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

93 lines
4.1 KiB
TypeScript
Raw Normal View History

2019-08-15 04:53:26 -05:00
import { UserNotificationModel } from '../../../models/account/user-notification'
import { PickWith, PickWithOpt } from '../../utils'
2019-08-15 04:53:26 -05:00
import { VideoModel } from '../../../models/video/video'
import { ActorModel } from '../../../models/activitypub/actor'
import { ServerModel } from '../../../models/server/server'
import { AvatarModel } from '../../../models/avatar/avatar'
import { VideoChannelModel } from '../../../models/video/video-channel'
import { AccountModel } from '../../../models/account/account'
import { VideoCommentModel } from '../../../models/video/video-comment'
import { VideoAbuseModel } from '../../../models/video/video-abuse'
import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
import { VideoImportModel } from '../../../models/video/video-import'
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
2019-08-20 06:52:49 -05:00
type Use<K extends keyof UserNotificationModel, M> = PickWith<UserNotificationModel, K, M>
// ############################################################################
2020-01-31 09:56:52 -06:00
export module UserNotificationIncludes {
2019-08-15 04:53:26 -05:00
export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'>
2020-01-31 09:56:52 -06:00
export type VideoIncludeChannel =
VideoInclude &
2019-08-15 04:53:26 -05:00
PickWith<VideoModel, 'VideoChannel', VideoChannelIncludeActor>
2020-01-31 09:56:52 -06:00
export type ActorInclude =
Pick<ActorModel, 'preferredUsername' | 'getHost'> &
2019-08-15 04:53:26 -05: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 09:56:52 -06:00
export type VideoChannelIncludeActor =
VideoChannelInclude &
2019-08-15 04:53:26 -05:00
PickWith<VideoChannelModel, 'Actor', ActorInclude>
export type AccountInclude = Pick<AccountModel, 'id' | 'name' | 'getDisplayName'>
2020-01-31 09:56:52 -06:00
export type AccountIncludeActor =
AccountInclude &
2019-08-15 04:53:26 -05:00
PickWith<AccountModel, 'Actor', ActorInclude>
2020-01-31 09:56:52 -06:00
export type VideoCommentInclude =
Pick<VideoCommentModel, 'id' | 'originCommentId' | 'getThreadId'> &
2019-08-15 04:53:26 -05:00
PickWith<VideoCommentModel, 'Account', AccountIncludeActor> &
PickWith<VideoCommentModel, 'Video', VideoInclude>
2020-01-31 09:56:52 -06:00
export type VideoAbuseInclude =
Pick<VideoAbuseModel, 'id'> &
2019-08-15 04:53:26 -05:00
PickWith<VideoAbuseModel, 'Video', VideoInclude>
2020-01-31 09:56:52 -06:00
export type VideoBlacklistInclude =
Pick<VideoBlacklistModel, 'id'> &
2019-08-15 04:53:26 -05:00
PickWith<VideoAbuseModel, 'Video', VideoInclude>
2020-01-31 09:56:52 -06:00
export type VideoImportInclude =
Pick<VideoImportModel, 'id' | 'magnetUri' | 'targetUrl' | 'torrentName'> &
2019-08-15 04:53:26 -05:00
PickWith<VideoImportModel, 'Video', VideoInclude>
2020-01-31 09:56:52 -06:00
export type ActorFollower =
Pick<ActorModel, 'preferredUsername' | 'getHost'> &
2019-08-15 04:53:26 -05:00
PickWith<ActorModel, 'Account', AccountInclude> &
PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>> &
PickWithOpt<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>>
2019-08-15 04:53:26 -05:00
2020-01-31 09:56:52 -06:00
export type ActorFollowing =
Pick<ActorModel, 'preferredUsername' | 'type' | 'getHost'> &
2019-08-15 04:53:26 -05:00
PickWith<ActorModel, 'VideoChannel', VideoChannelInclude> &
PickWith<ActorModel, 'Account', AccountInclude> &
PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>>
2019-08-15 04:53:26 -05:00
2020-01-31 09:56:52 -06:00
export type ActorFollowInclude =
Pick<ActorFollowModel, 'id' | 'state'> &
2019-08-15 04:53:26 -05:00
PickWith<ActorFollowModel, 'ActorFollower', ActorFollower> &
PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing>
}
2019-08-20 06:52:49 -05:00
// ############################################################################
2020-01-31 09:56:52 -06:00
export type MUserNotification =
Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' |
2019-08-15 04:53:26 -05:00
'VideoImport' | 'Account' | 'ActorFollow'>
2019-08-20 06:52:49 -05:00
// ############################################################################
2020-01-31 09:56:52 -06:00
export type UserNotificationModelForApi =
MUserNotification &
2019-08-20 06:52:49 -05:00
Use<'Video', UserNotificationIncludes.VideoIncludeChannel> &
Use<'Comment', UserNotificationIncludes.VideoCommentInclude> &
Use<'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> &
Use<'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> &
Use<'VideoImport', UserNotificationIncludes.VideoImportInclude> &
Use<'ActorFollow', UserNotificationIncludes.ActorFollowInclude> &
Use<'Account', UserNotificationIncludes.AccountIncludeActor>