From d95d15598847c7f020aa056e7e6e0c02d2bbf732 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 1 Jul 2020 16:05:30 +0200 Subject: Use 3 tables to represent abuses --- server/lib/activitypub/send/send-flag.ts | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'server/lib/activitypub/send') diff --git a/server/lib/activitypub/send/send-flag.ts b/server/lib/activitypub/send/send-flag.ts index 3a1fe0812..821637ec8 100644 --- a/server/lib/activitypub/send/send-flag.ts +++ b/server/lib/activitypub/send/send-flag.ts @@ -1,32 +1,31 @@ -import { getVideoAbuseActivityPubUrl } from '../url' -import { unicastTo } from './utils' -import { logger } from '../../../helpers/logger' +import { Transaction } from 'sequelize' import { ActivityAudience, ActivityFlag } from '../../../../shared/models/activitypub' +import { logger } from '../../../helpers/logger' +import { MAbuseAP, MAccountLight, MActor } from '../../../types/models' import { audiencify, getAudience } from '../audience' -import { Transaction } from 'sequelize' -import { MActor, MVideoFullLight } from '../../../types/models' -import { MVideoAbuseVideo } from '../../../types/models/video' +import { getAbuseActivityPubUrl } from '../url' +import { unicastTo } from './utils' -function sendVideoAbuse (byActor: MActor, videoAbuse: MVideoAbuseVideo, video: MVideoFullLight, t: Transaction) { - if (!video.VideoChannel.Account.Actor.serverId) return // Local user +function sendAbuse (byActor: MActor, abuse: MAbuseAP, flaggedAccount: MAccountLight, t: Transaction) { + if (!flaggedAccount.Actor.serverId) return // Local user - const url = getVideoAbuseActivityPubUrl(videoAbuse) + const url = getAbuseActivityPubUrl(abuse) - logger.info('Creating job to send video abuse %s.', url) + logger.info('Creating job to send abuse %s.', url) // Custom audience, we only send the abuse to the origin instance - const audience = { to: [ video.VideoChannel.Account.Actor.url ], cc: [] } - const flagActivity = buildFlagActivity(url, byActor, videoAbuse, audience) + const audience = { to: [ flaggedAccount.Actor.url ], cc: [] } + const flagActivity = buildFlagActivity(url, byActor, abuse, audience) - t.afterCommit(() => unicastTo(flagActivity, byActor, video.VideoChannel.Account.Actor.getSharedInbox())) + t.afterCommit(() => unicastTo(flagActivity, byActor, flaggedAccount.Actor.getSharedInbox())) } -function buildFlagActivity (url: string, byActor: MActor, videoAbuse: MVideoAbuseVideo, audience: ActivityAudience): ActivityFlag { +function buildFlagActivity (url: string, byActor: MActor, abuse: MAbuseAP, audience: ActivityAudience): ActivityFlag { if (!audience) audience = getAudience(byActor) const activity = Object.assign( { id: url, actor: byActor.url }, - videoAbuse.toActivityPubObject() + abuse.toActivityPubObject() ) return audiencify(activity, audience) @@ -35,5 +34,5 @@ function buildFlagActivity (url: string, byActor: MActor, videoAbuse: MVideoAbus // --------------------------------------------------------------------------- export { - sendVideoAbuse + sendAbuse } -- cgit v1.2.3