aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/initializers
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-01-19 11:56:04 +0100
committerChocobozzz <me@florianbigard.com>2023-01-19 13:54:52 +0100
commitf008e9f3f34ed1724afd5e071c39ed931741acbc (patch)
treed6d338714d4dc051e8a7ffcfa707f6d4e9e44c0c /server/initializers
parent5bdfa604f102a5e51b5152457cd1a16d79177e26 (diff)
downloadPeerTube-f008e9f3f34ed1724afd5e071c39ed931741acbc.tar.gz
PeerTube-f008e9f3f34ed1724afd5e071c39ed931741acbc.tar.zst
PeerTube-f008e9f3f34ed1724afd5e071c39ed931741acbc.zip
Add missing url unique index in local video viewer
Diffstat (limited to 'server/initializers')
-rw-r--r--server/initializers/constants.ts20
-rw-r--r--server/initializers/migrations/0755-unique-viewer-url.ts27
2 files changed, 30 insertions, 17 deletions
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index 2ef3da2e7..54380f7bf 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -6,7 +6,6 @@ import { randomInt, root } from '@shared/core-utils'
6import { 6import {
7 AbuseState, 7 AbuseState,
8 JobType, 8 JobType,
9 UserRegistrationState,
10 VideoChannelSyncState, 9 VideoChannelSyncState,
11 VideoImportState, 10 VideoImportState,
12 VideoPrivacy, 11 VideoPrivacy,
@@ -26,7 +25,7 @@ import { CONFIG, registerConfigChangedHandler } from './config'
26 25
27// --------------------------------------------------------------------------- 26// ---------------------------------------------------------------------------
28 27
29const LAST_MIGRATION_VERSION = 750 28const LAST_MIGRATION_VERSION = 755
30 29
31// --------------------------------------------------------------------------- 30// ---------------------------------------------------------------------------
32 31
@@ -79,8 +78,6 @@ const SORTABLE_COLUMNS = {
79 ACCOUNT_FOLLOWERS: [ 'createdAt' ], 78 ACCOUNT_FOLLOWERS: [ 'createdAt' ],
80 CHANNEL_FOLLOWERS: [ 'createdAt' ], 79 CHANNEL_FOLLOWERS: [ 'createdAt' ],
81 80
82 USER_REGISTRATIONS: [ 'createdAt', 'state' ],
83
84 VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'originallyPublishedAt', 'views', 'likes', 'trending', 'hot', 'best' ], 81 VIDEOS: [ 'name', 'duration', 'createdAt', 'publishedAt', 'originallyPublishedAt', 'views', 'likes', 'trending', 'hot', 'best' ],
85 82
86 // Don't forget to update peertube-search-index with the same values 83 // Don't forget to update peertube-search-index with the same values
@@ -293,10 +290,6 @@ const CONSTRAINTS_FIELDS = {
293 ABUSE_MESSAGES: { 290 ABUSE_MESSAGES: {
294 MESSAGE: { min: 2, max: 3000 } // Length 291 MESSAGE: { min: 2, max: 3000 } // Length
295 }, 292 },
296 USER_REGISTRATIONS: {
297 REASON_MESSAGE: { min: 2, max: 3000 }, // Length
298 MODERATOR_MESSAGE: { min: 2, max: 3000 } // Length
299 },
300 VIDEO_BLACKLIST: { 293 VIDEO_BLACKLIST: {
301 REASON: { min: 2, max: 300 } // Length 294 REASON: { min: 2, max: 300 } // Length
302 }, 295 },
@@ -523,12 +516,6 @@ const ABUSE_STATES: { [ id in AbuseState ]: string } = {
523 [AbuseState.ACCEPTED]: 'Accepted' 516 [AbuseState.ACCEPTED]: 'Accepted'
524} 517}
525 518
526const USER_REGISTRATION_STATES: { [ id in UserRegistrationState ]: string } = {
527 [UserRegistrationState.PENDING]: 'Pending',
528 [UserRegistrationState.REJECTED]: 'Rejected',
529 [UserRegistrationState.ACCEPTED]: 'Accepted'
530}
531
532const VIDEO_PLAYLIST_PRIVACIES: { [ id in VideoPlaylistPrivacy ]: string } = { 519const VIDEO_PLAYLIST_PRIVACIES: { [ id in VideoPlaylistPrivacy ]: string } = {
533 [VideoPlaylistPrivacy.PUBLIC]: 'Public', 520 [VideoPlaylistPrivacy.PUBLIC]: 'Public',
534 [VideoPlaylistPrivacy.UNLISTED]: 'Unlisted', 521 [VideoPlaylistPrivacy.UNLISTED]: 'Unlisted',
@@ -673,7 +660,7 @@ const USER_PASSWORD_CREATE_LIFETIME = 60000 * 60 * 24 * 7 // 7 days
673 660
674const TWO_FACTOR_AUTH_REQUEST_TOKEN_LIFETIME = 60000 * 10 // 10 minutes 661const TWO_FACTOR_AUTH_REQUEST_TOKEN_LIFETIME = 60000 * 10 // 10 minutes
675 662
676const EMAIL_VERIFY_LIFETIME = 60000 * 60 // 60 minutes 663const USER_EMAIL_VERIFY_LIFETIME = 60000 * 60 // 60 minutes
677 664
678const NSFW_POLICY_TYPES: { [ id: string ]: NSFWPolicyType } = { 665const NSFW_POLICY_TYPES: { [ id: string ]: NSFWPolicyType } = {
679 DO_NOT_LIST: 'do_not_list', 666 DO_NOT_LIST: 'do_not_list',
@@ -1082,14 +1069,13 @@ export {
1082 VIDEO_TRANSCODING_FPS, 1069 VIDEO_TRANSCODING_FPS,
1083 FFMPEG_NICE, 1070 FFMPEG_NICE,
1084 ABUSE_STATES, 1071 ABUSE_STATES,
1085 USER_REGISTRATION_STATES,
1086 LRU_CACHE, 1072 LRU_CACHE,
1087 REQUEST_TIMEOUTS, 1073 REQUEST_TIMEOUTS,
1088 MAX_LOCAL_VIEWER_WATCH_SECTIONS, 1074 MAX_LOCAL_VIEWER_WATCH_SECTIONS,
1089 USER_PASSWORD_RESET_LIFETIME, 1075 USER_PASSWORD_RESET_LIFETIME,
1090 USER_PASSWORD_CREATE_LIFETIME, 1076 USER_PASSWORD_CREATE_LIFETIME,
1091 MEMOIZE_TTL, 1077 MEMOIZE_TTL,
1092 EMAIL_VERIFY_LIFETIME, 1078 USER_EMAIL_VERIFY_LIFETIME,
1093 OVERVIEWS, 1079 OVERVIEWS,
1094 SCHEDULER_INTERVALS_MS, 1080 SCHEDULER_INTERVALS_MS,
1095 REPEAT_JOBS, 1081 REPEAT_JOBS,
diff --git a/server/initializers/migrations/0755-unique-viewer-url.ts b/server/initializers/migrations/0755-unique-viewer-url.ts
new file mode 100644
index 000000000..b3dff9258
--- /dev/null
+++ b/server/initializers/migrations/0755-unique-viewer-url.ts
@@ -0,0 +1,27 @@
1import * as Sequelize from 'sequelize'
2
3async function up (utils: {
4 transaction: Sequelize.Transaction
5 queryInterface: Sequelize.QueryInterface
6 sequelize: Sequelize.Sequelize
7 db: any
8}): Promise<void> {
9 const { transaction } = utils
10
11 const query = 'DELETE FROM "localVideoViewer" t1 ' +
12 'USING (SELECT MIN(id) as id, "url" FROM "localVideoViewer" GROUP BY "url" HAVING COUNT(*) > 1) t2 ' +
13 'WHERE t1."url" = t2."url" AND t1.id <> t2.id'
14
15 await utils.sequelize.query(query, { transaction })
16}
17
18async function down (utils: {
19 queryInterface: Sequelize.QueryInterface
20 transaction: Sequelize.Transaction
21}) {
22}
23
24export {
25 up,
26 down
27}