diff options
author | Chocobozzz <me@florianbigard.com> | 2019-08-15 11:53:26 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-08-19 17:26:35 +0200 |
commit | 453e83ea5d81d203ba34bc43cd5c2c750ba40568 (patch) | |
tree | 604e02f4343d13a4ba42e1fb7527ba6ab9111712 /server/typings/models/user/user-notification.ts | |
parent | 13176a07a95984a53cc59aec5217f2ce9806d1bc (diff) | |
download | PeerTube-453e83ea5d81d203ba34bc43cd5c2c750ba40568.tar.gz PeerTube-453e83ea5d81d203ba34bc43cd5c2c750ba40568.tar.zst PeerTube-453e83ea5d81d203ba34bc43cd5c2c750ba40568.zip |
Stronger model typings
Diffstat (limited to 'server/typings/models/user/user-notification.ts')
-rw-r--r-- | server/typings/models/user/user-notification.ts | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/server/typings/models/user/user-notification.ts b/server/typings/models/user/user-notification.ts new file mode 100644 index 000000000..b872c5dc5 --- /dev/null +++ b/server/typings/models/user/user-notification.ts | |||
@@ -0,0 +1,69 @@ | |||
1 | import { UserNotificationModel } from '../../../models/account/user-notification' | ||
2 | import { PickWith } from '../../utils' | ||
3 | import { VideoModel } from '../../../models/video/video' | ||
4 | import { ActorModel } from '../../../models/activitypub/actor' | ||
5 | import { ServerModel } from '../../../models/server/server' | ||
6 | import { AvatarModel } from '../../../models/avatar/avatar' | ||
7 | import { VideoChannelModel } from '../../../models/video/video-channel' | ||
8 | import { AccountModel } from '../../../models/account/account' | ||
9 | import { VideoCommentModel } from '../../../models/video/video-comment' | ||
10 | import { VideoAbuseModel } from '../../../models/video/video-abuse' | ||
11 | import { VideoBlacklistModel } from '../../../models/video/video-blacklist' | ||
12 | import { VideoImportModel } from '../../../models/video/video-import' | ||
13 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | ||
14 | |||
15 | export namespace UserNotificationIncludes { | ||
16 | export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'> | ||
17 | export type VideoIncludeChannel = VideoInclude & | ||
18 | PickWith<VideoModel, 'VideoChannel', VideoChannelIncludeActor> | ||
19 | |||
20 | export type ActorInclude = Pick<ActorModel, 'preferredUsername' | 'getHost'> & | ||
21 | PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> & | ||
22 | PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>> | ||
23 | |||
24 | export type VideoChannelInclude = Pick<VideoChannelModel, 'id' | 'name' | 'getDisplayName'> | ||
25 | export type VideoChannelIncludeActor = VideoChannelInclude & | ||
26 | PickWith<VideoChannelModel, 'Actor', ActorInclude> | ||
27 | |||
28 | export type AccountInclude = Pick<AccountModel, 'id' | 'name' | 'getDisplayName'> | ||
29 | export type AccountIncludeActor = AccountInclude & | ||
30 | PickWith<AccountModel, 'Actor', ActorInclude> | ||
31 | |||
32 | export type VideoCommentInclude = Pick<VideoCommentModel, 'id' | 'originCommentId' | 'getThreadId'> & | ||
33 | PickWith<VideoCommentModel, 'Account', AccountIncludeActor> & | ||
34 | PickWith<VideoCommentModel, 'Video', VideoInclude> | ||
35 | |||
36 | export type VideoAbuseInclude = Pick<VideoAbuseModel, 'id'> & | ||
37 | PickWith<VideoAbuseModel, 'Video', VideoInclude> | ||
38 | |||
39 | export type VideoBlacklistInclude = Pick<VideoBlacklistModel, 'id'> & | ||
40 | PickWith<VideoAbuseModel, 'Video', VideoInclude> | ||
41 | |||
42 | export type VideoImportInclude = Pick<VideoImportModel, 'id' | 'magnetUri' | 'targetUrl' | 'torrentName'> & | ||
43 | PickWith<VideoImportModel, 'Video', VideoInclude> | ||
44 | |||
45 | export type ActorFollower = Pick<ActorModel, 'preferredUsername' | 'getHost'> & | ||
46 | PickWith<ActorModel, 'Account', AccountInclude> & | ||
47 | PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> & | ||
48 | PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>> | ||
49 | |||
50 | export type ActorFollowing = Pick<ActorModel, 'preferredUsername'> & | ||
51 | PickWith<ActorModel, 'VideoChannel', VideoChannelInclude> & | ||
52 | PickWith<ActorModel, 'Account', AccountInclude> | ||
53 | |||
54 | export type ActorFollowInclude = Pick<ActorFollowModel, 'id' | 'state'> & | ||
55 | PickWith<ActorFollowModel, 'ActorFollower', ActorFollower> & | ||
56 | PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing> | ||
57 | } | ||
58 | |||
59 | export type UserNotificationModelOnly = Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' | | ||
60 | 'VideoImport' | 'Account' | 'ActorFollow'> | ||
61 | |||
62 | export type UserNotificationModelForApi = UserNotificationModelOnly & | ||
63 | PickWith<UserNotificationModel, 'Video', UserNotificationIncludes.VideoIncludeChannel> & | ||
64 | PickWith<UserNotificationModel, 'Comment', UserNotificationIncludes.VideoCommentInclude> & | ||
65 | PickWith<UserNotificationModel, 'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> & | ||
66 | PickWith<UserNotificationModel, 'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> & | ||
67 | PickWith<UserNotificationModel, 'VideoImport', UserNotificationIncludes.VideoImportInclude> & | ||
68 | PickWith<UserNotificationModel, 'ActorFollow', UserNotificationIncludes.ActorFollowInclude> & | ||
69 | PickWith<UserNotificationModel, 'Account', UserNotificationIncludes.AccountIncludeActor> | ||