diff options
author | Chocobozzz <me@florianbigard.com> | 2019-01-14 11:30:15 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-01-14 11:30:15 +0100 |
commit | 744d0eca195bce7dafeb4a958d0eb3c0046be32d (patch) | |
tree | 226c28f7fc63d1f6bf32095d7db0ef26a5b7073a /server/controllers/api | |
parent | bb8f7872f5a473c47a688b0c282ff34cd78a9835 (diff) | |
download | PeerTube-744d0eca195bce7dafeb4a958d0eb3c0046be32d.tar.gz PeerTube-744d0eca195bce7dafeb4a958d0eb3c0046be32d.tar.zst PeerTube-744d0eca195bce7dafeb4a958d0eb3c0046be32d.zip |
Refresh remote actors on GET enpoints
Diffstat (limited to 'server/controllers/api')
-rw-r--r-- | server/controllers/api/accounts.ts | 7 | ||||
-rw-r--r-- | server/controllers/api/video-channel.ts | 6 | ||||
-rw-r--r-- | server/controllers/api/videos/index.ts | 2 |
3 files changed, 14 insertions, 1 deletions
diff --git a/server/controllers/api/accounts.ts b/server/controllers/api/accounts.ts index a69a83acf..8c0237203 100644 --- a/server/controllers/api/accounts.ts +++ b/server/controllers/api/accounts.ts | |||
@@ -14,6 +14,8 @@ import { AccountModel } from '../../models/account/account' | |||
14 | import { VideoModel } from '../../models/video/video' | 14 | import { VideoModel } from '../../models/video/video' |
15 | import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' | 15 | import { buildNSFWFilter, isUserAbleToSearchRemoteURI } from '../../helpers/express-utils' |
16 | import { VideoChannelModel } from '../../models/video/video-channel' | 16 | import { VideoChannelModel } from '../../models/video/video-channel' |
17 | import { JobQueue } from '../../lib/job-queue' | ||
18 | import { logger } from '../../helpers/logger' | ||
17 | 19 | ||
18 | const accountsRouter = express.Router() | 20 | const accountsRouter = express.Router() |
19 | 21 | ||
@@ -57,6 +59,11 @@ export { | |||
57 | function getAccount (req: express.Request, res: express.Response, next: express.NextFunction) { | 59 | function getAccount (req: express.Request, res: express.Response, next: express.NextFunction) { |
58 | const account: AccountModel = res.locals.account | 60 | const account: AccountModel = res.locals.account |
59 | 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 | |||
60 | return res.json(account.toFormattedJSON()) | 67 | return res.json(account.toFormattedJSON()) |
61 | } | 68 | } |
62 | 69 | ||
diff --git a/server/controllers/api/video-channel.ts b/server/controllers/api/video-channel.ts index 3d6a6af7f..db7602139 100644 --- a/server/controllers/api/video-channel.ts +++ b/server/controllers/api/video-channel.ts | |||
@@ -30,6 +30,7 @@ import { updateActorAvatarFile } from '../../lib/avatar' | |||
30 | import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' | 30 | import { auditLoggerFactory, getAuditIdFromRes, VideoChannelAuditView } from '../../helpers/audit-logger' |
31 | import { resetSequelizeInstance } from '../../helpers/database-utils' | 31 | import { resetSequelizeInstance } from '../../helpers/database-utils' |
32 | import { UserModel } from '../../models/account/user' | 32 | import { UserModel } from '../../models/account/user' |
33 | import { JobQueue } from '../../lib/job-queue' | ||
33 | 34 | ||
34 | const auditLogger = auditLoggerFactory('channels') | 35 | const auditLogger = auditLoggerFactory('channels') |
35 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) | 36 | const reqAvatarFile = createReqFiles([ 'avatarfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { avatarfile: CONFIG.STORAGE.TMP_DIR }) |
@@ -197,6 +198,11 @@ async function removeVideoChannel (req: express.Request, res: express.Response) | |||
197 | async function getVideoChannel (req: express.Request, res: express.Response, next: express.NextFunction) { | 198 | async function getVideoChannel (req: express.Request, res: express.Response, next: express.NextFunction) { |
198 | const videoChannelWithVideos = await VideoChannelModel.loadAndPopulateAccountAndVideos(res.locals.videoChannel.id) | 199 | const videoChannelWithVideos = await VideoChannelModel.loadAndPopulateAccountAndVideos(res.locals.videoChannel.id) |
199 | 200 | ||
201 | if (videoChannelWithVideos.isOutdated()) { | ||
202 | JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'actor', url: videoChannelWithVideos.Actor.url } }) | ||
203 | .catch(err => logger.error('Cannot create AP refresher job for actor %s.', videoChannelWithVideos.Actor.url, { err })) | ||
204 | } | ||
205 | |||
200 | return res.json(videoChannelWithVideos.toFormattedJSON()) | 206 | return res.json(videoChannelWithVideos.toFormattedJSON()) |
201 | } | 207 | } |
202 | 208 | ||
diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 28ac26598..2b2dfa7ca 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts | |||
@@ -399,7 +399,7 @@ function getVideo (req: express.Request, res: express.Response) { | |||
399 | const videoInstance = res.locals.video | 399 | const videoInstance = res.locals.video |
400 | 400 | ||
401 | if (videoInstance.isOutdated()) { | 401 | if (videoInstance.isOutdated()) { |
402 | JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video', videoUrl: videoInstance.url } }) | 402 | JobQueue.Instance.createJob({ type: 'activitypub-refresher', payload: { type: 'video', url: videoInstance.url } }) |
403 | .catch(err => logger.error('Cannot create AP refresher job for video %s.', videoInstance.url, { err })) | 403 | .catch(err => logger.error('Cannot create AP refresher job for video %s.', videoInstance.url, { err })) |
404 | } | 404 | } |
405 | 405 | ||