aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/controllers/api/accounts.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/controllers/api/accounts.ts')
-rw-r--r--server/controllers/api/accounts.ts18
1 files changed, 14 insertions, 4 deletions
diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts
index b7691ccba..8c0237203 100644
--- a/server/controllers/api/accounts.ts
+++ b/server/controllers/api/accounts.ts
@@ -1,7 +1,8 @@
1import * as express from 'express' 1import * as express from 'express'
2import { getFormattedObjects } from '../../helpers/utils' 2import { getFormattedObjects } from '../../helpers/utils'
3import { 3import {
4 asyncMiddleware, commonVideosFiltersValidator, 4 asyncMiddleware,
5 commonVideosFiltersValidator,
5 listVideoAccountChannelsValidator, 6 listVideoAccountChannelsValidator,
6 optionalAuthenticate, 7 optionalAuthenticate,
7 paginationValidator, 8 paginationValidator,
@@ -13,6 +14,8 @@ import { AccountModel } from '../../models/account/account'
13import { VideoModel } from '../../models/video/video' 14import { VideoModel } from '../../models/video/video'
14import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' 15import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils'
15import { VideoChannelModel } from '../../models/video/video-channel' 16import { VideoChannelModel } from '../../models/video/video-channel'
17import { JobQueue } from '../../lib/job-queue'
18import { logger } from '../../helpers/logger'
16 19
17const accountsRouter = express.Router() 20const accountsRouter = express.Router()
18 21
@@ -56,6 +59,11 @@ export {
56function getAccount (req: express.Request, res: express.Response, next: express.NextFunction) { 59function getAccount (req: express.Request, res: express.Response, next: express.NextFunction) {
57 const account: AccountModel = res.locals.account 60 const account: AccountModel = res.locals.account
58 61
62 if (account.isOutdated()) {
63 JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'actor', url: account.Actor.url } })
64 .catch(err => logger.error('Cannot create AP refresher job for actor %s.', account.Actor.url, { err }))
65 }
66
59 return res.json(account.toFormattedJSON()) 67 return res.json(account.toFormattedJSON())
60} 68}
61 69
@@ -73,10 +81,10 @@ async function listVideoAccountChannels (req: express.Request, res: express.Resp
73 81
74async function listAccountVideos (req: express.Request, res: express.Response, next: express.NextFunction) { 82async function listAccountVideos (req: express.Request, res: express.Response, next: express.NextFunction) {
75 const account: AccountModel = res.locals.account 83 const account: AccountModel = res.locals.account
76 const actorId = isUserAbleToSearchRemoteURI(res) ? null : undefined 84 const followerActorId = isUserAbleToSearchRemoteURI(res) ? null : undefined
77 85
78 const resultList = await VideoModel.listForApi({ 86 const resultList = await VideoModel.listForApi({
79 actorId, 87 followerActorId,
80 start: req.query.start, 88 start: req.query.start,
81 count: req.query.count, 89 count: req.query.count,
82 sort: req.query.sort, 90 sort: req.query.sort,
@@ -86,9 +94,11 @@ async function listAccountVideos (req: express.Request, res: express.Response, n
86 languageOneOf: req.query.languageOneOf, 94 languageOneOf: req.query.languageOneOf,
87 tagsOneOf: req.query.tagsOneOf, 95 tagsOneOf: req.query.tagsOneOf,
88 tagsAllOf: req.query.tagsAllOf, 96 tagsAllOf: req.query.tagsAllOf,
97 filter: req.query.filter,
89 nsfw: buildNSFWFilter(res, req.query.nsfw), 98 nsfw: buildNSFWFilter(res, req.query.nsfw),
90 withFiles: false, 99 withFiles: false,
91 accountId: account.id 100 accountId: account.id,
101 user: res.locals.oauth ? res.locals.oauth.token.User : undefined
92 }) 102 })
93 103
94 return res.json(getFormattedObjects(resultList.data, resultList.total)) 104 return res.json(getFormattedObjects(resultList.data, resultList.total))