diff options
author | Chocobozzz <me@florianbigard.com> | 2019-08-20 13:52:49 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-08-20 14:53:42 +0200 |
commit | 0283eaac2a8e73006c66df3cf5bb9012e37450e5 (patch) | |
tree | 1fb73aeef57f984a77f47828ade23c6365ce8eb0 /server/lib/activitypub | |
parent | 96ca24f00e5ae5471dee9ee596489fe50af2b46f (diff) | |
download | PeerTube-0283eaac2a8e73006c66df3cf5bb9012e37450e5.tar.gz PeerTube-0283eaac2a8e73006c66df3cf5bb9012e37450e5.tar.zst PeerTube-0283eaac2a8e73006c66df3cf5bb9012e37450e5.zip |
Cleanup model types
Diffstat (limited to 'server/lib/activitypub')
-rw-r--r-- | server/lib/activitypub/actor.ts | 13 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-announce.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-create.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/video-comments.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/videos.ts | 12 |
5 files changed, 19 insertions, 18 deletions
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts index 7862b0f00..5201bdeef 100644 --- a/server/lib/activitypub/actor.ts +++ b/server/lib/activitypub/actor.ts | |||
@@ -24,15 +24,17 @@ import { ActorFetchByUrlType, fetchActorByUrl } from '../../helpers/actor' | |||
24 | import { sequelizeTypescript } from '../../initializers/database' | 24 | import { sequelizeTypescript } from '../../initializers/database' |
25 | import { | 25 | import { |
26 | MAccount, | 26 | MAccount, |
27 | MAccountDefault, | ||
27 | MActor, | 28 | MActor, |
28 | MActorAccountChannelId, | 29 | MActorAccountChannelId, |
30 | MActorAccountChannelIdActor, | ||
29 | MActorAccountId, | 31 | MActorAccountId, |
30 | MActorDefault, | 32 | MActorDefault, |
31 | MActorFull, | 33 | MActorFull, |
34 | MActorFullActor, | ||
32 | MActorId, | 35 | MActorId, |
33 | MActorAccountChannelIdActor, | ||
34 | MChannel, | 36 | MChannel, |
35 | MActorFullActor, MAccountActorDefault, MChannelActorDefault, MChannelActorAccountDefault | 37 | MChannelAccountDefault |
36 | } from '../../typings/models' | 38 | } from '../../typings/models' |
37 | 39 | ||
38 | // Set account keys, this could be long so process after the account creation and do not block the client | 40 | // Set account keys, this could be long so process after the account creation and do not block the client |
@@ -374,12 +376,11 @@ function saveActorAndServerAndModelIfNotExist ( | |||
374 | }) | 376 | }) |
375 | 377 | ||
376 | if (actorCreated.type === 'Person' || actorCreated.type === 'Application') { | 378 | if (actorCreated.type === 'Person' || actorCreated.type === 'Application') { |
377 | actorCreated.Account = await saveAccount(actorCreated, result, t) as MAccountActorDefault | 379 | actorCreated.Account = await saveAccount(actorCreated, result, t) as MAccountDefault |
378 | actorCreated.Account.Actor = actorCreated | 380 | actorCreated.Account.Actor = actorCreated |
379 | } else if (actorCreated.type === 'Group') { // Video channel | 381 | } else if (actorCreated.type === 'Group') { // Video channel |
380 | actorCreated.VideoChannel = await saveVideoChannel(actorCreated, result, ownerActor, t) as MChannelActorAccountDefault | 382 | const channel = await saveVideoChannel(actorCreated, result, ownerActor, t) |
381 | actorCreated.VideoChannel.Actor = actorCreated | 383 | actorCreated.VideoChannel = Object.assign(channel, { Actor: actorCreated, Account: ownerActor.Account }) |
382 | actorCreated.VideoChannel.Account = ownerActor.Account | ||
383 | } | 384 | } |
384 | 385 | ||
385 | actorCreated.Server = server | 386 | actorCreated.Server = server |
diff --git a/server/lib/activitypub/process/process-announce.ts b/server/lib/activitypub/process/process-announce.ts index 91a9ad72c..7e22125d5 100644 --- a/server/lib/activitypub/process/process-announce.ts +++ b/server/lib/activitypub/process/process-announce.ts | |||
@@ -7,7 +7,7 @@ import { getOrCreateVideoAndAccountAndChannel } from '../videos' | |||
7 | import { Notifier } from '../../notifier' | 7 | import { Notifier } from '../../notifier' |
8 | import { logger } from '../../../helpers/logger' | 8 | import { logger } from '../../../helpers/logger' |
9 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' | 9 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' |
10 | import { MActorSignature, MVideoAccountAllFiles } from '../../../typings/models' | 10 | import { MActorSignature, MVideoAccountLightBlacklistAllFiles } from '../../../typings/models' |
11 | 11 | ||
12 | async function processAnnounceActivity (options: APProcessorOptions<ActivityAnnounce>) { | 12 | async function processAnnounceActivity (options: APProcessorOptions<ActivityAnnounce>) { |
13 | const { activity, byActor: actorAnnouncer } = options | 13 | const { activity, byActor: actorAnnouncer } = options |
@@ -28,7 +28,7 @@ export { | |||
28 | async function processVideoShare (actorAnnouncer: MActorSignature, activity: ActivityAnnounce, notify: boolean) { | 28 | async function processVideoShare (actorAnnouncer: MActorSignature, activity: ActivityAnnounce, notify: boolean) { |
29 | const objectUri = typeof activity.object === 'string' ? activity.object : activity.object.id | 29 | const objectUri = typeof activity.object === 'string' ? activity.object : activity.object.id |
30 | 30 | ||
31 | let video: MVideoAccountAllFiles | 31 | let video: MVideoAccountLightBlacklistAllFiles |
32 | let videoCreated: boolean | 32 | let videoCreated: boolean |
33 | 33 | ||
34 | try { | 34 | try { |
diff --git a/server/lib/activitypub/process/process-create.ts b/server/lib/activitypub/process/process-create.ts index c45f09f52..bee853721 100644 --- a/server/lib/activitypub/process/process-create.ts +++ b/server/lib/activitypub/process/process-create.ts | |||
@@ -11,7 +11,7 @@ import { Notifier } from '../../notifier' | |||
11 | import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object' | 11 | import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object' |
12 | import { createOrUpdateVideoPlaylist } from '../playlist' | 12 | import { createOrUpdateVideoPlaylist } from '../playlist' |
13 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' | 13 | import { APProcessorOptions } from '../../../typings/activitypub-processor.model' |
14 | import { MActorSignature, MCommentOwnerVideo, MVideoAccountAllFiles } from '../../../typings/models' | 14 | import { MActorSignature, MCommentOwnerVideo, MVideoAccountLightBlacklistAllFiles } from '../../../typings/models' |
15 | 15 | ||
16 | async function processCreateActivity (options: APProcessorOptions<ActivityCreate>) { | 16 | async function processCreateActivity (options: APProcessorOptions<ActivityCreate>) { |
17 | const { activity, byActor } = options | 17 | const { activity, byActor } = options |
@@ -81,7 +81,7 @@ async function processCreateVideoComment (activity: ActivityCreate, byActor: MAc | |||
81 | 81 | ||
82 | if (!byAccount) throw new Error('Cannot create video comment with the non account actor ' + byActor.url) | 82 | if (!byAccount) throw new Error('Cannot create video comment with the non account actor ' + byActor.url) |
83 | 83 | ||
84 | let video: MVideoAccountAllFiles | 84 | let video: MVideoAccountLightBlacklistAllFiles |
85 | let created: boolean | 85 | let created: boolean |
86 | let comment: MCommentOwnerVideo | 86 | let comment: MCommentOwnerVideo |
87 | try { | 87 | try { |
diff --git a/server/lib/activitypub/video-comments.ts b/server/lib/activitypub/video-comments.ts index 375ac0aad..3e8306fa4 100644 --- a/server/lib/activitypub/video-comments.ts +++ b/server/lib/activitypub/video-comments.ts | |||
@@ -7,7 +7,7 @@ import { getOrCreateActorAndServerAndModel } from './actor' | |||
7 | import { getOrCreateVideoAndAccountAndChannel } from './videos' | 7 | import { getOrCreateVideoAndAccountAndChannel } from './videos' |
8 | import * as Bluebird from 'bluebird' | 8 | import * as Bluebird from 'bluebird' |
9 | import { checkUrlsSameHost } from '../../helpers/activitypub' | 9 | import { checkUrlsSameHost } from '../../helpers/activitypub' |
10 | import { MCommentOwner, MCommentOwnerVideo, MVideoAccountAllFiles } from '../../typings/models/video' | 10 | import { MCommentOwner, MCommentOwnerVideo, MVideoAccountLightBlacklistAllFiles } from '../../typings/models/video' |
11 | 11 | ||
12 | type ResolveThreadParams = { | 12 | type ResolveThreadParams = { |
13 | url: string, | 13 | url: string, |
@@ -15,7 +15,7 @@ type ResolveThreadParams = { | |||
15 | isVideo?: boolean, | 15 | isVideo?: boolean, |
16 | commentCreated?: boolean | 16 | commentCreated?: boolean |
17 | } | 17 | } |
18 | type ResolveThreadResult = Promise<{ video: MVideoAccountAllFiles, comment: MCommentOwnerVideo, commentCreated: boolean }> | 18 | type ResolveThreadResult = Promise<{ video: MVideoAccountLightBlacklistAllFiles, comment: MCommentOwnerVideo, commentCreated: boolean }> |
19 | 19 | ||
20 | async function addVideoComments (commentUrls: string[]) { | 20 | async function addVideoComments (commentUrls: string[]) { |
21 | return Bluebird.map(commentUrls, commentUrl => { | 21 | return Bluebird.map(commentUrls, commentUrl => { |
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index 035994da8..970a953fc 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts | |||
@@ -58,7 +58,7 @@ import { | |||
58 | MChannelDefault, | 58 | MChannelDefault, |
59 | MChannelId, | 59 | MChannelId, |
60 | MVideo, | 60 | MVideo, |
61 | MVideoAccountAllFiles, | 61 | MVideoAccountLightBlacklistAllFiles, |
62 | MVideoAccountLight, | 62 | MVideoAccountLight, |
63 | MVideoAP, | 63 | MVideoAP, |
64 | MVideoAPWithoutCaption, | 64 | MVideoAPWithoutCaption, |
@@ -213,19 +213,19 @@ function getOrCreateVideoAndAccountAndChannel (options: { | |||
213 | syncParam?: SyncParam, | 213 | syncParam?: SyncParam, |
214 | fetchType?: 'all', | 214 | fetchType?: 'all', |
215 | allowRefresh?: boolean | 215 | allowRefresh?: boolean |
216 | }): Promise<{ video: MVideoAccountAllFiles, created: boolean, autoBlacklisted?: boolean }> | 216 | }): Promise<{ video: MVideoAccountLightBlacklistAllFiles, created: boolean, autoBlacklisted?: boolean }> |
217 | function getOrCreateVideoAndAccountAndChannel (options: { | 217 | function getOrCreateVideoAndAccountAndChannel (options: { |
218 | videoObject: { id: string } | string, | 218 | videoObject: { id: string } | string, |
219 | syncParam?: SyncParam, | 219 | syncParam?: SyncParam, |
220 | fetchType?: VideoFetchByUrlType, | 220 | fetchType?: VideoFetchByUrlType, |
221 | allowRefresh?: boolean | 221 | allowRefresh?: boolean |
222 | }): Promise<{ video: MVideoAccountAllFiles | MVideoThumbnail, created: boolean, autoBlacklisted?: boolean }> | 222 | }): Promise<{ video: MVideoAccountLightBlacklistAllFiles | MVideoThumbnail, created: boolean, autoBlacklisted?: boolean }> |
223 | async function getOrCreateVideoAndAccountAndChannel (options: { | 223 | async function getOrCreateVideoAndAccountAndChannel (options: { |
224 | videoObject: { id: string } | string, | 224 | videoObject: { id: string } | string, |
225 | syncParam?: SyncParam, | 225 | syncParam?: SyncParam, |
226 | fetchType?: VideoFetchByUrlType, | 226 | fetchType?: VideoFetchByUrlType, |
227 | allowRefresh?: boolean // true by default | 227 | allowRefresh?: boolean // true by default |
228 | }): Promise<{ video: MVideoAccountAllFiles | MVideoThumbnail, created: boolean, autoBlacklisted?: boolean }> { | 228 | }): Promise<{ video: MVideoAccountLightBlacklistAllFiles | MVideoThumbnail, created: boolean, autoBlacklisted?: boolean }> { |
229 | // Default params | 229 | // Default params |
230 | const syncParam = options.syncParam || { likes: true, dislikes: true, shares: true, comments: true, thumbnail: true, refreshVideo: false } | 230 | const syncParam = options.syncParam || { likes: true, dislikes: true, shares: true, comments: true, thumbnail: true, refreshVideo: false } |
231 | const fetchType = options.fetchType || 'all' | 231 | const fetchType = options.fetchType || 'all' |
@@ -263,7 +263,7 @@ async function getOrCreateVideoAndAccountAndChannel (options: { | |||
263 | } | 263 | } |
264 | 264 | ||
265 | async function updateVideoFromAP (options: { | 265 | async function updateVideoFromAP (options: { |
266 | video: MVideoAccountAllFiles, | 266 | video: MVideoAccountLightBlacklistAllFiles, |
267 | videoObject: VideoTorrentObject, | 267 | videoObject: VideoTorrentObject, |
268 | account: MAccountActor, | 268 | account: MAccountActor, |
269 | channel: MChannelDefault, | 269 | channel: MChannelDefault, |
@@ -420,7 +420,7 @@ async function refreshVideoIfNeeded (options: { | |||
420 | 420 | ||
421 | // We need more attributes if the argument video was fetched with not enough joints | 421 | // We need more attributes if the argument video was fetched with not enough joints |
422 | const video = options.fetchedType === 'all' | 422 | const video = options.fetchedType === 'all' |
423 | ? options.video as MVideoAccountAllFiles | 423 | ? options.video as MVideoAccountLightBlacklistAllFiles |
424 | : await VideoModel.loadByUrlAndPopulateAccount(options.video.url) | 424 | : await VideoModel.loadByUrlAndPopulateAccount(options.video.url) |
425 | 425 | ||
426 | try { | 426 | try { |