From c3441b0320f632e22318261bcd614d10187de22d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 16 Mar 2023 10:36:33 +0100 Subject: Add video AP hooks --- server/lib/activitypub/videos/shared/creator.ts | 3 +++ server/lib/activitypub/videos/updater.ts | 3 +++ 2 files changed, 6 insertions(+) (limited to 'server/lib/activitypub') diff --git a/server/lib/activitypub/videos/shared/creator.ts b/server/lib/activitypub/videos/shared/creator.ts index 07252fea2..77321d8a5 100644 --- a/server/lib/activitypub/videos/shared/creator.ts +++ b/server/lib/activitypub/videos/shared/creator.ts @@ -1,6 +1,7 @@ import { logger, loggerTagsFactory, LoggerTagsFn } from '@server/helpers/logger' import { sequelizeTypescript } from '@server/initializers/database' +import { Hooks } from '@server/lib/plugins/hooks' import { autoBlacklistVideoIfNeeded } from '@server/lib/video-blacklist' import { VideoModel } from '@server/models/video/video' import { MThumbnail, MVideoFullLight, MVideoThumbnail } from '@server/types/models' @@ -61,6 +62,8 @@ export class APVideoCreator extends APVideoAbstractBuilder { logger.info('Remote video with uuid %s inserted.', this.videoObject.uuid, this.lTags()) + Hooks.runAction('action:activity-pub.remote-video.created', { video: videoCreated, videoAPObject: this.videoObject }) + return { autoBlacklisted, videoCreated } } catch (err) { // FIXME: Use rollback hook when https://github.com/sequelize/sequelize/pull/13038 is released diff --git a/server/lib/activitypub/videos/updater.ts b/server/lib/activitypub/videos/updater.ts index 0bf32f440..3677dc3bb 100644 --- a/server/lib/activitypub/videos/updater.ts +++ b/server/lib/activitypub/videos/updater.ts @@ -3,6 +3,7 @@ import { resetSequelizeInstance, runInReadCommittedTransaction } from '@server/h import { logger, loggerTagsFactory, LoggerTagsFn } from '@server/helpers/logger' import { Notifier } from '@server/lib/notifier' import { PeerTubeSocket } from '@server/lib/peertube-socket' +import { Hooks } from '@server/lib/plugins/hooks' import { autoBlacklistVideoIfNeeded } from '@server/lib/video-blacklist' import { VideoLiveModel } from '@server/models/video/video-live' import { MActor, MChannelAccountLight, MChannelId, MVideoAccountLightBlacklistAllFiles, MVideoFullLight } from '@server/types/models' @@ -81,6 +82,8 @@ export class APVideoUpdater extends APVideoAbstractBuilder { PeerTubeSocket.Instance.sendVideoLiveNewState(videoUpdated) } + Hooks.runAction('action:activity-pub.remote-video.updated', { video: videoUpdated, videoAPObject: this.videoObject }) + logger.info('Remote video with uuid %s updated', this.videoObject.uuid, this.lTags()) return videoUpdated -- cgit v1.2.3