diff options
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/abuse/abuse.ts | 8 | ||||
-rw-r--r-- | server/models/account/user.ts | 45 |
2 files changed, 28 insertions, 25 deletions
diff --git a/server/models/abuse/abuse.ts b/server/models/abuse/abuse.ts index 1b599db62..2a407c3d2 100644 --- a/server/models/abuse/abuse.ts +++ b/server/models/abuse/abuse.ts | |||
@@ -17,11 +17,11 @@ import { | |||
17 | UpdatedAt | 17 | UpdatedAt |
18 | } from 'sequelize-typescript' | 18 | } from 'sequelize-typescript' |
19 | import { isAbuseModerationCommentValid, isAbuseReasonValid, isAbuseStateValid } from '@server/helpers/custom-validators/abuses' | 19 | import { isAbuseModerationCommentValid, isAbuseReasonValid, isAbuseStateValid } from '@server/helpers/custom-validators/abuses' |
20 | import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse' | ||
20 | import { | 21 | import { |
21 | AbuseFilter, | 22 | AbuseFilter, |
22 | AbuseObject, | 23 | AbuseObject, |
23 | AbusePredefinedReasons, | 24 | AbusePredefinedReasons, |
24 | abusePredefinedReasonsMap, | ||
25 | AbusePredefinedReasonsString, | 25 | AbusePredefinedReasonsString, |
26 | AbuseState, | 26 | AbuseState, |
27 | AbuseVideoIs, | 27 | AbuseVideoIs, |
@@ -646,8 +646,10 @@ export class AbuseModel extends Model<AbuseModel> { | |||
646 | } | 646 | } |
647 | 647 | ||
648 | private static getPredefinedReasonsStrings (predefinedReasons: AbusePredefinedReasons[]): AbusePredefinedReasonsString[] { | 648 | private static getPredefinedReasonsStrings (predefinedReasons: AbusePredefinedReasons[]): AbusePredefinedReasonsString[] { |
649 | const invertedPredefinedReasons = invert(abusePredefinedReasonsMap) | ||
650 | |||
649 | return (predefinedReasons || []) | 651 | return (predefinedReasons || []) |
650 | .filter(r => r in AbusePredefinedReasons) | 652 | .map(r => invertedPredefinedReasons[r] as AbusePredefinedReasonsString) |
651 | .map(r => invert(abusePredefinedReasonsMap)[r] as AbusePredefinedReasonsString) | 653 | .filter(v => !!v) |
652 | } | 654 | } |
653 | } | 655 | } |
diff --git a/server/models/account/user.ts b/server/models/account/user.ts index 5f45f8e7c..22e6715b4 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts | |||
@@ -1,3 +1,5 @@ | |||
1 | import * as Bluebird from 'bluebird' | ||
2 | import { values } from 'lodash' | ||
1 | import { col, FindOptions, fn, literal, Op, QueryTypes, where, WhereOptions } from 'sequelize' | 3 | import { col, FindOptions, fn, literal, Op, QueryTypes, where, WhereOptions } from 'sequelize' |
2 | import { | 4 | import { |
3 | AfterDestroy, | 5 | AfterDestroy, |
@@ -19,8 +21,21 @@ import { | |||
19 | Table, | 21 | Table, |
20 | UpdatedAt | 22 | UpdatedAt |
21 | } from 'sequelize-typescript' | 23 | } from 'sequelize-typescript' |
22 | import { hasUserRight, MyUser, USER_ROLE_LABELS, UserRight, AbuseState, VideoPlaylistType, VideoPrivacy } from '../../../shared' | 24 | import { |
25 | MMyUserFormattable, | ||
26 | MUserDefault, | ||
27 | MUserFormattable, | ||
28 | MUserId, | ||
29 | MUserNotifSettingChannelDefault, | ||
30 | MUserWithNotificationSetting, | ||
31 | MVideoFullLight | ||
32 | } from '@server/types/models' | ||
33 | import { hasUserRight, USER_ROLE_LABELS } from '../../../shared/core-utils/users' | ||
34 | import { AbuseState, MyUser, UserRight, VideoPlaylistType, VideoPrivacy } from '../../../shared/models' | ||
23 | import { User, UserRole } from '../../../shared/models/users' | 35 | import { User, UserRole } from '../../../shared/models/users' |
36 | import { UserAdminFlag } from '../../../shared/models/users/user-flag.model' | ||
37 | import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type' | ||
38 | import { isThemeNameValid } from '../../helpers/custom-validators/plugins' | ||
24 | import { | 39 | import { |
25 | isNoInstanceConfigWarningModal, | 40 | isNoInstanceConfigWarningModal, |
26 | isNoWelcomeModal, | 41 | isNoWelcomeModal, |
@@ -42,33 +57,19 @@ import { | |||
42 | isUserWebTorrentEnabledValid | 57 | isUserWebTorrentEnabledValid |
43 | } from '../../helpers/custom-validators/users' | 58 | } from '../../helpers/custom-validators/users' |
44 | import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto' | 59 | import { comparePassword, cryptPassword } from '../../helpers/peertube-crypto' |
60 | import { DEFAULT_USER_THEME_NAME, NSFW_POLICY_TYPES } from '../../initializers/constants' | ||
61 | import { clearCacheByUserId } from '../../lib/oauth-model' | ||
62 | import { getThemeOrDefault } from '../../lib/plugins/theme-utils' | ||
63 | import { ActorModel } from '../activitypub/actor' | ||
64 | import { ActorFollowModel } from '../activitypub/actor-follow' | ||
45 | import { OAuthTokenModel } from '../oauth/oauth-token' | 65 | import { OAuthTokenModel } from '../oauth/oauth-token' |
46 | import { getSort, throwIfNotValid } from '../utils' | 66 | import { getSort, throwIfNotValid } from '../utils' |
67 | import { VideoModel } from '../video/video' | ||
47 | import { VideoChannelModel } from '../video/video-channel' | 68 | import { VideoChannelModel } from '../video/video-channel' |
69 | import { VideoImportModel } from '../video/video-import' | ||
48 | import { VideoPlaylistModel } from '../video/video-playlist' | 70 | import { VideoPlaylistModel } from '../video/video-playlist' |
49 | import { AccountModel } from './account' | 71 | import { AccountModel } from './account' |
50 | import { NSFWPolicyType } from '../../../shared/models/videos/nsfw-policy.type' | ||
51 | import { values } from 'lodash' | ||
52 | import { DEFAULT_USER_THEME_NAME, NSFW_POLICY_TYPES } from '../../initializers/constants' | ||
53 | import { clearCacheByUserId } from '../../lib/oauth-model' | ||
54 | import { UserNotificationSettingModel } from './user-notification-setting' | 72 | import { UserNotificationSettingModel } from './user-notification-setting' |
55 | import { VideoModel } from '../video/video' | ||
56 | import { ActorModel } from '../activitypub/actor' | ||
57 | import { ActorFollowModel } from '../activitypub/actor-follow' | ||
58 | import { VideoImportModel } from '../video/video-import' | ||
59 | import { UserAdminFlag } from '../../../shared/models/users/user-flag.model' | ||
60 | import { isThemeNameValid } from '../../helpers/custom-validators/plugins' | ||
61 | import { getThemeOrDefault } from '../../lib/plugins/theme-utils' | ||
62 | import * as Bluebird from 'bluebird' | ||
63 | import { | ||
64 | MMyUserFormattable, | ||
65 | MUserDefault, | ||
66 | MUserFormattable, | ||
67 | MUserId, | ||
68 | MUserNotifSettingChannelDefault, | ||
69 | MUserWithNotificationSetting, | ||
70 | MVideoFullLight | ||
71 | } from '@server/types/models' | ||
72 | 73 | ||
73 | enum ScopeNames { | 74 | enum ScopeNames { |
74 | FOR_ME_API = 'FOR_ME_API', | 75 | FOR_ME_API = 'FOR_ME_API', |