diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2019-12-11 20:20:42 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-12-13 09:13:43 +0100 |
commit | bee29df8a9ba3090be3daa8ff806dd9a26d7a5cf (patch) | |
tree | 9e9f6d509ed24f799f82667109498b9561474a4d /server | |
parent | d816f3a063febac1cad09ab3a32e5f0d29353627 (diff) | |
download | PeerTube-bee29df8a9ba3090be3daa8ff806dd9a26d7a5cf.tar.gz PeerTube-bee29df8a9ba3090be3daa8ff806dd9a26d7a5cf.tar.zst PeerTube-bee29df8a9ba3090be3daa8ff806dd9a26d7a5cf.zip |
autoplay next video support for playlists
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/api/users/me.ts | 1 | ||||
-rw-r--r-- | server/helpers/custom-validators/users.ts | 5 | ||||
-rw-r--r-- | server/initializers/constants.ts | 2 | ||||
-rw-r--r-- | server/initializers/migrations/0460-user-playlist-autoplay.ts | 27 | ||||
-rw-r--r-- | server/models/account/user.ts | 8 |
5 files changed, 42 insertions, 1 deletions
diff --git a/server/controllers/api/users/me.ts b/server/controllers/api/users/me.ts index cfc346c35..ba976ab03 100644 --- a/server/controllers/api/users/me.ts +++ b/server/controllers/api/users/me.ts | |||
@@ -176,6 +176,7 @@ async function updateMe (req: express.Request, res: express.Response) { | |||
176 | if (body.webTorrentEnabled !== undefined) user.webTorrentEnabled = body.webTorrentEnabled | 176 | if (body.webTorrentEnabled !== undefined) user.webTorrentEnabled = body.webTorrentEnabled |
177 | if (body.autoPlayVideo !== undefined) user.autoPlayVideo = body.autoPlayVideo | 177 | if (body.autoPlayVideo !== undefined) user.autoPlayVideo = body.autoPlayVideo |
178 | if (body.autoPlayNextVideo !== undefined) user.autoPlayNextVideo = body.autoPlayNextVideo | 178 | if (body.autoPlayNextVideo !== undefined) user.autoPlayNextVideo = body.autoPlayNextVideo |
179 | if (body.autoPlayNextVideoPlaylist !== undefined) user.autoPlayNextVideoPlaylist = body.autoPlayNextVideoPlaylist | ||
179 | if (body.videosHistoryEnabled !== undefined) user.videosHistoryEnabled = body.videosHistoryEnabled | 180 | if (body.videosHistoryEnabled !== undefined) user.videosHistoryEnabled = body.videosHistoryEnabled |
180 | if (body.videoLanguages !== undefined) user.videoLanguages = body.videoLanguages | 181 | if (body.videoLanguages !== undefined) user.videoLanguages = body.videoLanguages |
181 | if (body.theme !== undefined) user.theme = body.theme | 182 | if (body.theme !== undefined) user.theme = body.theme |
diff --git a/server/helpers/custom-validators/users.ts b/server/helpers/custom-validators/users.ts index 16a95f120..008916a04 100644 --- a/server/helpers/custom-validators/users.ts +++ b/server/helpers/custom-validators/users.ts | |||
@@ -69,6 +69,10 @@ function isUserAutoPlayNextVideoValid (value: any) { | |||
69 | return isBooleanValid(value) | 69 | return isBooleanValid(value) |
70 | } | 70 | } |
71 | 71 | ||
72 | function isUserAutoPlayNextVideoPlaylistValid (value: any) { | ||
73 | return isBooleanValid(value) | ||
74 | } | ||
75 | |||
72 | function isNoInstanceConfigWarningModal (value: any) { | 76 | function isNoInstanceConfigWarningModal (value: any) { |
73 | return isBooleanValid(value) | 77 | return isBooleanValid(value) |
74 | } | 78 | } |
@@ -111,6 +115,7 @@ export { | |||
111 | isUserWebTorrentEnabledValid, | 115 | isUserWebTorrentEnabledValid, |
112 | isUserAutoPlayVideoValid, | 116 | isUserAutoPlayVideoValid, |
113 | isUserAutoPlayNextVideoValid, | 117 | isUserAutoPlayNextVideoValid, |
118 | isUserAutoPlayNextVideoPlaylistValid, | ||
114 | isUserDisplayNameValid, | 119 | isUserDisplayNameValid, |
115 | isUserDescriptionValid, | 120 | isUserDescriptionValid, |
116 | isNoInstanceConfigWarningModal, | 121 | isNoInstanceConfigWarningModal, |
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index d0cf4d5de..00238f7a1 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts | |||
@@ -14,7 +14,7 @@ import { CONFIG, registerConfigChangedHandler } from './config' | |||
14 | 14 | ||
15 | // --------------------------------------------------------------------------- | 15 | // --------------------------------------------------------------------------- |
16 | 16 | ||
17 | const LAST_MIGRATION_VERSION = 455 | 17 | const LAST_MIGRATION_VERSION = 460 |
18 | 18 | ||
19 | // --------------------------------------------------------------------------- | 19 | // --------------------------------------------------------------------------- |
20 | 20 | ||
diff --git a/server/initializers/migrations/0460-user-playlist-autoplay.ts b/server/initializers/migrations/0460-user-playlist-autoplay.ts new file mode 100644 index 000000000..3067ac1a4 --- /dev/null +++ b/server/initializers/migrations/0460-user-playlist-autoplay.ts | |||
@@ -0,0 +1,27 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | async function up (utils: { | ||
4 | transaction: Sequelize.Transaction, | ||
5 | queryInterface: Sequelize.QueryInterface, | ||
6 | sequelize: Sequelize.Sequelize, | ||
7 | db: any | ||
8 | }): Promise<void> { | ||
9 | { | ||
10 | const data = { | ||
11 | type: Sequelize.BOOLEAN, | ||
12 | allowNull: false, | ||
13 | defaultValue: true | ||
14 | } | ||
15 | |||
16 | await utils.queryInterface.addColumn('user', 'autoPlayNextVideoPlaylist', data) | ||
17 | } | ||
18 | } | ||
19 | |||
20 | function down (options) { | ||
21 | throw new Error('Not implemented.') | ||
22 | } | ||
23 | |||
24 | export { | ||
25 | up, | ||
26 | down | ||
27 | } | ||
diff --git a/server/models/account/user.ts b/server/models/account/user.ts index 522ea3310..b2cd25bc3 100644 --- a/server/models/account/user.ts +++ b/server/models/account/user.ts | |||
@@ -26,6 +26,7 @@ import { | |||
26 | isUserAdminFlagsValid, | 26 | isUserAdminFlagsValid, |
27 | isUserAutoPlayVideoValid, | 27 | isUserAutoPlayVideoValid, |
28 | isUserAutoPlayNextVideoValid, | 28 | isUserAutoPlayNextVideoValid, |
29 | isUserAutoPlayNextVideoPlaylistValid, | ||
29 | isUserBlockedReasonValid, | 30 | isUserBlockedReasonValid, |
30 | isUserBlockedValid, | 31 | isUserBlockedValid, |
31 | isUserEmailVerifiedValid, | 32 | isUserEmailVerifiedValid, |
@@ -167,6 +168,12 @@ export class UserModel extends Model<UserModel> { | |||
167 | @Column | 168 | @Column |
168 | autoPlayNextVideo: boolean | 169 | autoPlayNextVideo: boolean |
169 | 170 | ||
171 | @AllowNull(false) | ||
172 | @Default(true) | ||
173 | @Is('UserAutoPlayNextVideoPlaylist', value => throwIfNotValid(value, isUserAutoPlayNextVideoPlaylistValid, 'auto play next video for playlists boolean')) | ||
174 | @Column | ||
175 | autoPlayNextVideoPlaylist: boolean | ||
176 | |||
170 | @AllowNull(true) | 177 | @AllowNull(true) |
171 | @Default(null) | 178 | @Default(null) |
172 | @Is('UserVideoLanguages', value => throwIfNotValid(value, isUserVideoLanguages, 'video languages')) | 179 | @Is('UserVideoLanguages', value => throwIfNotValid(value, isUserVideoLanguages, 'video languages')) |
@@ -619,6 +626,7 @@ export class UserModel extends Model<UserModel> { | |||
619 | videosHistoryEnabled: this.videosHistoryEnabled, | 626 | videosHistoryEnabled: this.videosHistoryEnabled, |
620 | autoPlayVideo: this.autoPlayVideo, | 627 | autoPlayVideo: this.autoPlayVideo, |
621 | autoPlayNextVideo: this.autoPlayNextVideo, | 628 | autoPlayNextVideo: this.autoPlayNextVideo, |
629 | autoPlayNextVideoPlaylist: this.autoPlayNextVideoPlaylist, | ||
622 | videoLanguages: this.videoLanguages, | 630 | videoLanguages: this.videoLanguages, |
623 | 631 | ||
624 | role: this.role, | 632 | role: this.role, |