@@ -134,7 +134,7 @@ pub async fn init_panelapi(pool: PgPool, cache_http: botox::cache::CacheHttpImpl
134134 . allow_headers ( Any ) ,
135135 ) ;
136136
137- let addr = format ! ( "127 .0.0.1 :{}" , crate :: config:: CONFIG . server_port. get( ) ) ;
137+ let addr = format ! ( "0 .0.0.0 :{}" , crate :: config:: CONFIG . server_port. get( ) ) ;
138138 info ! ( "Starting server on {}" , addr) ;
139139
140140 let listener = tokio:: net:: TcpListener :: bind ( addr)
@@ -201,11 +201,6 @@ async fn query(
201201 . await
202202 . map_err ( Error :: new) ?;
203203
204- let total_changelogs = sqlx:: query!( "SELECT COUNT(*) FROM changelogs" )
205- . fetch_one ( & state. pool )
206- . await
207- . map_err ( Error :: new) ?;
208-
209204 Ok ( (
210205 StatusCode :: OK ,
211206 Json ( BaseAnalytics {
@@ -231,7 +226,7 @@ async fn query(
231226 } )
232227 . collect ( ) ,
233228 total_users : total_users. count . unwrap_or_default ( ) ,
234- changelogs_count : total_changelogs . count . unwrap_or_default ( ) ,
229+ changelogs_count : 0 ,
235230 } ) ,
236231 )
237232 . into_response ( ) )
@@ -1640,191 +1635,14 @@ async fn query(
16401635 }
16411636 }
16421637 PanelQuery :: UpdateChangelog {
1643- login_token,
1644- action,
1638+ ..
16451639 } => {
1646- let auth_data = super :: auth:: check_auth ( & state. pool , & login_token)
1647- . await
1648- . map_err ( Error :: new) ?;
1649-
1650- let user_perms = get_user_perms ( & state. pool , & auth_data. user_id )
1651- . await
1652- . map_err ( Error :: new) ?
1653- . resolve ( ) ;
1654-
1655- match action {
1656- ChangelogAction :: ListEntries => {
1657- let rows = sqlx:: query!(
1658- "SELECT version, added, updated, removed, github_html, created_at, extra_description, prerelease, published FROM changelogs ORDER BY version::semver DESC"
1659- )
1660- . fetch_all ( & state. pool )
1661- . await
1662- . map_err ( Error :: new) ?;
1663-
1664- let mut entries = Vec :: new ( ) ;
1665-
1666- for row in rows {
1667- entries. push ( ChangelogEntry {
1668- version : row. version ,
1669- added : row. added ,
1670- updated : row. updated ,
1671- removed : row. removed ,
1672- github_html : row. github_html ,
1673- created_at : row. created_at ,
1674- extra_description : row. extra_description ,
1675- prerelease : row. prerelease ,
1676- published : row. published ,
1677- } ) ;
1678- }
1679-
1680- Ok ( ( StatusCode :: OK , Json ( entries) ) . into_response ( ) )
1681- }
1682- ChangelogAction :: CreateEntry {
1683- version,
1684- extra_description,
1685- prerelease,
1686- added,
1687- updated,
1688- removed,
1689- } => {
1690- if !perms:: has_perm ( & user_perms, & "changelogs.create" . into ( ) ) {
1691- return Ok ( (
1692- StatusCode :: FORBIDDEN ,
1693- "You do not have permission to create changelog entries [changelogs.create]"
1694- . to_string ( ) ,
1695- )
1696- . into_response ( ) ) ;
1697- }
1698-
1699- // Check if entry already exists with same vesion
1700- if sqlx:: query!(
1701- "SELECT COUNT(*) FROM changelogs WHERE version = $1" ,
1702- version
1703- )
1704- . fetch_one ( & state. pool )
1705- . await
1706- . map_err ( Error :: new) ?
1707- . count
1708- . unwrap_or ( 0 )
1709- > 0
1710- {
1711- return Ok ( (
1712- StatusCode :: BAD_REQUEST ,
1713- "Entry with same version already exists" . to_string ( ) ,
1714- )
1715- . into_response ( ) ) ;
1716- }
1717-
1718- // Insert entry
1719- sqlx:: query!(
1720- "INSERT INTO changelogs (version, extra_description, prerelease, added, updated, removed) VALUES ($1, $2, $3, $4, $5, $6)" ,
1721- version,
1722- extra_description,
1723- prerelease,
1724- & added,
1725- & updated,
1726- & removed,
1727- )
1728- . execute ( & state. pool )
1729- . await
1730- . map_err ( Error :: new) ?;
1731-
1732- Ok ( ( StatusCode :: NO_CONTENT , "" ) . into_response ( ) )
1733- }
1734- ChangelogAction :: UpdateEntry {
1735- version,
1736- extra_description,
1737- github_html,
1738- prerelease,
1739- added,
1740- updated,
1741- removed,
1742- published,
1743- } => {
1744- if !perms:: has_perm ( & user_perms, & "changelogs.update" . into ( ) ) {
1745- return Ok ( (
1746- StatusCode :: FORBIDDEN ,
1747- "You do not have permission to update changelog entries [changelogs.update]"
1748- . to_string ( ) ,
1749- )
1750- . into_response ( ) ) ;
1751- }
1752-
1753- // Check if entry already exists with same vesion
1754- if sqlx:: query!(
1755- "SELECT COUNT(*) FROM changelogs WHERE version = $1" ,
1756- version
1757- )
1758- . fetch_one ( & state. pool )
1759- . await
1760- . map_err ( Error :: new) ?
1761- . count
1762- . unwrap_or ( 0 )
1763- == 0
1764- {
1765- return Ok ( (
1766- StatusCode :: BAD_REQUEST ,
1767- "Entry with same version does not already exist" . to_string ( ) ,
1768- )
1769- . into_response ( ) ) ;
1770- }
1771-
1772- // Update entry
1773- sqlx:: query!(
1774- "UPDATE changelogs SET extra_description = $2, github_html = $3, prerelease = $4, added = $5, updated = $6, removed = $7, published = $8 WHERE version = $1" ,
1775- version,
1776- extra_description,
1777- github_html,
1778- prerelease,
1779- & added,
1780- & updated,
1781- & removed,
1782- published
1783- )
1784- . execute ( & state. pool )
1785- . await
1786- . map_err ( Error :: new) ?;
1787-
1788- Ok ( ( StatusCode :: NO_CONTENT , "" ) . into_response ( ) )
1789- }
1790- ChangelogAction :: DeleteEntry { version } => {
1791- if !perms:: has_perm ( & user_perms, & "changelogs.delete" . into ( ) ) {
1792- return Ok ( (
1793- StatusCode :: FORBIDDEN ,
1794- "You do not have permission to delete changelog entries [changelogs.delete]"
1795- . to_string ( ) ,
1796- )
1797- . into_response ( ) ) ;
1798- }
1799-
1800- // Check if entry already exists with same vesion
1801- if sqlx:: query!(
1802- "SELECT COUNT(*) FROM changelogs WHERE version = $1" ,
1803- version
1804- )
1805- . fetch_one ( & state. pool )
1806- . await
1807- . map_err ( Error :: new) ?
1808- . count
1809- . unwrap_or ( 0 )
1810- == 0
1811- {
1812- return Ok ( (
1813- StatusCode :: BAD_REQUEST ,
1814- "Entry with same version does not already exist" . to_string ( ) ,
1815- )
1816- . into_response ( ) ) ;
1817- }
1818-
1819- // Delete entry
1820- sqlx:: query!( "DELETE FROM changelogs WHERE version = $1" , version)
1821- . execute ( & state. pool )
1822- . await
1823- . map_err ( Error :: new) ?;
1824-
1825- Ok ( ( StatusCode :: NO_CONTENT , "" ) . into_response ( ) )
1826- }
1827- }
1640+ return Ok ( (
1641+ StatusCode :: FORBIDDEN ,
1642+ "You do not have permission to create changelog entries [not implemented]"
1643+ . to_string ( ) ,
1644+ )
1645+ . into_response ( ) ) ;
18281646 }
18291647 PanelQuery :: UpdateBlog {
18301648 login_token,
0 commit comments