aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/models/users
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-07-31 14:34:36 +0200
committerChocobozzz <me@florianbigard.com>2023-08-11 15:02:33 +0200
commit3a4992633ee62d5edfbb484d9c6bcb3cf158489d (patch)
treee4510b39bdac9c318fdb4b47018d08f15368b8f0 /shared/models/users
parent04d1da5621d25d59bd5fa1543b725c497bf5d9a8 (diff)
downloadPeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.gz
PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.zst
PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.zip
Migrate server to ESM
Sorry for the very big commit that may lead to git log issues and merge conflicts, but it's a major step forward: * Server can be faster at startup because imports() are async and we can easily lazy import big modules * Angular doesn't seem to support ES import (with .js extension), so we had to correctly organize peertube into a monorepo: * Use yarn workspace feature * Use typescript reference projects for dependencies * Shared projects have been moved into "packages", each one is now a node module (with a dedicated package.json/tsconfig.json) * server/tools have been moved into apps/ and is now a dedicated app bundled and published on NPM so users don't have to build peertube cli tools manually * server/tests have been moved into packages/ so we don't compile them every time we want to run the server * Use isolatedModule option: * Had to move from const enum to const (https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums) * Had to explictely specify "type" imports when used in decorators * Prefer tsx (that uses esbuild under the hood) instead of ts-node to load typescript files (tests with mocha or scripts): * To reduce test complexity as esbuild doesn't support decorator metadata, we only test server files that do not import server models * We still build tests files into js files for a faster CI * Remove unmaintained peertube CLI import script * Removed some barrels to speed up execution (less imports)
Diffstat (limited to 'shared/models/users')
-rw-r--r--shared/models/users/index.ts16
-rw-r--r--shared/models/users/registration/index.ts5
-rw-r--r--shared/models/users/registration/user-register.model.ts12
-rw-r--r--shared/models/users/registration/user-registration-request.model.ts5
-rw-r--r--shared/models/users/registration/user-registration-state.model.ts5
-rw-r--r--shared/models/users/registration/user-registration-update-state.model.ts4
-rw-r--r--shared/models/users/registration/user-registration.model.ts29
-rw-r--r--shared/models/users/two-factor-enable-result.model.ts7
-rw-r--r--shared/models/users/user-create-result.model.ts7
-rw-r--r--shared/models/users/user-create.model.ts13
-rw-r--r--shared/models/users/user-flag.model.ts4
-rw-r--r--shared/models/users/user-login.model.ts5
-rw-r--r--shared/models/users/user-notification-setting.model.ts32
-rw-r--r--shared/models/users/user-notification.model.ts138
-rw-r--r--shared/models/users/user-refresh-token.model.ts4
-rw-r--r--shared/models/users/user-right.enum.ts51
-rw-r--r--shared/models/users/user-role.ts6
-rw-r--r--shared/models/users/user-scoped-token.ts5
-rw-r--r--shared/models/users/user-update-me.model.ts26
-rw-r--r--shared/models/users/user-update.model.ts13
-rw-r--r--shared/models/users/user-video-quota.model.ts4
-rw-r--r--shared/models/users/user.model.ts78
22 files changed, 0 insertions, 469 deletions
diff --git a/shared/models/users/index.ts b/shared/models/users/index.ts
deleted file mode 100644
index 4a050c870..000000000
--- a/shared/models/users/index.ts
+++ /dev/null
@@ -1,16 +0,0 @@
1export * from './registration'
2export * from './two-factor-enable-result.model'
3export * from './user-create-result.model'
4export * from './user-create.model'
5export * from './user-flag.model'
6export * from './user-login.model'
7export * from './user-notification-setting.model'
8export * from './user-notification.model'
9export * from './user-refresh-token.model'
10export * from './user-right.enum'
11export * from './user-role'
12export * from './user-scoped-token'
13export * from './user-update-me.model'
14export * from './user-update.model'
15export * from './user-video-quota.model'
16export * from './user.model'
diff --git a/shared/models/users/registration/index.ts b/shared/models/users/registration/index.ts
deleted file mode 100644
index 593740c4f..000000000
--- a/shared/models/users/registration/index.ts
+++ /dev/null
@@ -1,5 +0,0 @@
1export * from './user-register.model'
2export * from './user-registration-request.model'
3export * from './user-registration-state.model'
4export * from './user-registration-update-state.model'
5export * from './user-registration.model'
diff --git a/shared/models/users/registration/user-register.model.ts b/shared/models/users/registration/user-register.model.ts
deleted file mode 100644
index cf9a43a67..000000000
--- a/shared/models/users/registration/user-register.model.ts
+++ /dev/null
@@ -1,12 +0,0 @@
1export interface UserRegister {
2 username: string
3 password: string
4 email: string
5
6 displayName?: string
7
8 channel?: {
9 name: string
10 displayName: string
11 }
12}
diff --git a/shared/models/users/registration/user-registration-request.model.ts b/shared/models/users/registration/user-registration-request.model.ts
deleted file mode 100644
index 6c38817e0..000000000
--- a/shared/models/users/registration/user-registration-request.model.ts
+++ /dev/null
@@ -1,5 +0,0 @@
1import { UserRegister } from './user-register.model'
2
3export interface UserRegistrationRequest extends UserRegister {
4 registrationReason: string
5}
diff --git a/shared/models/users/registration/user-registration-state.model.ts b/shared/models/users/registration/user-registration-state.model.ts
deleted file mode 100644
index e4c835f78..000000000
--- a/shared/models/users/registration/user-registration-state.model.ts
+++ /dev/null
@@ -1,5 +0,0 @@
1export const enum UserRegistrationState {
2 PENDING = 1,
3 REJECTED = 2,
4 ACCEPTED = 3
5}
diff --git a/shared/models/users/registration/user-registration-update-state.model.ts b/shared/models/users/registration/user-registration-update-state.model.ts
deleted file mode 100644
index a1740dcca..000000000
--- a/shared/models/users/registration/user-registration-update-state.model.ts
+++ /dev/null
@@ -1,4 +0,0 @@
1export interface UserRegistrationUpdateState {
2 moderationResponse: string
3 preventEmailDelivery?: boolean
4}
diff --git a/shared/models/users/registration/user-registration.model.ts b/shared/models/users/registration/user-registration.model.ts
deleted file mode 100644
index 0d74dc28b..000000000
--- a/shared/models/users/registration/user-registration.model.ts
+++ /dev/null
@@ -1,29 +0,0 @@
1import { UserRegistrationState } from './user-registration-state.model'
2
3export interface UserRegistration {
4 id: number
5
6 state: {
7 id: UserRegistrationState
8 label: string
9 }
10
11 registrationReason: string
12 moderationResponse: string
13
14 username: string
15 email: string
16 emailVerified: boolean
17
18 accountDisplayName: string
19
20 channelHandle: string
21 channelDisplayName: string
22
23 createdAt: Date
24 updatedAt: Date
25
26 user?: {
27 id: number
28 }
29}
diff --git a/shared/models/users/two-factor-enable-result.model.ts b/shared/models/users/two-factor-enable-result.model.ts
deleted file mode 100644
index 1fc801f0a..000000000
--- a/shared/models/users/two-factor-enable-result.model.ts
+++ /dev/null
@@ -1,7 +0,0 @@
1export interface TwoFactorEnableResult {
2 otpRequest: {
3 requestToken: string
4 secret: string
5 uri: string
6 }
7}
diff --git a/shared/models/users/user-create-result.model.ts b/shared/models/users/user-create-result.model.ts
deleted file mode 100644
index 835b241ed..000000000
--- a/shared/models/users/user-create-result.model.ts
+++ /dev/null
@@ -1,7 +0,0 @@
1export interface UserCreateResult {
2 id: number
3
4 account: {
5 id: number
6 }
7}
diff --git a/shared/models/users/user-create.model.ts b/shared/models/users/user-create.model.ts
deleted file mode 100644
index ddc71dd59..000000000
--- a/shared/models/users/user-create.model.ts
+++ /dev/null
@@ -1,13 +0,0 @@
1import { UserRole } from './user-role'
2import { UserAdminFlag } from './user-flag.model'
3
4export interface UserCreate {
5 username: string
6 password: string
7 email: string
8 videoQuota: number
9 videoQuotaDaily: number
10 role: UserRole
11 adminFlags?: UserAdminFlag
12 channelName?: string
13}
diff --git a/shared/models/users/user-flag.model.ts b/shared/models/users/user-flag.model.ts
deleted file mode 100644
index b791a1263..000000000
--- a/shared/models/users/user-flag.model.ts
+++ /dev/null
@@ -1,4 +0,0 @@
1export const enum UserAdminFlag {
2 NONE = 0,
3 BYPASS_VIDEO_AUTO_BLACKLIST = 1 << 0
4}
diff --git a/shared/models/users/user-login.model.ts b/shared/models/users/user-login.model.ts
deleted file mode 100644
index 1e85ab30b..000000000
--- a/shared/models/users/user-login.model.ts
+++ /dev/null
@@ -1,5 +0,0 @@
1export interface UserLogin {
2 access_token: string
3 refresh_token: string
4 token_type: string
5}
diff --git a/shared/models/users/user-notification-setting.model.ts b/shared/models/users/user-notification-setting.model.ts
deleted file mode 100644
index 278a05e7a..000000000
--- a/shared/models/users/user-notification-setting.model.ts
+++ /dev/null
@@ -1,32 +0,0 @@
1export const enum UserNotificationSettingValue {
2 NONE = 0,
3 WEB = 1 << 0,
4 EMAIL = 1 << 1
5}
6
7export interface UserNotificationSetting {
8 abuseAsModerator: UserNotificationSettingValue
9 videoAutoBlacklistAsModerator: UserNotificationSettingValue
10 newUserRegistration: UserNotificationSettingValue
11
12 newVideoFromSubscription: UserNotificationSettingValue
13
14 blacklistOnMyVideo: UserNotificationSettingValue
15 myVideoPublished: UserNotificationSettingValue
16 myVideoImportFinished: UserNotificationSettingValue
17
18 commentMention: UserNotificationSettingValue
19 newCommentOnMyVideo: UserNotificationSettingValue
20
21 newFollow: UserNotificationSettingValue
22 newInstanceFollower: UserNotificationSettingValue
23 autoInstanceFollowing: UserNotificationSettingValue
24
25 abuseStateChange: UserNotificationSettingValue
26 abuseNewMessage: UserNotificationSettingValue
27
28 newPeerTubeVersion: UserNotificationSettingValue
29 newPluginVersion: UserNotificationSettingValue
30
31 myVideoStudioEditionFinished: UserNotificationSettingValue
32}
diff --git a/shared/models/users/user-notification.model.ts b/shared/models/users/user-notification.model.ts
deleted file mode 100644
index 294c921bd..000000000
--- a/shared/models/users/user-notification.model.ts
+++ /dev/null
@@ -1,138 +0,0 @@
1import { FollowState } from '../actors'
2import { AbuseState } from '../moderation'
3import { PluginType } from '../plugins'
4
5export const enum UserNotificationType {
6 NEW_VIDEO_FROM_SUBSCRIPTION = 1,
7 NEW_COMMENT_ON_MY_VIDEO = 2,
8 NEW_ABUSE_FOR_MODERATORS = 3,
9
10 BLACKLIST_ON_MY_VIDEO = 4,
11 UNBLACKLIST_ON_MY_VIDEO = 5,
12
13 MY_VIDEO_PUBLISHED = 6,
14
15 MY_VIDEO_IMPORT_SUCCESS = 7,
16 MY_VIDEO_IMPORT_ERROR = 8,
17
18 NEW_USER_REGISTRATION = 9,
19 NEW_FOLLOW = 10,
20 COMMENT_MENTION = 11,
21
22 VIDEO_AUTO_BLACKLIST_FOR_MODERATORS = 12,
23
24 NEW_INSTANCE_FOLLOWER = 13,
25
26 AUTO_INSTANCE_FOLLOWING = 14,
27
28 ABUSE_STATE_CHANGE = 15,
29
30 ABUSE_NEW_MESSAGE = 16,
31
32 NEW_PLUGIN_VERSION = 17,
33 NEW_PEERTUBE_VERSION = 18,
34
35 MY_VIDEO_STUDIO_EDITION_FINISHED = 19,
36
37 NEW_USER_REGISTRATION_REQUEST = 20
38}
39
40export interface VideoInfo {
41 id: number
42 uuid: string
43 shortUUID: string
44 name: string
45}
46
47export interface AvatarInfo {
48 width: number
49 path: string
50}
51
52export interface ActorInfo {
53 id: number
54 displayName: string
55 name: string
56 host: string
57
58 avatars: AvatarInfo[]
59 avatar: AvatarInfo
60}
61
62export interface UserNotification {
63 id: number
64 type: UserNotificationType
65 read: boolean
66
67 video?: VideoInfo & {
68 channel: ActorInfo
69 }
70
71 videoImport?: {
72 id: number
73 video?: VideoInfo
74 torrentName?: string
75 magnetUri?: string
76 targetUrl?: string
77 }
78
79 comment?: {
80 id: number
81 threadId: number
82 account: ActorInfo
83 video: VideoInfo
84 }
85
86 abuse?: {
87 id: number
88 state: AbuseState
89
90 video?: VideoInfo
91
92 comment?: {
93 threadId: number
94
95 video: VideoInfo
96 }
97
98 account?: ActorInfo
99 }
100
101 videoBlacklist?: {
102 id: number
103 video: VideoInfo
104 }
105
106 account?: ActorInfo
107
108 actorFollow?: {
109 id: number
110 follower: ActorInfo
111 state: FollowState
112
113 following: {
114 type: 'account' | 'channel' | 'instance'
115 name: string
116 displayName: string
117 host: string
118 }
119 }
120
121 plugin?: {
122 name: string
123 type: PluginType
124 latestVersion: string
125 }
126
127 peertube?: {
128 latestVersion: string
129 }
130
131 registration?: {
132 id: number
133 username: string
134 }
135
136 createdAt: string
137 updatedAt: string
138}
diff --git a/shared/models/users/user-refresh-token.model.ts b/shared/models/users/user-refresh-token.model.ts
deleted file mode 100644
index f528dd961..000000000
--- a/shared/models/users/user-refresh-token.model.ts
+++ /dev/null
@@ -1,4 +0,0 @@
1export interface UserRefreshToken {
2 access_token: string
3 refresh_token: string
4}
diff --git a/shared/models/users/user-right.enum.ts b/shared/models/users/user-right.enum.ts
deleted file mode 100644
index a5a770b75..000000000
--- a/shared/models/users/user-right.enum.ts
+++ /dev/null
@@ -1,51 +0,0 @@
1export const enum UserRight {
2 ALL = 0,
3
4 MANAGE_USERS = 1,
5
6 MANAGE_SERVER_FOLLOW = 2,
7
8 MANAGE_LOGS = 3,
9
10 MANAGE_DEBUG = 4,
11
12 MANAGE_SERVER_REDUNDANCY = 5,
13
14 MANAGE_ABUSES = 6,
15
16 MANAGE_JOBS = 7,
17
18 MANAGE_CONFIGURATION = 8,
19 MANAGE_INSTANCE_CUSTOM_PAGE = 9,
20
21 MANAGE_ACCOUNTS_BLOCKLIST = 10,
22 MANAGE_SERVERS_BLOCKLIST = 11,
23
24 MANAGE_VIDEO_BLACKLIST = 12,
25 MANAGE_ANY_VIDEO_CHANNEL = 13,
26
27 REMOVE_ANY_VIDEO = 14,
28 REMOVE_ANY_VIDEO_PLAYLIST = 15,
29 REMOVE_ANY_VIDEO_COMMENT = 16,
30
31 UPDATE_ANY_VIDEO = 17,
32 UPDATE_ANY_VIDEO_PLAYLIST = 18,
33
34 GET_ANY_LIVE = 19,
35 SEE_ALL_VIDEOS = 20,
36 SEE_ALL_COMMENTS = 21,
37 CHANGE_VIDEO_OWNERSHIP = 22,
38
39 MANAGE_PLUGINS = 23,
40
41 MANAGE_VIDEOS_REDUNDANCIES = 24,
42
43 MANAGE_VIDEO_FILES = 25,
44 RUN_VIDEO_TRANSCODING = 26,
45
46 MANAGE_VIDEO_IMPORTS = 27,
47
48 MANAGE_REGISTRATIONS = 28,
49
50 MANAGE_RUNNERS = 29
51}
diff --git a/shared/models/users/user-role.ts b/shared/models/users/user-role.ts
deleted file mode 100644
index 687a2aa0d..000000000
--- a/shared/models/users/user-role.ts
+++ /dev/null
@@ -1,6 +0,0 @@
1// Keep the order
2export const enum UserRole {
3 ADMINISTRATOR = 0,
4 MODERATOR = 1,
5 USER = 2
6}
diff --git a/shared/models/users/user-scoped-token.ts b/shared/models/users/user-scoped-token.ts
deleted file mode 100644
index f9d9b0a8b..000000000
--- a/shared/models/users/user-scoped-token.ts
+++ /dev/null
@@ -1,5 +0,0 @@
1export type ScopedTokenType = 'feedToken'
2
3export type ScopedToken = {
4 feedToken: string
5}
diff --git a/shared/models/users/user-update-me.model.ts b/shared/models/users/user-update-me.model.ts
deleted file mode 100644
index c1d5ffba4..000000000
--- a/shared/models/users/user-update-me.model.ts
+++ /dev/null
@@ -1,26 +0,0 @@
1import { NSFWPolicyType } from '../videos/nsfw-policy.type'
2
3export interface UserUpdateMe {
4 displayName?: string
5 description?: string
6 nsfwPolicy?: NSFWPolicyType
7
8 p2pEnabled?: boolean
9
10 autoPlayVideo?: boolean
11 autoPlayNextVideo?: boolean
12 autoPlayNextVideoPlaylist?: boolean
13 videosHistoryEnabled?: boolean
14 videoLanguages?: string[]
15
16 email?: string
17 emailPublic?: boolean
18 currentPassword?: string
19 password?: string
20
21 theme?: string
22
23 noInstanceConfigWarningModal?: boolean
24 noWelcomeModal?: boolean
25 noAccountSetupWarningModal?: boolean
26}
diff --git a/shared/models/users/user-update.model.ts b/shared/models/users/user-update.model.ts
deleted file mode 100644
index 158738545..000000000
--- a/shared/models/users/user-update.model.ts
+++ /dev/null
@@ -1,13 +0,0 @@
1import { UserRole } from './user-role'
2import { UserAdminFlag } from './user-flag.model'
3
4export interface UserUpdate {
5 password?: string
6 email?: string
7 emailVerified?: boolean
8 videoQuota?: number
9 videoQuotaDaily?: number
10 role?: UserRole
11 adminFlags?: UserAdminFlag
12 pluginAuth?: string
13}
diff --git a/shared/models/users/user-video-quota.model.ts b/shared/models/users/user-video-quota.model.ts
deleted file mode 100644
index a24871d71..000000000
--- a/shared/models/users/user-video-quota.model.ts
+++ /dev/null
@@ -1,4 +0,0 @@
1export interface UserVideoQuota {
2 videoQuotaUsed: number
3 videoQuotaUsedDaily: number
4}
diff --git a/shared/models/users/user.model.ts b/shared/models/users/user.model.ts
deleted file mode 100644
index 9de4118b4..000000000
--- a/shared/models/users/user.model.ts
+++ /dev/null
@@ -1,78 +0,0 @@
1import { Account } from '../actors'
2import { VideoChannel } from '../videos/channel/video-channel.model'
3import { UserRole } from './user-role'
4import { NSFWPolicyType } from '../videos/nsfw-policy.type'
5import { UserNotificationSetting } from './user-notification-setting.model'
6import { UserAdminFlag } from './user-flag.model'
7import { VideoPlaylistType } from '../videos/playlist/video-playlist-type.model'
8
9export interface User {
10 id: number
11 username: string
12 email: string
13 pendingEmail: string | null
14
15 emailVerified: boolean
16 emailPublic: boolean
17 nsfwPolicy: NSFWPolicyType
18
19 adminFlags?: UserAdminFlag
20
21 autoPlayVideo: boolean
22 autoPlayNextVideo: boolean
23 autoPlayNextVideoPlaylist: boolean
24
25 p2pEnabled: boolean
26
27 videosHistoryEnabled: boolean
28 videoLanguages: string[]
29
30 role: {
31 id: UserRole
32 label: string
33 }
34
35 videoQuota: number
36 videoQuotaDaily: number
37 videoQuotaUsed?: number
38 videoQuotaUsedDaily?: number
39
40 videosCount?: number
41
42 abusesCount?: number
43 abusesAcceptedCount?: number
44 abusesCreatedCount?: number
45
46 videoCommentsCount?: number
47
48 theme: string
49
50 account: Account
51 notificationSettings?: UserNotificationSetting
52 videoChannels?: VideoChannel[]
53
54 blocked: boolean
55 blockedReason?: string
56
57 noInstanceConfigWarningModal: boolean
58 noWelcomeModal: boolean
59 noAccountSetupWarningModal: boolean
60
61 createdAt: Date
62
63 pluginAuth: string | null
64
65 lastLoginDate: Date | null
66
67 twoFactorEnabled: boolean
68}
69
70export interface MyUserSpecialPlaylist {
71 id: number
72 name: string
73 type: VideoPlaylistType
74}
75
76export interface MyUser extends User {
77 specialPlaylists: MyUserSpecialPlaylist[]
78}