diff options
author | Chocobozzz <me@florianbigard.com> | 2019-08-02 10:53:36 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-08-02 10:53:36 +0200 |
commit | 1198edf4bb06ce5f1668b97cf9ca8fb483fe3f41 (patch) | |
tree | 0378e6f2ec9912a80838f373ec2d09c3b805b7b6 /server/lib/activitypub/process/process-announce.ts | |
parent | 44b88f180bc9ec692885e7db08757a43b3e2df79 (diff) | |
download | PeerTube-1198edf4bb06ce5f1668b97cf9ca8fb483fe3f41.tar.gz PeerTube-1198edf4bb06ce5f1668b97cf9ca8fb483fe3f41.tar.zst PeerTube-1198edf4bb06ce5f1668b97cf9ca8fb483fe3f41.zip |
Fix user notifications on new follow
Diffstat (limited to 'server/lib/activitypub/process/process-announce.ts')
-rw-r--r-- | server/lib/activitypub/process/process-announce.ts | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/server/lib/activitypub/process/process-announce.ts b/server/lib/activitypub/process/process-announce.ts index 1fe347506..7a59bb84d 100644 --- a/server/lib/activitypub/process/process-announce.ts +++ b/server/lib/activitypub/process/process-announce.ts | |||
@@ -8,9 +8,14 @@ import { getOrCreateVideoAndAccountAndChannel } from '../videos' | |||
8 | import { Notifier } from '../../notifier' | 8 | import { Notifier } from '../../notifier' |
9 | import { VideoModel } from '../../../models/video/video' | 9 | import { VideoModel } from '../../../models/video/video' |
10 | import { logger } from '../../../helpers/logger' | 10 | import { logger } from '../../../helpers/logger' |
11 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' | ||
11 | 12 | ||
12 | async function processAnnounceActivity (activity: ActivityAnnounce, actorAnnouncer: ActorModel) { | 13 | async function processAnnounceActivity (options: APProcessorOptions<ActivityAnnounce>) { |
13 | return retryTransactionWrapper(processVideoShare, actorAnnouncer, activity) | 14 | const { activity, byActor: actorAnnouncer } = options |
15 | // Only notify if it is not from a fetcher job | ||
16 | const notify = options.fromFetch !== true | ||
17 | |||
18 | return retryTransactionWrapper(processVideoShare, actorAnnouncer, activity, notify) | ||
14 | } | 19 | } |
15 | 20 | ||
16 | // --------------------------------------------------------------------------- | 21 | // --------------------------------------------------------------------------- |
@@ -21,7 +26,7 @@ export { | |||
21 | 26 | ||
22 | // --------------------------------------------------------------------------- | 27 | // --------------------------------------------------------------------------- |
23 | 28 | ||
24 | async function processVideoShare (actorAnnouncer: ActorModel, activity: ActivityAnnounce) { | 29 | async function processVideoShare (actorAnnouncer: ActorModel, activity: ActivityAnnounce, notify: boolean) { |
25 | const objectUri = typeof activity.object === 'string' ? activity.object : activity.object.id | 30 | const objectUri = typeof activity.object === 'string' ? activity.object : activity.object.id |
26 | 31 | ||
27 | let video: VideoModel | 32 | let video: VideoModel |
@@ -63,5 +68,5 @@ async function processVideoShare (actorAnnouncer: ActorModel, activity: Activity | |||
63 | return undefined | 68 | return undefined |
64 | }) | 69 | }) |
65 | 70 | ||
66 | if (videoCreated) Notifier.Instance.notifyOnNewVideoIfNeeded(video) | 71 | if (videoCreated && notify) Notifier.Instance.notifyOnNewVideoIfNeeded(video) |
67 | } | 72 | } |