From d95d15598847c7f020aa056e7e6e0c02d2bbf732 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 1 Jul 2020 16:05:30 +0200 Subject: Use 3 tables to represent abuses --- server/types/models/index.ts | 1 + server/types/models/moderation/abuse.ts | 97 +++++++++++++++++++++++++++ server/types/models/moderation/index.ts | 1 + server/types/models/user/user-notification.ts | 32 ++++++--- server/types/models/video/index.ts | 1 - server/types/models/video/video-abuse.ts | 35 ---------- 6 files changed, 122 insertions(+), 45 deletions(-) create mode 100644 server/types/models/moderation/abuse.ts create mode 100644 server/types/models/moderation/index.ts delete mode 100644 server/types/models/video/video-abuse.ts (limited to 'server/types') diff --git a/server/types/models/index.ts b/server/types/models/index.ts index 78b4948ce..affa17425 100644 --- a/server/types/models/index.ts +++ b/server/types/models/index.ts @@ -1,4 +1,5 @@ export * from './account' +export * from './moderation' export * from './oauth' export * from './server' export * from './user' diff --git a/server/types/models/moderation/abuse.ts b/server/types/models/moderation/abuse.ts new file mode 100644 index 000000000..abbc93d6f --- /dev/null +++ b/server/types/models/moderation/abuse.ts @@ -0,0 +1,97 @@ +import { VideoAbuseModel } from '@server/models/abuse/video-abuse' +import { VideoCommentAbuseModel } from '@server/models/abuse/video-comment-abuse' +import { PickWith } from '@shared/core-utils' +import { AbuseModel } from '../../../models/abuse/abuse' +import { MAccountDefault, MAccountFormattable, MAccountLight, MAccountUrl } from '../account' +import { MCommentOwner, MCommentUrl, MVideoUrl, MCommentOwnerVideo } from '../video' +import { MVideo, MVideoAccountLightBlacklistAllFiles } from '../video/video' + +type Use = PickWith +type UseVideoAbuse = PickWith +type UseCommentAbuse = PickWith + +// ############################################################################ + +export type MAbuse = Omit + +export type MVideoAbuse = Omit + +export type MCommentAbuse = Omit + +// ############################################################################ + +export type MVideoAbuseVideo = + MVideoAbuse & + UseVideoAbuse<'Video', MVideo> + +export type MVideoAbuseVideoUrl = + MVideoAbuse & + UseVideoAbuse<'Video', MVideoUrl> + +export type MVideoAbuseVideoFull = + MVideoAbuse & + UseVideoAbuse<'Video', MVideoAccountLightBlacklistAllFiles> + +export type MVideoAbuseFormattable = + MVideoAbuse & + UseVideoAbuse<'Video', Pick> + +// ############################################################################ + +export type MCommentAbuseAccount = + MCommentAbuse & + UseCommentAbuse<'VideoComment', MCommentOwner> + +export type MCommentAbuseAccountVideo = + MCommentAbuse & + UseCommentAbuse<'VideoComment', MCommentOwnerVideo> + +export type MCommentAbuseUrl = + MCommentAbuse & + UseCommentAbuse<'VideoComment', MCommentUrl> + +// ############################################################################ + +export type MAbuseId = Pick + +export type MAbuseVideo = + MAbuse & + Pick & + Use<'VideoAbuse', MVideoAbuseVideo> + +export type MAbuseUrl = + MAbuse & + Use<'VideoAbuse', MVideoAbuseVideoUrl> & + Use<'VideoCommentAbuse', MCommentAbuseUrl> + +export type MAbuseAccountVideo = + MAbuse & + Pick & + Use<'VideoAbuse', MVideoAbuseVideoFull> & + Use<'ReporterAccount', MAccountDefault> + +export type MAbuseAP = + MAbuse & + Pick & + Use<'ReporterAccount', MAccountUrl> & + Use<'FlaggedAccount', MAccountUrl> & + Use<'VideoAbuse', MVideoAbuseVideo> & + Use<'VideoCommentAbuse', MCommentAbuseAccount> + +export type MAbuseFull = + MAbuse & + Pick & + Use<'ReporterAccount', MAccountLight> & + Use<'FlaggedAccount', MAccountLight> & + Use<'VideoAbuse', MVideoAbuseVideoFull> & + Use<'VideoCommentAbuse', MCommentAbuseAccountVideo> + +// ############################################################################ + +// Format for API or AP object + +export type MAbuseFormattable = + MAbuse & + Use<'ReporterAccount', MAccountFormattable> & + Use<'VideoAbuse', MVideoAbuseFormattable> diff --git a/server/types/models/moderation/index.ts b/server/types/models/moderation/index.ts new file mode 100644 index 000000000..8bea1708f --- /dev/null +++ b/server/types/models/moderation/index.ts @@ -0,0 +1 @@ +export * from './abuse' diff --git a/server/types/models/user/user-notification.ts b/server/types/models/user/user-notification.ts index dd3de423b..92ea16768 100644 --- a/server/types/models/user/user-notification.ts +++ b/server/types/models/user/user-notification.ts @@ -1,16 +1,18 @@ -import { UserNotificationModel } from '../../../models/account/user-notification' +import { VideoAbuseModel } from '@server/models/abuse/video-abuse' +import { VideoCommentAbuseModel } from '@server/models/abuse/video-comment-abuse' import { PickWith, PickWithOpt } from '@shared/core-utils' -import { VideoModel } from '../../../models/video/video' +import { AbuseModel } from '../../../models/abuse/abuse' +import { AccountModel } from '../../../models/account/account' +import { UserNotificationModel } from '../../../models/account/user-notification' import { ActorModel } from '../../../models/activitypub/actor' -import { ServerModel } from '../../../models/server/server' +import { ActorFollowModel } from '../../../models/activitypub/actor-follow' import { AvatarModel } from '../../../models/avatar/avatar' +import { ServerModel } from '../../../models/server/server' +import { VideoModel } from '../../../models/video/video' +import { VideoBlacklistModel } from '../../../models/video/video-blacklist' 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' type Use = PickWith @@ -47,6 +49,18 @@ export module UserNotificationIncludes { Pick & PickWith + export type VideoCommentAbuseInclude = + Pick & + PickWith & + PickWith>> + + export type AbuseInclude = + Pick & + PickWith & + PickWith & + PickWith + export type VideoBlacklistInclude = Pick & PickWith @@ -76,7 +90,7 @@ export module UserNotificationIncludes { // ############################################################################ export type MUserNotification = - Omit // ############################################################################ @@ -85,7 +99,7 @@ export type UserNotificationModelForApi = MUserNotification & Use<'Video', UserNotificationIncludes.VideoIncludeChannel> & Use<'Comment', UserNotificationIncludes.VideoCommentInclude> & - Use<'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> & + Use<'Abuse', UserNotificationIncludes.AbuseInclude> & Use<'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> & Use<'VideoImport', UserNotificationIncludes.VideoImportInclude> & Use<'ActorFollow', UserNotificationIncludes.ActorFollowInclude> & diff --git a/server/types/models/video/index.ts b/server/types/models/video/index.ts index bd69c8a4b..25db23898 100644 --- a/server/types/models/video/index.ts +++ b/server/types/models/video/index.ts @@ -2,7 +2,6 @@ export * from './schedule-video-update' export * from './tag' export * from './thumbnail' export * from './video' -export * from './video-abuse' export * from './video-blacklist' export * from './video-caption' export * from './video-change-ownership' diff --git a/server/types/models/video/video-abuse.ts b/server/types/models/video/video-abuse.ts deleted file mode 100644 index 279a87cf3..000000000 --- a/server/types/models/video/video-abuse.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { VideoAbuseModel } from '../../../models/video/video-abuse' -import { PickWith } from '@shared/core-utils' -import { MVideoAccountLightBlacklistAllFiles, MVideo } from './video' -import { MAccountDefault, MAccountFormattable } from '../account' - -type Use = PickWith - -// ############################################################################ - -export type MVideoAbuse = Omit - -// ############################################################################ - -export type MVideoAbuseId = Pick - -export type MVideoAbuseVideo = - MVideoAbuse & - Pick & - Use<'Video', MVideo> - -export type MVideoAbuseAccountVideo = - MVideoAbuse & - Pick & - Use<'Video', MVideoAccountLightBlacklistAllFiles> & - Use<'Account', MAccountDefault> - -// ############################################################################ - -// Format for API or AP object - -export type MVideoAbuseFormattable = - MVideoAbuse & - Use<'Account', MAccountFormattable> & - Use<'Video', Pick> -- cgit v1.2.3