diff options
Diffstat (limited to 'server/controllers')
-rw-r--r-- | server/controllers/activitypub/inbox.ts | 2 | ||||
-rw-r--r-- | server/controllers/api/config.ts | 4 | ||||
-rw-r--r-- | server/controllers/api/server/index.ts | 2 | ||||
-rw-r--r-- | server/controllers/api/server/stats.ts | 39 |
4 files changed, 45 insertions, 2 deletions
diff --git a/server/controllers/activitypub/inbox.ts b/server/controllers/activitypub/inbox.ts index bd0d7a9c8..0354d7833 100644 --- a/server/controllers/activitypub/inbox.ts +++ b/server/controllers/activitypub/inbox.ts | |||
@@ -56,6 +56,8 @@ async function inboxController (req: express.Request, res: express.Response, nex | |||
56 | specificActor = res.locals.videoChannel | 56 | specificActor = res.locals.videoChannel |
57 | } | 57 | } |
58 | 58 | ||
59 | logger.info('Receiving inbox requests for %d activities by %s.', activities.length, res.locals.signature.actor) | ||
60 | |||
59 | await processActivities(activities, res.locals.signature.actor, specificActor) | 61 | await processActivities(activities, res.locals.signature.actor, specificActor) |
60 | 62 | ||
61 | res.status(204).end() | 63 | res.status(204).end() |
diff --git a/server/controllers/api/config.ts b/server/controllers/api/config.ts index 7ef0c19e3..427125810 100644 --- a/server/controllers/api/config.ts +++ b/server/controllers/api/config.ts | |||
@@ -1,8 +1,8 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { omit } from 'lodash' | 2 | import { omit } from 'lodash' |
3 | import { ServerConfig, UserRight } from '../../../shared' | 3 | import { ServerConfig, UserRight } from '../../../shared' |
4 | import { About } from '../../../shared/models/config/about.model' | 4 | import { About } from '../../../shared/models/server/about.model' |
5 | import { CustomConfig } from '../../../shared/models/config/custom-config.model' | 5 | import { CustomConfig } from '../../../shared/models/server/custom-config.model' |
6 | import { unlinkPromise, writeFilePromise } from '../../helpers/core-utils' | 6 | import { unlinkPromise, writeFilePromise } from '../../helpers/core-utils' |
7 | import { isSignupAllowed } from '../../helpers/utils' | 7 | import { isSignupAllowed } from '../../helpers/utils' |
8 | import { CONFIG, CONSTRAINTS_FIELDS, reloadConfig } from '../../initializers' | 8 | import { CONFIG, CONSTRAINTS_FIELDS, reloadConfig } from '../../initializers' |
diff --git a/server/controllers/api/server/index.ts b/server/controllers/api/server/index.ts index 8dc1a0031..850a52cdb 100644 --- a/server/controllers/api/server/index.ts +++ b/server/controllers/api/server/index.ts | |||
@@ -1,9 +1,11 @@ | |||
1 | import * as express from 'express' | 1 | import * as express from 'express' |
2 | import { serverFollowsRouter } from './follows' | 2 | import { serverFollowsRouter } from './follows' |
3 | import { statsRouter } from './stats' | ||
3 | 4 | ||
4 | const serverRouter = express.Router() | 5 | const serverRouter = express.Router() |
5 | 6 | ||
6 | serverRouter.use('/', serverFollowsRouter) | 7 | serverRouter.use('/', serverFollowsRouter) |
8 | serverRouter.use('/', statsRouter) | ||
7 | 9 | ||
8 | // --------------------------------------------------------------------------- | 10 | // --------------------------------------------------------------------------- |
9 | 11 | ||
diff --git a/server/controllers/api/server/stats.ts b/server/controllers/api/server/stats.ts new file mode 100644 index 000000000..6f4fe938c --- /dev/null +++ b/server/controllers/api/server/stats.ts | |||
@@ -0,0 +1,39 @@ | |||
1 | import * as express from 'express' | ||
2 | import { ServerStats } from '../../../../shared/models/server/server-stats.model' | ||
3 | import { asyncMiddleware } from '../../../middlewares' | ||
4 | import { UserModel } from '../../../models/account/user' | ||
5 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | ||
6 | import { VideoModel } from '../../../models/video/video' | ||
7 | import { VideoCommentModel } from '../../../models/video/video-comment' | ||
8 | |||
9 | const statsRouter = express.Router() | ||
10 | |||
11 | statsRouter.get('/stats', | ||
12 | asyncMiddleware(getStats) | ||
13 | ) | ||
14 | |||
15 | async function getStats (req: express.Request, res: express.Response, next: express.NextFunction) { | ||
16 | const { totalLocalVideos, totalLocalVideoViews, totalVideos } = await VideoModel.getStats() | ||
17 | const { totalLocalVideoComments, totalVideoComments } = await VideoCommentModel.getStats() | ||
18 | const { totalUsers } = await UserModel.getStats() | ||
19 | const { totalInstanceFollowers, totalInstanceFollowing } = await ActorFollowModel.getStats() | ||
20 | |||
21 | const data: ServerStats = { | ||
22 | totalLocalVideos, | ||
23 | totalLocalVideoViews, | ||
24 | totalVideos, | ||
25 | totalLocalVideoComments, | ||
26 | totalVideoComments, | ||
27 | totalUsers, | ||
28 | totalInstanceFollowers, | ||
29 | totalInstanceFollowing | ||
30 | } | ||
31 | |||
32 | return res.json(data).end() | ||
33 | } | ||
34 | |||
35 | // --------------------------------------------------------------------------- | ||
36 | |||
37 | export { | ||
38 | statsRouter | ||
39 | } | ||