diff options
author | Chocobozzz <me@florianbigard.com> | 2019-08-06 17:19:53 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-08-06 17:26:51 +0200 |
commit | 6b9c966f6428c9e47bead3410a0401e8ebd744bf (patch) | |
tree | 282218ec56725b0e2e878b0471cd08a54fd91998 /server/lib/activitypub/process/process-create.ts | |
parent | 466e3f20a537f1eff4b4fd03297df11ba371d049 (diff) | |
download | PeerTube-6b9c966f6428c9e47bead3410a0401e8ebd744bf.tar.gz PeerTube-6b9c966f6428c9e47bead3410a0401e8ebd744bf.tar.zst PeerTube-6b9c966f6428c9e47bead3410a0401e8ebd744bf.zip |
Automatically remove bad followings
Diffstat (limited to 'server/lib/activitypub/process/process-create.ts')
-rw-r--r-- | server/lib/activitypub/process/process-create.ts | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts index a979771b6..b81021163 100644 --- a/server/lib/activitypub/process/process-create.ts +++ b/server/lib/activitypub/process/process-create.ts | |||
@@ -4,7 +4,7 @@ import { retryTransactionWrapper } from '../../../helpers/database-utils' | |||
4 | import { logger } from '../../../helpers/logger' | 4 | import { logger } from '../../../helpers/logger' |
5 | import { sequelizeTypescript } from '../../../initializers' | 5 | import { sequelizeTypescript } from '../../../initializers' |
6 | import { ActorModel } from '../../../models/activitypub/actor' | 6 | import { ActorModel } from '../../../models/activitypub/actor' |
7 | import { addVideoComment, resolveThread } from '../video-comments' | 7 | import { resolveThread } from '../video-comments' |
8 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' | 8 | import { getOrCreateVideoAndAccountAndChannel } from '../videos' |
9 | import { forwardVideoRelatedActivity } from '../send/utils' | 9 | import { forwardVideoRelatedActivity } from '../send/utils' |
10 | import { createOrUpdateCacheFile } from '../cache-file' | 10 | import { createOrUpdateCacheFile } from '../cache-file' |
@@ -13,6 +13,7 @@ import { PlaylistObject } from '../../../../shared/models/activitypub/objects/pl | |||
13 | import { createOrUpdateVideoPlaylist } from '../playlist' | 13 | import { createOrUpdateVideoPlaylist } from '../playlist' |
14 | import { VideoModel } from '../../../models/video/video' | 14 | import { VideoModel } from '../../../models/video/video' |
15 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' | 15 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' |
16 | import { VideoCommentModel } from '../../../models/video/video-comment' | ||
16 | 17 | ||
17 | async function processCreateActivity (options: APProcessorOptions<ActivityCreate>) { | 18 | async function processCreateActivity (options: APProcessorOptions<ActivityCreate>) { |
18 | const { activity, byActor } = options | 19 | const { activity, byActor } = options |
@@ -83,9 +84,13 @@ async function processCreateVideoComment (activity: ActivityCreate, byActor: Act | |||
83 | if (!byAccount) throw new Error('Cannot create video comment with the non account actor ' + byActor.url) | 84 | if (!byAccount) throw new Error('Cannot create video comment with the non account actor ' + byActor.url) |
84 | 85 | ||
85 | let video: VideoModel | 86 | let video: VideoModel |
87 | let created: boolean | ||
88 | let comment: VideoCommentModel | ||
86 | try { | 89 | try { |
87 | const resolveThreadResult = await resolveThread(commentObject.inReplyTo) | 90 | const resolveThreadResult = await resolveThread({ url: commentObject.id, isVideo: false }) |
88 | video = resolveThreadResult.video | 91 | video = resolveThreadResult.video |
92 | created = resolveThreadResult.commentCreated | ||
93 | comment = resolveThreadResult.comment | ||
89 | } catch (err) { | 94 | } catch (err) { |
90 | logger.debug( | 95 | logger.debug( |
91 | 'Cannot process video comment because we could not resolve thread %s. Maybe it was not a video thread, so skip it.', | 96 | 'Cannot process video comment because we could not resolve thread %s. Maybe it was not a video thread, so skip it.', |
@@ -95,8 +100,6 @@ async function processCreateVideoComment (activity: ActivityCreate, byActor: Act | |||
95 | return | 100 | return |
96 | } | 101 | } |
97 | 102 | ||
98 | const { comment, created } = await addVideoComment(video, commentObject.id) | ||
99 | |||
100 | if (video.isOwned() && created === true) { | 103 | if (video.isOwned() && created === true) { |
101 | // Don't resend the activity to the sender | 104 | // Don't resend the activity to the sender |
102 | const exceptions = [ byActor ] | 105 | const exceptions = [ byActor ] |