]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/types/models/user/user-notification.ts
Fix embed url
[github/Chocobozzz/PeerTube.git] / server / types / models / user / user-notification.ts
CommitLineData
453e83ea 1import { UserNotificationModel } from '../../../models/account/user-notification'
67ed6552 2import { PickWith, PickWithOpt } from '@shared/core-utils'
453e83ea
C
3import { VideoModel } from '../../../models/video/video'
4import { ActorModel } from '../../../models/activitypub/actor'
5import { ServerModel } from '../../../models/server/server'
6import { AvatarModel } from '../../../models/avatar/avatar'
7import { VideoChannelModel } from '../../../models/video/video-channel'
8import { AccountModel } from '../../../models/account/account'
9import { VideoCommentModel } from '../../../models/video/video-comment'
10import { VideoAbuseModel } from '../../../models/video/video-abuse'
11import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
12import { VideoImportModel } from '../../../models/video/video-import'
13import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
14
0283eaac
C
15type Use<K extends keyof UserNotificationModel, M> = PickWith<UserNotificationModel, K, M>
16
17// ############################################################################
18
a1587156
C
19export module UserNotificationIncludes {
20
453e83ea 21 export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'>
a1587156
C
22 export type VideoIncludeChannel =
23 VideoInclude &
453e83ea
C
24 PickWith<VideoModel, 'VideoChannel', VideoChannelIncludeActor>
25
a1587156
C
26 export type ActorInclude =
27 Pick<ActorModel, 'preferredUsername' | 'getHost'> &
453e83ea
C
28 PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> &
29 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>>
30
31 export type VideoChannelInclude = Pick<VideoChannelModel, 'id' | 'name' | 'getDisplayName'>
a1587156
C
32 export type VideoChannelIncludeActor =
33 VideoChannelInclude &
453e83ea
C
34 PickWith<VideoChannelModel, 'Actor', ActorInclude>
35
36 export type AccountInclude = Pick<AccountModel, 'id' | 'name' | 'getDisplayName'>
a1587156
C
37 export type AccountIncludeActor =
38 AccountInclude &
453e83ea
C
39 PickWith<AccountModel, 'Actor', ActorInclude>
40
a1587156
C
41 export type VideoCommentInclude =
42 Pick<VideoCommentModel, 'id' | 'originCommentId' | 'getThreadId'> &
453e83ea
C
43 PickWith<VideoCommentModel, 'Account', AccountIncludeActor> &
44 PickWith<VideoCommentModel, 'Video', VideoInclude>
45
a1587156
C
46 export type VideoAbuseInclude =
47 Pick<VideoAbuseModel, 'id'> &
453e83ea
C
48 PickWith<VideoAbuseModel, 'Video', VideoInclude>
49
a1587156
C
50 export type VideoBlacklistInclude =
51 Pick<VideoBlacklistModel, 'id'> &
453e83ea
C
52 PickWith<VideoAbuseModel, 'Video', VideoInclude>
53
a1587156
C
54 export type VideoImportInclude =
55 Pick<VideoImportModel, 'id' | 'magnetUri' | 'targetUrl' | 'torrentName'> &
453e83ea
C
56 PickWith<VideoImportModel, 'Video', VideoInclude>
57
a1587156
C
58 export type ActorFollower =
59 Pick<ActorModel, 'preferredUsername' | 'getHost'> &
453e83ea 60 PickWith<ActorModel, 'Account', AccountInclude> &
8424c402
C
61 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>> &
62 PickWithOpt<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>>
453e83ea 63
a1587156
C
64 export type ActorFollowing =
65 Pick<ActorModel, 'preferredUsername' | 'type' | 'getHost'> &
453e83ea 66 PickWith<ActorModel, 'VideoChannel', VideoChannelInclude> &
8424c402
C
67 PickWith<ActorModel, 'Account', AccountInclude> &
68 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>>
453e83ea 69
a1587156
C
70 export type ActorFollowInclude =
71 Pick<ActorFollowModel, 'id' | 'state'> &
453e83ea
C
72 PickWith<ActorFollowModel, 'ActorFollower', ActorFollower> &
73 PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing>
74}
75
0283eaac
C
76// ############################################################################
77
a1587156
C
78export type MUserNotification =
79 Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' |
453e83ea
C
80 'VideoImport' | 'Account' | 'ActorFollow'>
81
0283eaac
C
82// ############################################################################
83
a1587156
C
84export type UserNotificationModelForApi =
85 MUserNotification &
0283eaac
C
86 Use<'Video', UserNotificationIncludes.VideoIncludeChannel> &
87 Use<'Comment', UserNotificationIncludes.VideoCommentInclude> &
88 Use<'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> &
89 Use<'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> &
90 Use<'VideoImport', UserNotificationIncludes.VideoImportInclude> &
91 Use<'ActorFollow', UserNotificationIncludes.ActorFollowInclude> &
92 Use<'Account', UserNotificationIncludes.AccountIncludeActor>