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

117 lines
5.3 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'
2021-03-11 16:54:52 +01:00
import { ApplicationModel } from '@server/models/application/application'
import { PluginModel } from '@server/models/server/plugin'
2021-05-11 11:15:29 +02:00
import { UserNotificationModel } from '@server/models/user/user-notification'
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'
2021-05-11 11:15:29 +02:00
import { ActorModel } from '../../../models/actor/actor'
import { ActorFollowModel } from '../../../models/actor/actor-follow'
import { ActorImageModel } from '../../../models/actor/actor-image'
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'> &
2021-04-06 11:35:56 +02:00
PickWith<ActorModel, 'Avatar', Pick<ActorImageModel, 'filename' | 'getStaticPath'>> &
2019-08-15 11:53:26 +02:00
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'>> &
2021-04-06 11:35:56 +02:00
PickWithOpt<ActorModel, 'Avatar', Pick<ActorImageModel, '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>
2021-03-11 16:54:52 +01:00
export type PluginInclude =
Pick<PluginModel, 'id' | 'name' | 'type' | 'latestVersion'>
export type ApplicationInclude =
Pick<ApplicationModel, 'latestPeerTubeVersion'>
2019-08-15 11:53:26 +02:00
}
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' |
2021-03-11 16:54:52 +01:00
'VideoImport' | 'Account' | 'ActorFollow' | 'Plugin' | 'Application'>
2019-08-15 11:53:26 +02:00
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> &
2021-03-11 16:54:52 +01:00
Use<'Plugin', UserNotificationIncludes.PluginInclude> &
Use<'Application', UserNotificationIncludes.ApplicationInclude> &
2019-08-20 13:52:49 +02:00
Use<'Account', UserNotificationIncludes.AccountIncludeActor>