mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
feat: add overseerr version and update availability status to sidebar
sort of experimental so may be kinda broken. :)
This commit is contained in:
@@ -1,33 +1,75 @@
|
||||
import { Router } from 'express';
|
||||
import user from './user';
|
||||
import authRoutes from './auth';
|
||||
import { checkUser, isAuthenticated } from '../middleware/auth';
|
||||
import settingsRoutes from './settings';
|
||||
import GithubAPI from '../api/github';
|
||||
import TheMovieDb from '../api/themoviedb';
|
||||
import { StatusResponse } from '../interfaces/api/settingsInterfaces';
|
||||
import { Permission } from '../lib/permissions';
|
||||
import { getSettings } from '../lib/settings';
|
||||
import searchRoutes from './search';
|
||||
import discoverRoutes from './discover';
|
||||
import requestRoutes from './request';
|
||||
import movieRoutes from './movie';
|
||||
import tvRoutes from './tv';
|
||||
import mediaRoutes from './media';
|
||||
import personRoutes from './person';
|
||||
import collectionRoutes from './collection';
|
||||
import { getAppVersion, getCommitTag } from '../utils/appVersion';
|
||||
import serviceRoutes from './service';
|
||||
import { appDataStatus, appDataPath } from '../utils/appDataVolume';
|
||||
import TheMovieDb from '../api/themoviedb';
|
||||
import { checkUser, isAuthenticated } from '../middleware/auth';
|
||||
import { mapProductionCompany } from '../models/Movie';
|
||||
import { mapNetwork } from '../models/Tv';
|
||||
import { appDataPath, appDataStatus } from '../utils/appDataVolume';
|
||||
import { getAppVersion, getCommitTag } from '../utils/appVersion';
|
||||
import authRoutes from './auth';
|
||||
import collectionRoutes from './collection';
|
||||
import discoverRoutes from './discover';
|
||||
import mediaRoutes from './media';
|
||||
import movieRoutes from './movie';
|
||||
import personRoutes from './person';
|
||||
import requestRoutes from './request';
|
||||
import searchRoutes from './search';
|
||||
import serviceRoutes from './service';
|
||||
import settingsRoutes from './settings';
|
||||
import tvRoutes from './tv';
|
||||
import user from './user';
|
||||
|
||||
const router = Router();
|
||||
|
||||
router.use(checkUser);
|
||||
|
||||
router.get('/status', (req, res) => {
|
||||
router.get<unknown, StatusResponse>('/status', async (req, res) => {
|
||||
const githubApi = new GithubAPI();
|
||||
|
||||
const currentVersion = getAppVersion();
|
||||
const commitTag = getCommitTag();
|
||||
let updateAvailable = false;
|
||||
let commitsBehind = 0;
|
||||
|
||||
if (currentVersion.startsWith('develop-') && commitTag !== 'local') {
|
||||
const commits = await githubApi.getOverseerrCommits();
|
||||
|
||||
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.getOverseerrReleases();
|
||||
|
||||
if (releases.length) {
|
||||
const latestVersion = releases[0];
|
||||
|
||||
if (latestVersion.name !== currentVersion) {
|
||||
updateAvailable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res.status(200).json({
|
||||
version: getAppVersion(),
|
||||
commitTag: getCommitTag(),
|
||||
updateAvailable,
|
||||
commitsBehind,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -39,7 +81,7 @@ router.get('/status/appdata', (_req, res) => {
|
||||
});
|
||||
|
||||
router.use('/user', isAuthenticated(), user);
|
||||
router.get('/settings/public', (_req, res) => {
|
||||
router.get('/settings/public', async (_req, res) => {
|
||||
const settings = getSettings();
|
||||
|
||||
return res.status(200).json(settings.fullPublicSettings);
|
||||
|
Reference in New Issue
Block a user