From 265ba139ebf56bbdc1c65f6ea4f367774c691fc0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 3 Jan 2018 16:38:50 +0100 Subject: Send account activitypub update events --- server/lib/activitypub/send/send-update.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'server/lib/activitypub/send/send-update.ts') diff --git a/server/lib/activitypub/send/send-update.ts b/server/lib/activitypub/send/send-update.ts index b623fec6c..e8f11edd0 100644 --- a/server/lib/activitypub/send/send-update.ts +++ b/server/lib/activitypub/send/send-update.ts @@ -1,6 +1,7 @@ import { Transaction } from 'sequelize' import { ActivityAudience, ActivityUpdate } from '../../../../shared/models/activitypub' import { VideoPrivacy } from '../../../../shared/models/videos' +import { UserModel } from '../../../models/account/user' import { ActorModel } from '../../../models/activitypub/actor' import { VideoModel } from '../../../models/video/video' import { VideoShareModel } from '../../../models/video/video-share' @@ -22,9 +23,24 @@ async function sendUpdateVideo (video: VideoModel, t: Transaction) { return broadcastToFollowers(data, byActor, actorsInvolved, t) } +async function sendUpdateUser (user: UserModel, t: Transaction) { + const byActor = user.Account.Actor + + const url = getUpdateActivityPubUrl(byActor.url, byActor.updatedAt.toISOString()) + const accountObject = user.Account.toActivityPubObject() + const audience = await getAudience(byActor, t) + const data = await updateActivityData(url, byActor, accountObject, t, audience) + + const actorsInvolved = await VideoShareModel.loadActorsByVideoOwner(byActor.id, t) + actorsInvolved.push(byActor) + + return broadcastToFollowers(data, byActor, actorsInvolved, t) +} + // --------------------------------------------------------------------------- export { + sendUpdateUser, sendUpdateVideo } -- cgit v1.2.3