From 07197db4c567f22bbc9c12339062896dc76bac2f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 27 Mar 2018 13:33:56 +0200 Subject: Try to refractor activities sending There is still a need for work on this part though --- server/controllers/activitypub/client.ts | 4 +- server/controllers/api/videos/index.ts | 8 +-- server/controllers/api/videos/rate.ts | 8 +-- server/lib/activitypub/index.ts | 7 +- server/lib/activitypub/send/send-announce.ts | 10 +-- server/lib/activitypub/send/send-create.ts | 102 +++++++++++---------------- server/lib/activitypub/send/send-like.ts | 19 +++-- server/lib/activitypub/send/send-undo.ts | 49 +++++-------- server/lib/activitypub/share.ts | 6 +- server/lib/activitypub/video-rates.ts | 46 +++--------- server/lib/video-comment.ts | 8 +-- 11 files changed, 99 insertions(+), 168 deletions(-) diff --git a/server/controllers/activitypub/client.ts b/server/controllers/activitypub/client.ts index 347079816..8e295b4f9 100644 --- a/server/controllers/activitypub/client.ts +++ b/server/controllers/activitypub/client.ts @@ -4,7 +4,7 @@ import { VideoPrivacy } from '../../../shared/models/videos' import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub' import { pageToStartAndCount } from '../../helpers/core-utils' import { ACTIVITY_PUB, CONFIG } from '../../initializers' -import { buildVideoAnnounceToFollowers } from '../../lib/activitypub/send' +import { buildVideoAnnounce } from '../../lib/activitypub/send' import { audiencify, getAudience } from '../../lib/activitypub/send/misc' import { createActivityData } from '../../lib/activitypub/send/send-create' import { asyncMiddleware, executeIfActivityPub, localAccountValidator } from '../../middlewares' @@ -130,7 +130,7 @@ async function videoController (req: express.Request, res: express.Response, nex async function videoAnnounceController (req: express.Request, res: express.Response, next: express.NextFunction) { const share = res.locals.videoShare as VideoShareModel - const object = await buildVideoAnnounceToFollowers(share.Actor, share, res.locals.video, undefined) + const object = await buildVideoAnnounce(share.Actor, share, res.locals.video, undefined) return res.json(activityPubContextify(object)) } diff --git a/server/controllers/api/videos/index.ts b/server/controllers/api/videos/index.ts index 690872320..552e5edac 100644 --- a/server/controllers/api/videos/index.ts +++ b/server/controllers/api/videos/index.ts @@ -20,7 +20,7 @@ import { VIDEO_PRIVACIES } from '../../../initializers' import { fetchRemoteVideoDescription, getVideoActivityPubUrl, shareVideoByServerAndChannel } from '../../../lib/activitypub' -import { sendCreateVideo, sendCreateViewToOrigin, sendCreateViewToVideoFollowers, sendUpdateVideo } from '../../../lib/activitypub/send' +import { sendCreateVideo, sendCreateView, sendUpdateVideo } from '../../../lib/activitypub/send' import { JobQueue } from '../../../lib/job-queue' import { Redis } from '../../../lib/redis' import { @@ -365,11 +365,7 @@ async function viewVideo (req: express.Request, res: express.Response) { const serverAccount = await getServerActor() - if (videoInstance.isOwned()) { - await sendCreateViewToVideoFollowers(serverAccount, videoInstance, undefined) - } else { - await sendCreateViewToOrigin(serverAccount, videoInstance, undefined) - } + await sendCreateView(serverAccount, videoInstance, undefined) return res.status(204).end() } diff --git a/server/controllers/api/videos/rate.ts b/server/controllers/api/videos/rate.ts index a7bd570eb..23e9de9f3 100644 --- a/server/controllers/api/videos/rate.ts +++ b/server/controllers/api/videos/rate.ts @@ -3,7 +3,7 @@ import { UserVideoRateUpdate } from '../../../../shared' import { retryTransactionWrapper } from '../../../helpers/database-utils' import { logger } from '../../../helpers/logger' import { sequelizeTypescript, VIDEO_RATE_TYPES } from '../../../initializers' -import { sendVideoRateChangeToFollowers, sendVideoRateChangeToOrigin } from '../../../lib/activitypub' +import { sendVideoRateChange } from '../../../lib/activitypub' import { asyncMiddleware, authenticate, videoRateValidator } from '../../../middlewares' import { AccountModel } from '../../../models/account/account' import { AccountVideoRateModel } from '../../../models/account/account-video-rate' @@ -83,11 +83,7 @@ async function rateVideo (req: express.Request, res: express.Response) { // It is useful for the user to have a feedback await videoInstance.increment(incrementQuery, sequelizeOptions) - if (videoInstance.isOwned()) { - await sendVideoRateChangeToFollowers(accountInstance, videoInstance, likesToIncrement, dislikesToIncrement, t) - } else { - await sendVideoRateChangeToOrigin(accountInstance, videoInstance, likesToIncrement, dislikesToIncrement, t) - } + await sendVideoRateChange(accountInstance, videoInstance, likesToIncrement, dislikesToIncrement, t) }) logger.info('Account video rate for video %s of account %s updated.', videoInstance.name, accountInstance.name) diff --git a/server/lib/activitypub/index.ts b/server/lib/activitypub/index.ts index 0779d1e91..88064c6b6 100644 --- a/server/lib/activitypub/index.ts +++ b/server/lib/activitypub/index.ts @@ -4,9 +4,6 @@ export * from './actor' export * from './fetch' export * from './share' export * from './videos' +export * from './video-comments' +export * from './video-rates' export * from './url' -export { videoCommentActivityObjectToDBAttributes } from './video-comments' -export { addVideoComments } from './video-comments' -export { addVideoComment } from './video-comments' -export { sendVideoRateChangeToFollowers } from './video-rates' -export { sendVideoRateChangeToOrigin } from './video-rates' diff --git a/server/lib/activitypub/send/send-announce.ts b/server/lib/activitypub/send/send-announce.ts index ed551a2b2..4179c9d43 100644 --- a/server/lib/activitypub/send/send-announce.ts +++ b/server/lib/activitypub/send/send-announce.ts @@ -5,7 +5,7 @@ import { VideoModel } from '../../../models/video/video' import { VideoShareModel } from '../../../models/video/video-share' import { broadcastToFollowers, getActorsInvolvedInVideo, getAudience, getObjectFollowersAudience } from './misc' -async function buildVideoAnnounceToFollowers (byActor: ActorModel, videoShare: VideoShareModel, video: VideoModel, t: Transaction) { +async function buildVideoAnnounce (byActor: ActorModel, videoShare: VideoShareModel, video: VideoModel, t: Transaction) { const announcedObject = video.url const accountsToForwardView = await getActorsInvolvedInVideo(video, t) @@ -13,8 +13,8 @@ async function buildVideoAnnounceToFollowers (byActor: ActorModel, videoShare: V return announceActivityData(videoShare.url, byActor, announcedObject, t, audience) } -async function sendVideoAnnounceToFollowers (byActor: ActorModel, videoShare: VideoShareModel, video: VideoModel, t: Transaction) { - const data = await buildVideoAnnounceToFollowers(byActor, videoShare, video, t) +async function sendVideoAnnounce (byActor: ActorModel, videoShare: VideoShareModel, video: VideoModel, t: Transaction) { + const data = await buildVideoAnnounce(byActor, videoShare, video, t) return broadcastToFollowers(data, byActor, [ byActor ], t) } @@ -43,7 +43,7 @@ async function announceActivityData ( // --------------------------------------------------------------------------- export { - sendVideoAnnounceToFollowers, + sendVideoAnnounce, announceActivityData, - buildVideoAnnounceToFollowers + buildVideoAnnounce } diff --git a/server/lib/activitypub/send/send-create.ts b/server/lib/activitypub/send/send-create.ts index d73dd8d24..4ff20b033 100644 --- a/server/lib/activitypub/send/send-create.ts +++ b/server/lib/activitypub/send/send-create.ts @@ -40,105 +40,92 @@ async function sendVideoAbuse (byActor: ActorModel, videoAbuse: VideoAbuseModel, return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl) } -async function sendCreateVideoCommentToOrigin (comment: VideoCommentModel, t: Transaction) { +async function sendCreateVideoComment (comment: VideoCommentModel, t: Transaction) { + const isOrigin = comment.Video.isOwned() + const byActor = comment.Account.Actor const threadParentComments = await VideoCommentModel.listThreadParentComments(comment, t) const commentObject = comment.toActivityPubObject(threadParentComments) const actorsInvolvedInComment = await getActorsInvolvedInVideo(comment.Video, t) actorsInvolvedInComment.push(byActor) - const audience = getVideoCommentAudience(comment, threadParentComments, actorsInvolvedInComment) - - const data = await createActivityData(comment.url, byActor, commentObject, t, audience) - - // This was a reply, send it to the parent actors - const actorsException = [ byActor ] - await broadcastToActors(data, byActor, threadParentComments.map(c => c.Account.Actor), actorsException) - - // Broadcast to our followers - await broadcastToFollowers(data, byActor, [ byActor ], t) - // Send to origin - return unicastTo(data, byActor, comment.Video.VideoChannel.Account.Actor.sharedInboxUrl) -} + const parentsCommentActors = threadParentComments.map(c => c.Account.Actor) -async function sendCreateVideoCommentToVideoFollowers (comment: VideoCommentModel, t: Transaction) { - const byActor = comment.Account.Actor - const threadParentComments = await VideoCommentModel.listThreadParentComments(comment, t) - const commentObject = comment.toActivityPubObject(threadParentComments) - - const actorsInvolvedInComment = await getActorsInvolvedInVideo(comment.Video, t) - actorsInvolvedInComment.push(byActor) + let audience: ActivityAudience + if (isOrigin) { + audience = getVideoCommentAudience(comment, threadParentComments, actorsInvolvedInComment, isOrigin) + } else { + audience = getObjectFollowersAudience(actorsInvolvedInComment.concat(parentsCommentActors)) + } - const audience = getVideoCommentAudience(comment, threadParentComments, actorsInvolvedInComment, true) const data = await createActivityData(comment.url, byActor, commentObject, t, audience) // This was a reply, send it to the parent actors const actorsException = [ byActor ] - await broadcastToActors(data, byActor, threadParentComments.map(c => c.Account.Actor), actorsException) + await broadcastToActors(data, byActor, parentsCommentActors, actorsException) // Broadcast to our followers await broadcastToFollowers(data, byActor, [ byActor ], t) // Send to actors involved in the comment - return broadcastToFollowers(data, byActor, actorsInvolvedInComment, t, actorsException) + if (isOrigin) return broadcastToFollowers(data, byActor, actorsInvolvedInComment, t, actorsException) + + // Send to origin + return unicastTo(data, byActor, comment.Video.VideoChannel.Account.Actor.sharedInboxUrl) } -async function sendCreateViewToOrigin (byActor: ActorModel, video: VideoModel, t: Transaction) { +async function sendCreateView (byActor: ActorModel, video: VideoModel, t: Transaction) { const url = getVideoViewActivityPubUrl(byActor, video) const viewActivityData = createViewActivityData(byActor, video) const actorsInvolvedInVideo = await getActorsInvolvedInVideo(video, t) - const audience = getOriginVideoAudience(video, actorsInvolvedInVideo) - const data = await createActivityData(url, byActor, viewActivityData, t, audience) - return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl) -} + // Send to origin + if (video.isOwned() === false) { + const audience = getOriginVideoAudience(video, actorsInvolvedInVideo) + const data = await createActivityData(url, byActor, viewActivityData, t, audience) -async function sendCreateViewToVideoFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) { - const url = getVideoViewActivityPubUrl(byActor, video) - const viewActivityData = createViewActivityData(byActor, video) + return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl) + } - const actorsToForwardView = await getActorsInvolvedInVideo(video, t) - const audience = getObjectFollowersAudience(actorsToForwardView) + // Send to followers + const audience = getObjectFollowersAudience(actorsInvolvedInVideo) const data = await createActivityData(url, byActor, viewActivityData, t, audience) // Use the server actor to send the view const serverActor = await getServerActor() const actorsException = [ byActor ] - return broadcastToFollowers(data, serverActor, actorsToForwardView, t, actorsException) + return broadcastToFollowers(data, serverActor, actorsInvolvedInVideo, t, actorsException) } -async function sendCreateDislikeToOrigin (byActor: ActorModel, video: VideoModel, t: Transaction) { +async function sendCreateDislike (byActor: ActorModel, video: VideoModel, t: Transaction) { const url = getVideoDislikeActivityPubUrl(byActor, video) const dislikeActivityData = createDislikeActivityData(byActor, video) const actorsInvolvedInVideo = await getActorsInvolvedInVideo(video, t) - const audience = getOriginVideoAudience(video, actorsInvolvedInVideo) - const data = await createActivityData(url, byActor, dislikeActivityData, t, audience) - return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl) -} + // Send to origin + if (video.isOwned() === false) { + const audience = getOriginVideoAudience(video, actorsInvolvedInVideo) + const data = await createActivityData(url, byActor, dislikeActivityData, t, audience) -async function sendCreateDislikeToVideoFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) { - const url = getVideoDislikeActivityPubUrl(byActor, video) - const dislikeActivityData = createDislikeActivityData(byActor, video) + return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl) + } - const actorsToForwardView = await getActorsInvolvedInVideo(video, t) - const audience = getObjectFollowersAudience(actorsToForwardView) + // Send to followers + const audience = getObjectFollowersAudience(actorsInvolvedInVideo) const data = await createActivityData(url, byActor, dislikeActivityData, t, audience) const actorsException = [ byActor ] - return broadcastToFollowers(data, byActor, actorsToForwardView, t, actorsException) + return broadcastToFollowers(data, byActor, actorsInvolvedInVideo, t, actorsException) } -async function createActivityData ( - url: string, - byActor: ActorModel, - object: any, - t: Transaction, - audience?: ActivityAudience -): Promise { +async function createActivityData (url: string, + byActor: ActorModel, + object: any, + t: Transaction, + audience?: ActivityAudience): Promise { if (!audience) { audience = await getAudience(byActor, t) } @@ -173,11 +160,8 @@ export { sendCreateVideo, sendVideoAbuse, createActivityData, - sendCreateViewToOrigin, - sendCreateViewToVideoFollowers, - sendCreateDislikeToOrigin, - sendCreateDislikeToVideoFollowers, + sendCreateView, + sendCreateDislike, createDislikeActivityData, - sendCreateVideoCommentToOrigin, - sendCreateVideoCommentToVideoFollowers + sendCreateVideoComment } diff --git a/server/lib/activitypub/send/send-like.ts b/server/lib/activitypub/send/send-like.ts index b01249e69..fb2b4aaf8 100644 --- a/server/lib/activitypub/send/send-like.ts +++ b/server/lib/activitypub/send/send-like.ts @@ -13,20 +13,20 @@ import { unicastTo } from './misc' -async function sendLikeToOrigin (byActor: ActorModel, video: VideoModel, t: Transaction) { +async function sendLike (byActor: ActorModel, video: VideoModel, t: Transaction) { const url = getVideoLikeActivityPubUrl(byActor, video) const accountsInvolvedInVideo = await getActorsInvolvedInVideo(video, t) - const audience = getOriginVideoAudience(video, accountsInvolvedInVideo) - const data = await likeActivityData(url, byActor, video, t, audience) - return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl) -} + // Send to origin + if (video.isOwned() === false) { + const audience = getOriginVideoAudience(video, accountsInvolvedInVideo) + const data = await likeActivityData(url, byActor, video, t, audience) -async function sendLikeToVideoFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) { - const url = getVideoLikeActivityPubUrl(byActor, video) + return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl) + } - const accountsInvolvedInVideo = await getActorsInvolvedInVideo(video, t) + // Send to followers const audience = getObjectFollowersAudience(accountsInvolvedInVideo) const data = await likeActivityData(url, byActor, video, t, audience) @@ -56,7 +56,6 @@ async function likeActivityData ( // --------------------------------------------------------------------------- export { - sendLikeToOrigin, - sendLikeToVideoFollowers, + sendLike, likeActivityData } diff --git a/server/lib/activitypub/send/send-undo.ts b/server/lib/activitypub/send/send-undo.ts index 41a500384..bd49d452e 100644 --- a/server/lib/activitypub/send/send-undo.ts +++ b/server/lib/activitypub/send/send-undo.ts @@ -30,68 +30,55 @@ async function sendUndoFollow (actorFollow: ActorFollowModel, t: Transaction) { return unicastTo(data, me, following.inboxUrl) } -async function sendUndoLikeToOrigin (byActor: ActorModel, video: VideoModel, t: Transaction) { +async function sendUndoLike (byActor: ActorModel, video: VideoModel, t: Transaction) { const likeUrl = getVideoLikeActivityPubUrl(byActor, video) const undoUrl = getUndoActivityPubUrl(likeUrl) const actorsInvolvedInVideo = await getActorsInvolvedInVideo(video, t) - const audience = getOriginVideoAudience(video, actorsInvolvedInVideo) const object = await likeActivityData(likeUrl, byActor, video, t) - const data = await undoActivityData(undoUrl, byActor, object, t, audience) - return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl) -} + // Send to origin + if (video.isOwned() === false) { + const audience = getOriginVideoAudience(video, actorsInvolvedInVideo) + const data = await undoActivityData(undoUrl, byActor, object, t, audience) -async function sendUndoLikeToVideoFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) { - const likeUrl = getVideoLikeActivityPubUrl(byActor, video) - const undoUrl = getUndoActivityPubUrl(likeUrl) + return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl) + } - const toActorsFollowers = await getActorsInvolvedInVideo(video, t) - const audience = getObjectFollowersAudience(toActorsFollowers) - const object = await likeActivityData(likeUrl, byActor, video, t) + const audience = getObjectFollowersAudience(actorsInvolvedInVideo) const data = await undoActivityData(undoUrl, byActor, object, t, audience) const followersException = [ byActor ] - return broadcastToFollowers(data, byActor, toActorsFollowers, t, followersException) + return broadcastToFollowers(data, byActor, actorsInvolvedInVideo, t, followersException) } -async function sendUndoDislikeToOrigin (byActor: ActorModel, video: VideoModel, t: Transaction) { +async function sendUndoDislike (byActor: ActorModel, video: VideoModel, t: Transaction) { const dislikeUrl = getVideoDislikeActivityPubUrl(byActor, video) const undoUrl = getUndoActivityPubUrl(dislikeUrl) const actorsInvolvedInVideo = await getActorsInvolvedInVideo(video, t) - const audience = getOriginVideoAudience(video, actorsInvolvedInVideo) const dislikeActivity = createDislikeActivityData(byActor, video) const object = await createActivityData(undoUrl, byActor, dislikeActivity, t) - const data = await undoActivityData(undoUrl, byActor, object, t, audience) - - return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl) -} - -async function sendUndoDislikeToVideoFollowers (byActor: ActorModel, video: VideoModel, t: Transaction) { - const dislikeUrl = getVideoDislikeActivityPubUrl(byActor, video) - const undoUrl = getUndoActivityPubUrl(dislikeUrl) + if (video.isOwned() === false) { + const audience = getOriginVideoAudience(video, actorsInvolvedInVideo) + const data = await undoActivityData(undoUrl, byActor, object, t, audience) - const dislikeActivity = createDislikeActivityData(byActor, video) - const object = await createActivityData(undoUrl, byActor, dislikeActivity, t) + return unicastTo(data, byActor, video.VideoChannel.Account.Actor.sharedInboxUrl) + } const data = await undoActivityData(undoUrl, byActor, object, t) - const toActorsFollowers = await getActorsInvolvedInVideo(video, t) - const followersException = [ byActor ] - return broadcastToFollowers(data, byActor, toActorsFollowers, t, followersException) + return broadcastToFollowers(data, byActor, actorsInvolvedInVideo, t, followersException) } // --------------------------------------------------------------------------- export { sendUndoFollow, - sendUndoLikeToOrigin, - sendUndoLikeToVideoFollowers, - sendUndoDislikeToOrigin, - sendUndoDislikeToVideoFollowers + sendUndoLike, + sendUndoDislike } // --------------------------------------------------------------------------- diff --git a/server/lib/activitypub/share.ts b/server/lib/activitypub/share.ts index 038f19b7d..f256f8d21 100644 --- a/server/lib/activitypub/share.ts +++ b/server/lib/activitypub/share.ts @@ -3,7 +3,7 @@ import { VideoPrivacy } from '../../../shared/models/videos' import { getServerActor } from '../../helpers/utils' import { VideoModel } from '../../models/video/video' import { VideoShareModel } from '../../models/video/video-share' -import { sendVideoAnnounceToFollowers } from './send' +import { sendVideoAnnounce } from './send' import { getAnnounceActivityPubUrl } from './url' async function shareVideoByServerAndChannel (video: VideoModel, t: Transaction) { @@ -23,7 +23,7 @@ async function shareVideoByServerAndChannel (video: VideoModel, t: Transaction) }, transaction: t }).then(([ serverShare, created ]) => { - if (created) return sendVideoAnnounceToFollowers(serverActor, serverShare, video, t) + if (created) return sendVideoAnnounce(serverActor, serverShare, video, t) return undefined }) @@ -40,7 +40,7 @@ async function shareVideoByServerAndChannel (video: VideoModel, t: Transaction) }, transaction: t }).then(([ videoChannelShare, created ]) => { - if (created) return sendVideoAnnounceToFollowers(serverActor, videoChannelShare, video, t) + if (created) return sendVideoAnnounce(serverActor, videoChannelShare, video, t) return undefined }) diff --git a/server/lib/activitypub/video-rates.ts b/server/lib/activitypub/video-rates.ts index 1b2958cca..19011b4ab 100644 --- a/server/lib/activitypub/video-rates.ts +++ b/server/lib/activitypub/video-rates.ts @@ -1,52 +1,28 @@ import { Transaction } from 'sequelize' import { AccountModel } from '../../models/account/account' import { VideoModel } from '../../models/video/video' -import { - sendCreateDislikeToOrigin, sendCreateDislikeToVideoFollowers, sendLikeToOrigin, sendLikeToVideoFollowers, sendUndoDislikeToOrigin, - sendUndoDislikeToVideoFollowers, sendUndoLikeToOrigin, sendUndoLikeToVideoFollowers -} from './send' +import { sendCreateDislike, sendLike, sendUndoDislike, sendUndoLike } from './send' -async function sendVideoRateChangeToFollowers (account: AccountModel, - video: VideoModel, - likes: number, - dislikes: number, - t: Transaction) { +async function sendVideoRateChange (account: AccountModel, + video: VideoModel, + likes: number, + dislikes: number, + t: Transaction) { const actor = account.Actor // Keep the order: first we undo and then we create // Undo Like - if (likes < 0) await sendUndoLikeToVideoFollowers(actor, video, t) + if (likes < 0) await sendUndoLike(actor, video, t) // Undo Dislike - if (dislikes < 0) await sendUndoDislikeToVideoFollowers(actor, video, t) + if (dislikes < 0) await sendUndoDislike(actor, video, t) // Like - if (likes > 0) await sendLikeToVideoFollowers(actor, video, t) + if (likes > 0) await sendLike(actor, video, t) // Dislike - if (dislikes > 0) await sendCreateDislikeToVideoFollowers(actor, video, t) -} - -async function sendVideoRateChangeToOrigin (account: AccountModel, - video: VideoModel, - likes: number, - dislikes: number, - t: Transaction) { - const actor = account.Actor - - // Keep the order: first we undo and then we create - - // Undo Like - if (likes < 0) await sendUndoLikeToOrigin(actor, video, t) - // Undo Dislike - if (dislikes < 0) await sendUndoDislikeToOrigin(actor, video, t) - - // Like - if (likes > 0) await sendLikeToOrigin(actor, video, t) - // Dislike - if (dislikes > 0) await sendCreateDislikeToOrigin(actor, video, t) + if (dislikes > 0) await sendCreateDislike(actor, video, t) } export { - sendVideoRateChangeToFollowers, - sendVideoRateChangeToOrigin + sendVideoRateChange } diff --git a/server/lib/video-comment.ts b/server/lib/video-comment.ts index 0d744c526..f88e5cfdf 100644 --- a/server/lib/video-comment.ts +++ b/server/lib/video-comment.ts @@ -5,7 +5,7 @@ import { AccountModel } from '../models/account/account' import { VideoModel } from '../models/video/video' import { VideoCommentModel } from '../models/video/video-comment' import { getVideoCommentActivityPubUrl } from './activitypub' -import { sendCreateVideoCommentToOrigin, sendCreateVideoCommentToVideoFollowers } from './activitypub/send' +import { sendCreateVideoComment } from './activitypub/send' async function createVideoComment (obj: { text: string, @@ -37,11 +37,7 @@ async function createVideoComment (obj: { savedComment.Video = obj.video savedComment.Account = obj.account - if (savedComment.Video.isOwned()) { - await sendCreateVideoCommentToVideoFollowers(savedComment, t) - } else { - await sendCreateVideoCommentToOrigin(savedComment, t) - } + await sendCreateVideoComment(savedComment, t) return savedComment } -- cgit v1.2.3