diff options
author | Chocobozzz <me@florianbigard.com> | 2018-12-26 10:36:24 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-01-09 11:15:15 +0100 |
commit | cef534ed53e4518fe0acf581bfe880788d42fc36 (patch) | |
tree | 115b51ea5136849a2336d44915c7780649f25dc2 /server/lib/activitypub/process/process-create.ts | |
parent | 1de1d05f4c61fe059fa5e24e79c92582f0e7e4b3 (diff) | |
download | PeerTube-cef534ed53e4518fe0acf581bfe880788d42fc36.tar.gz PeerTube-cef534ed53e4518fe0acf581bfe880788d42fc36.tar.zst PeerTube-cef534ed53e4518fe0acf581bfe880788d42fc36.zip |
Add user notification base code
Diffstat (limited to 'server/lib/activitypub/process/process-create.ts')
-rw-r--r-- | server/lib/activitypub/process/process-create.ts | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts index df05ee452..2e04ee843 100644 --- a/server/lib/activitypub/process/process-create.ts +++ b/server/lib/activitypub/process/process-create.ts | |||
@@ -13,6 +13,7 @@ import { forwardVideoRelatedActivity } from '../send/utils' | |||
13 | import { Redis } from '../../redis' | 13 | import { Redis } from '../../redis' |
14 | import { createOrUpdateCacheFile } from '../cache-file' | 14 | import { createOrUpdateCacheFile } from '../cache-file' |
15 | import { getVideoDislikeActivityPubUrl } from '../url' | 15 | import { getVideoDislikeActivityPubUrl } from '../url' |
16 | import { Notifier } from '../../notifier' | ||
16 | 17 | ||
17 | async function processCreateActivity (activity: ActivityCreate, byActor: ActorModel) { | 18 | async function processCreateActivity (activity: ActivityCreate, byActor: ActorModel) { |
18 | const activityObject = activity.object | 19 | const activityObject = activity.object |
@@ -47,7 +48,9 @@ export { | |||
47 | async function processCreateVideo (activity: ActivityCreate) { | 48 | async function processCreateVideo (activity: ActivityCreate) { |
48 | const videoToCreateData = activity.object as VideoTorrentObject | 49 | const videoToCreateData = activity.object as VideoTorrentObject |
49 | 50 | ||
50 | const { video } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoToCreateData }) | 51 | const { video, created } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoToCreateData }) |
52 | |||
53 | if (created) Notifier.Instance.notifyOnNewVideo(video) | ||
51 | 54 | ||
52 | return video | 55 | return video |
53 | } | 56 | } |
@@ -133,7 +136,10 @@ async function processCreateVideoAbuse (byActor: ActorModel, videoAbuseToCreateD | |||
133 | state: VideoAbuseState.PENDING | 136 | state: VideoAbuseState.PENDING |
134 | } | 137 | } |
135 | 138 | ||
136 | await VideoAbuseModel.create(videoAbuseData, { transaction: t }) | 139 | const videoAbuseInstance = await VideoAbuseModel.create(videoAbuseData, { transaction: t }) |
140 | videoAbuseInstance.Video = video | ||
141 | |||
142 | Notifier.Instance.notifyOnNewVideoAbuse(videoAbuseInstance) | ||
137 | 143 | ||
138 | logger.info('Remote abuse for video uuid %s created', videoAbuseToCreateData.object) | 144 | logger.info('Remote abuse for video uuid %s created', videoAbuseToCreateData.object) |
139 | }) | 145 | }) |
@@ -147,7 +153,7 @@ async function processCreateVideoComment (byActor: ActorModel, activity: Activit | |||
147 | 153 | ||
148 | const { video } = await resolveThread(commentObject.inReplyTo) | 154 | const { video } = await resolveThread(commentObject.inReplyTo) |
149 | 155 | ||
150 | const { created } = await addVideoComment(video, commentObject.id) | 156 | const { comment, created } = await addVideoComment(video, commentObject.id) |
151 | 157 | ||
152 | if (video.isOwned() && created === true) { | 158 | if (video.isOwned() && created === true) { |
153 | // Don't resend the activity to the sender | 159 | // Don't resend the activity to the sender |
@@ -155,4 +161,6 @@ async function processCreateVideoComment (byActor: ActorModel, activity: Activit | |||
155 | 161 | ||
156 | await forwardVideoRelatedActivity(activity, undefined, exceptions, video) | 162 | await forwardVideoRelatedActivity(activity, undefined, exceptions, video) |
157 | } | 163 | } |
164 | |||
165 | if (created === true) Notifier.Instance.notifyOnNewComment(comment) | ||
158 | } | 166 | } |