From 55cd7b397d93b13e800de6e825a4886dcb1fed7e Mon Sep 17 00:00:00 2001 From: Ludovic Ortega Date: Tue, 9 Jun 2026 18:14:34 +0200 Subject: [PATCH] refactor: add checkUpdateAvailable to status endpoint Signed-off-by: Ludovic Ortega --- seerr-api.yml | 10 +++- server/interfaces/api/settingsInterfaces.ts | 4 +- server/routes/index.ts | 56 ++++++++++--------- src/components/Layout/VersionStatus/index.tsx | 34 +++++------ src/components/StatusChecker/index.tsx | 2 +- 5 files changed, 59 insertions(+), 47 deletions(-) diff --git a/seerr-api.yml b/seerr-api.yml index 2a3add3d3..38876ff82 100644 --- a/seerr-api.yml +++ b/seerr-api.yml @@ -2150,10 +2150,18 @@ paths: /status: get: summary: Get Seerr status - description: Returns the current Seerr status in a JSON object. + description: Returns the current Seerr status in a JSON object. updateAvailable and commitsBehind are omitted when checkUpdateAvailable is false. security: [] tags: - public + parameters: + - in: query + name: checkUpdateAvailable + description: If false, updateAvailable and commitsBehind will be omitted from the response. Defaults to true. + required: false + example: false + schema: + type: boolean responses: '200': description: Returned status diff --git a/server/interfaces/api/settingsInterfaces.ts b/server/interfaces/api/settingsInterfaces.ts index aae3feedc..f2793c9aa 100644 --- a/server/interfaces/api/settingsInterfaces.ts +++ b/server/interfaces/api/settingsInterfaces.ts @@ -76,7 +76,7 @@ export interface CacheResponse { export interface StatusResponse { version: string; commitTag: string; - updateAvailable: boolean; - commitsBehind: number; + updateAvailable?: boolean; + commitsBehind?: number; restartRequired: boolean; } diff --git a/server/routes/index.ts b/server/routes/index.ts index f701acf96..e3ee9981c 100644 --- a/server/routes/index.ts +++ b/server/routes/index.ts @@ -48,40 +48,43 @@ const router = Router(); router.use(checkUser); router.get('/status', async (req, res) => { - const githubApi = new GithubAPI(); - const currentVersion = getAppVersion(); const commitTag = getCommitTag(); + const checkUpdate = String(req.query.checkUpdateAvailable) !== 'false'; let updateAvailable = false; let commitsBehind = 0; - if (currentVersion.startsWith('develop-') && commitTag !== 'local') { - const commits = await githubApi.getSeerrCommits(); + if (checkUpdate) { + const githubApi = new GithubAPI(); - if (commits.length) { - const filteredCommits = commits.filter( - (commit) => !commit.commit.message.includes('[skip ci]') - ); - if (filteredCommits[0].sha !== commitTag) { - updateAvailable = true; + if (currentVersion.startsWith('develop-') && commitTag !== 'local') { + const commits = await githubApi.getSeerrCommits(); + + if (commits.length) { + const filteredCommits = commits.filter( + (commit) => !commit.commit.message.includes('[skip ci]') + ); + if (filteredCommits[0].sha !== commitTag) { + updateAvailable = true; + } + + const commitIndex = filteredCommits.findIndex( + (commit) => commit.sha === commitTag + ); + + if (updateAvailable) { + commitsBehind = commitIndex; + } } + } else if (commitTag !== 'local') { + const releases = await githubApi.getSeerrReleases(); - const commitIndex = filteredCommits.findIndex( - (commit) => commit.sha === commitTag - ); + if (releases.length) { + const latestVersion = releases[0]; - if (updateAvailable) { - commitsBehind = commitIndex; - } - } - } else if (commitTag !== 'local') { - const releases = await githubApi.getSeerrReleases(); - - if (releases.length) { - const latestVersion = releases[0]; - - if (!latestVersion.name.includes(currentVersion)) { - updateAvailable = true; + if (!latestVersion.name.includes(currentVersion)) { + updateAvailable = true; + } } } } @@ -89,8 +92,7 @@ router.get('/status', async (req, res) => { return res.status(200).json({ version: getAppVersion(), commitTag: getCommitTag(), - updateAvailable, - commitsBehind, + ...(checkUpdate && { updateAvailable, commitsBehind }), restartRequired: restartFlag.isSet(), }); }); diff --git a/src/components/Layout/VersionStatus/index.tsx b/src/components/Layout/VersionStatus/index.tsx index 44d59c9fd..1b4e428f2 100644 --- a/src/components/Layout/VersionStatus/index.tsx +++ b/src/components/Layout/VersionStatus/index.tsx @@ -27,7 +27,7 @@ const VersionStatus = ({ onClick }: VersionStatusProps) => { const settings = useSettings(); const intl = useIntl(); const { data } = useSWR( - settings.currentSettings.versionCheck ? '/api/v1/status' : null, + `/api/v1/status?checkUpdateAvailable=${settings.currentSettings.versionCheck}`, { refreshInterval: 60 * 1000, } @@ -70,21 +70,23 @@ const VersionStatus = ({ onClick }: VersionStatusProps) => { )}
{versionStream} - - {data.commitTag === 'local' ? ( - '(⌐■_■)' - ) : data.commitsBehind > 0 ? ( - intl.formatMessage(messages.commitsbehind, { - commitsBehind: data.commitsBehind, - }) - ) : data.commitsBehind === -1 ? ( - intl.formatMessage(messages.outofdate) - ) : ( - - {data.version.replace('develop-', '')} - - )} - + {data.commitsBehind !== undefined && ( + + {data.commitTag === 'local' ? ( + '(⌐■_■)' + ) : data.commitsBehind > 0 ? ( + intl.formatMessage(messages.commitsbehind, { + commitsBehind: data.commitsBehind, + }) + ) : data.commitsBehind === -1 ? ( + intl.formatMessage(messages.outofdate) + ) : ( + + {data.version.replace('develop-', '')} + + )} + + )}
{data.updateAvailable && } diff --git a/src/components/StatusChecker/index.tsx b/src/components/StatusChecker/index.tsx index 8d726a3b9..5190b5603 100644 --- a/src/components/StatusChecker/index.tsx +++ b/src/components/StatusChecker/index.tsx @@ -24,7 +24,7 @@ const StatusChecker = () => { const settings = useSettings(); const { hasPermission } = useUser(); const { data, error } = useSWR( - settings.currentSettings.versionCheck ? '/api/v1/status' : null, + '/api/v1/status?checkUpdateAvailable=false', { refreshInterval: 60 * 1000, }