PeerTube/server/types/models/user/user-notification.ts

107 lines
4.8 KiB
TypeScript
Raw Normal View History

2020-07-01 16:05:30 +02:00
import { VideoAbuseModel } from '@server/models/abuse/video-abuse'
import { VideoCommentAbuseModel } from '@server/models/abuse/video-comment-abuse'
2020-06-23 14:10:17 +02:00
import { PickWith, PickWithOpt } from '@shared/core-utils'
2020-07-01 16:05:30 +02:00
import { AbuseModel } from '../../../models/abuse/abuse'
import { AccountModel } from '../../../models/account/account'
import { UserNotificationModel } from '../../../models/account/user-notification'
2019-08-15 11:53:26 +02:00
import { ActorModel } from '../../../models/activitypub/actor'
2020-07-01 16:05:30 +02:00
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
2019-08-15 11:53:26 +02:00
import { AvatarModel } from '../../../models/avatar/avatar'
2020-07-01 16:05:30 +02:00
import { ServerModel } from '../../../models/server/server'
import { VideoModel } from '../../../models/video/video'
import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
2019-08-15 11:53:26 +02:00
import { VideoChannelModel } from '../../../models/video/video-channel'
import { VideoCommentModel } from '../../../models/video/video-comment'
import { VideoImportModel } from '../../../models/video/video-import'
2019-08-20 13:52:49 +02:00
type Use<K extends keyof UserNotificationModel, M> = PickWith<UserNotificationModel, K, M>
// ############################################################################
2020-01-31 16:56:52 +01:00
export module UserNotificationIncludes {
2019-08-15 11:53:26 +02:00
export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'>
2020-01-31 16:56:52 +01:00
export type VideoIncludeChannel =
VideoInclude &
2019-08-15 11:53:26 +02:00
PickWith<VideoModel, 'VideoChannel', VideoChannelIncludeActor>
2020-01-31 16:56:52 +01:00
export type ActorInclude =
Pick<ActorModel, 'preferredUsername' | 'getHost'> &
2019-08-15 11:53:26 +02:00
PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> &
PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>>
export type VideoChannelInclude = Pick<VideoChannelModel, 'id' | 'name' | 'getDisplayName'>
2020-01-31 16:56:52 +01:00
export type VideoChannelIncludeActor =
VideoChannelInclude &
2019-08-15 11:53:26 +02:00
PickWith<VideoChannelModel, 'Actor', ActorInclude>
export type AccountInclude = Pick<AccountModel, 'id' | 'name' | 'getDisplayName'>
2020-01-31 16:56:52 +01:00
export type AccountIncludeActor =
AccountInclude &
2019-08-15 11:53:26 +02:00
PickWith<AccountModel, 'Actor', ActorInclude>
2020-01-31 16:56:52 +01:00
export type VideoCommentInclude =
Pick<VideoCommentModel, 'id' | 'originCommentId' | 'getThreadId'> &
2019-08-15 11:53:26 +02:00
PickWith<VideoCommentModel, 'Account', AccountIncludeActor> &
PickWith<VideoCommentModel, 'Video', VideoInclude>
2020-01-31 16:56:52 +01:00
export type VideoAbuseInclude =
Pick<VideoAbuseModel, 'id'> &
2019-08-15 11:53:26 +02:00
PickWith<VideoAbuseModel, 'Video', VideoInclude>
2020-07-01 16:05:30 +02:00
export type VideoCommentAbuseInclude =
Pick<VideoCommentAbuseModel, 'id'> &
PickWith<VideoCommentAbuseModel, 'VideoComment',
Pick<VideoCommentModel, 'id' | 'originCommentId' | 'getThreadId'> &
2020-07-08 15:51:46 +02:00
PickWith<VideoCommentModel, 'Video', Pick<VideoModel, 'id' | 'name' | 'uuid'>>>
2020-07-01 16:05:30 +02:00
export type AbuseInclude =
Pick<AbuseModel, 'id' | 'state'> &
2020-07-01 16:05:30 +02:00
PickWith<AbuseModel, 'VideoAbuse', VideoAbuseInclude> &
PickWith<AbuseModel, 'VideoCommentAbuse', VideoCommentAbuseInclude> &
PickWith<AbuseModel, 'FlaggedAccount', AccountIncludeActor>
2020-01-31 16:56:52 +01:00
export type VideoBlacklistInclude =
Pick<VideoBlacklistModel, 'id'> &
2019-08-15 11:53:26 +02:00
PickWith<VideoAbuseModel, 'Video', VideoInclude>
2020-01-31 16:56:52 +01:00
export type VideoImportInclude =
Pick<VideoImportModel, 'id' | 'magnetUri' | 'targetUrl' | 'torrentName'> &
2019-08-15 11:53:26 +02:00
PickWith<VideoImportModel, 'Video', VideoInclude>
2020-01-31 16:56:52 +01:00
export type ActorFollower =
Pick<ActorModel, 'preferredUsername' | 'getHost'> &
2019-08-15 11:53:26 +02:00
PickWith<ActorModel, 'Account', AccountInclude> &
PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>> &
PickWithOpt<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>>
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type ActorFollowing =
Pick<ActorModel, 'preferredUsername' | 'type' | 'getHost'> &
2019-08-15 11:53:26 +02:00
PickWith<ActorModel, 'VideoChannel', VideoChannelInclude> &
PickWith<ActorModel, 'Account', AccountInclude> &
PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>>
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type ActorFollowInclude =
Pick<ActorFollowModel, 'id' | 'state'> &
2019-08-15 11:53:26 +02:00
PickWith<ActorFollowModel, 'ActorFollower', ActorFollower> &
PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing>
}
2019-08-20 13:52:49 +02:00
// ############################################################################
2020-01-31 16:56:52 +01:00
export type MUserNotification =
2020-07-01 16:05:30 +02:00
Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'Abuse' | 'VideoBlacklist' |
2019-08-15 11:53:26 +02:00
'VideoImport' | 'Account' | 'ActorFollow'>
2019-08-20 13:52:49 +02:00
// ############################################################################
2020-01-31 16:56:52 +01:00
export type UserNotificationModelForApi =
MUserNotification &
2019-08-20 13:52:49 +02:00
Use<'Video', UserNotificationIncludes.VideoIncludeChannel> &
Use<'Comment', UserNotificationIncludes.VideoCommentInclude> &
2020-07-01 16:05:30 +02:00
Use<'Abuse', UserNotificationIncludes.AbuseInclude> &
2019-08-20 13:52:49 +02:00
Use<'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> &
Use<'VideoImport', UserNotificationIncludes.VideoImportInclude> &
Use<'ActorFollow', UserNotificationIncludes.ActorFollowInclude> &
Use<'Account', UserNotificationIncludes.AccountIncludeActor>