aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib/activitypub/process/process-create.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-02 10:53:36 +0200
committerChocobozzz <me@florianbigard.com>2019-08-02 10:53:36 +0200
commit1198edf4bb06ce5f1668b97cf9ca8fb483fe3f41 (patch)
tree0378e6f2ec9912a80838f373ec2d09c3b805b7b6 /server/lib/activitypub/process/process-create.ts
parent44b88f180bc9ec692885e7db08757a43b3e2df79 (diff)
downloadPeerTube-1198edf4bb06ce5f1668b97cf9ca8fb483fe3f41.tar.gz
PeerTube-1198edf4bb06ce5f1668b97cf9ca8fb483fe3f41.tar.zst
PeerTube-1198edf4bb06ce5f1668b97cf9ca8fb483fe3f41.zip
Fix user notifications on new follow
Diffstat (limited to 'server/lib/activitypub/process/process-create.ts')
-rw-r--r--server/lib/activitypub/process/process-create.ts19
1 files changed, 12 insertions, 7 deletions
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts
index 1e893cdeb..a979771b6 100644
--- a/server/lib/activitypub/process/process-create.ts
+++ b/server/lib/activitypub/process/process-create.ts
@@ -12,17 +12,22 @@ import { Notifier } from '../../notifier'
12import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object' 12import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object'
13import { createOrUpdateVideoPlaylist } from '../playlist' 13import { createOrUpdateVideoPlaylist } from '../playlist'
14import { VideoModel } from '../../../models/video/video' 14import { VideoModel } from '../../../models/video/video'
15import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
15 16
16async function processCreateActivity (activity: ActivityCreate, byActor: ActorModel) { 17async function processCreateActivity (options: APProcessorOptions<ActivityCreate>) {
18 const { activity, byActor } = options
19
20 // Only notify if it is not from a fetcher job
21 const notify = options.fromFetch !== true
17 const activityObject = activity.object 22 const activityObject = activity.object
18 const activityType = activityObject.type 23 const activityType = activityObject.type
19 24
20 if (activityType === 'Video') { 25 if (activityType === 'Video') {
21 return processCreateVideo(activity) 26 return processCreateVideo(activity, notify)
22 } 27 }
23 28
24 if (activityType === 'Note') { 29 if (activityType === 'Note') {
25 return retryTransactionWrapper(processCreateVideoComment, activity, byActor) 30 return retryTransactionWrapper(processCreateVideoComment, activity, byActor, notify)
26 } 31 }
27 32
28 if (activityType === 'CacheFile') { 33 if (activityType === 'CacheFile') {
@@ -45,12 +50,12 @@ export {
45 50
46// --------------------------------------------------------------------------- 51// ---------------------------------------------------------------------------
47 52
48async function processCreateVideo (activity: ActivityCreate) { 53async function processCreateVideo (activity: ActivityCreate, notify: boolean) {
49 const videoToCreateData = activity.object as VideoTorrentObject 54 const videoToCreateData = activity.object as VideoTorrentObject
50 55
51 const { video, created } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoToCreateData }) 56 const { video, created } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoToCreateData })
52 57
53 if (created) Notifier.Instance.notifyOnNewVideoIfNeeded(video) 58 if (created && notify) Notifier.Instance.notifyOnNewVideoIfNeeded(video)
54 59
55 return video 60 return video
56} 61}
@@ -71,7 +76,7 @@ async function processCreateCacheFile (activity: ActivityCreate, byActor: ActorM
71 } 76 }
72} 77}
73 78
74async function processCreateVideoComment (activity: ActivityCreate, byActor: ActorModel) { 79async function processCreateVideoComment (activity: ActivityCreate, byActor: ActorModel, notify: boolean) {
75 const commentObject = activity.object as VideoCommentObject 80 const commentObject = activity.object as VideoCommentObject
76 const byAccount = byActor.Account 81 const byAccount = byActor.Account
77 82
@@ -99,7 +104,7 @@ async function processCreateVideoComment (activity: ActivityCreate, byActor: Act
99 await forwardVideoRelatedActivity(activity, undefined, exceptions, video) 104 await forwardVideoRelatedActivity(activity, undefined, exceptions, video)
100 } 105 }
101 106
102 if (created === true) Notifier.Instance.notifyOnNewComment(comment) 107 if (created && notify) Notifier.Instance.notifyOnNewComment(comment)
103} 108}
104 109
105async function processCreatePlaylist (activity: ActivityCreate, byActor: ActorModel) { 110async function processCreatePlaylist (activity: ActivityCreate, byActor: ActorModel) {