Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Add new feature modal info

Chocobozzz60f92d55de41
diff --git a/client/src/app/+admin/system/logs/logs.component.html b/client/src/app/+admin/system/logs/logs.component.html
index de227c542d..7fbdde2100 100644
--- a/client/src/app/+admin/system/logs/logs.component.html
+++ b/client/src/app/+admin/system/logs/logs.component.html
@@ -5,7 +5,9 @@
<div class="peertube-select-container">
<select id="log-type" [(ngModel)]="logType" (ngModelChange)="refresh()" class="form-control">
- <option *ngFor="let logTypeChoice of logTypeChoices" [value]="logTypeChoice.id">{{ logTypeChoice.label }}</option>
+ @for (logTypeChoice of logTypeChoices; track logTypeChoice) {
+ <option [value]="logTypeChoice.id">{{ logTypeChoice.label }}</option>
+ }
</select>
</div>
</div>
diff --git a/client/src/app/+my-library/+my-video-channels/edit/pages/video-channel-editors.component.scss b/client/src/app/+my-library/+my-video-channels/edit/pages/video-channel-editors.component.scss
index b6a704ca76..3a9c94c68e 100644
--- a/client/src/app/+my-library/+my-video-channels/edit/pages/video-channel-editors.component.scss
+++ b/client/src/app/+my-library/+my-video-channels/edit/pages/video-channel-editors.component.scss
@@ -41,5 +41,5 @@ my-action-dropdown {
}
.editor-explanation {
- color: pvar(--fg-300);
+ color: pvar(--fg-200);
}
diff --git a/client/src/app/+my-library/my-video-space.component.ts b/client/src/app/+my-library/my-video-space.component.ts
index 421e6a63bd..7e8d1c3e08 100644
--- a/client/src/app/+my-library/my-video-space.component.ts
+++ b/client/src/app/+my-library/my-video-space.component.ts
@@ -1,6 +1,7 @@
import { Component, OnInit, inject } from '@angular/core'
import { RouterOutlet } from '@angular/router'
import { ServerService } from '@app/core'
+import { NewFeatureInfoService } from '@app/modal/new-feature-info.service'
import { HorizontalMenuComponent, HorizontalMenuEntry } from '@app/shared/shared-main/menu/horizontal-menu.component'
import { HTMLServerConfig } from '@peertube/peertube-models'
@@ -10,6 +11,7 @@ import { HTMLServerConfig } from '@peertube/peertube-models'
})
export class MyVideoSpaceComponent implements OnInit {
private serverService = inject(ServerService)
+ private newFeatureInfoService = inject(NewFeatureInfoService)
menuEntries: HorizontalMenuEntry[] = []
@@ -19,6 +21,8 @@ export class MyVideoSpaceComponent implements OnInit {
this.serverConfig = this.serverService.getHTMLConfig()
this.buildMenu()
+
+ this.newFeatureInfoService.showChannelCollaboration()
}
private buildMenu () {
diff --git a/client/src/app/core/users/user.model.ts b/client/src/app/core/users/user.model.ts
index 58cffb9e77..1865f0cfc9 100644
--- a/client/src/app/core/users/user.model.ts
+++ b/client/src/app/core/users/user.model.ts
@@ -78,6 +78,8 @@ export class User implements UserServerModel {
language: string
+ newFeaturesInfoRead: number
+
createdAt: Date
constructor (hash: Partial<UserServerModel>) {
diff --git a/client/src/app/core/users/user.service.ts b/client/src/app/core/users/user.service.ts
index a37779ee54..77f711011b 100644
--- a/client/src/app/core/users/user.service.ts
+++ b/client/src/app/core/users/user.service.ts
@@ -2,7 +2,14 @@ import { HttpClient, HttpParams } from '@angular/common/http'
import { inject, Injectable, LOCALE_ID } from '@angular/core'
import { AuthService } from '@app/core/auth'
import { arrayify, getCompleteLocale } from '@peertube/peertube-core-utils'
-import { ActorImage, User as UserServerModel, UserUpdateMe, UserVideoQuota } from '@peertube/peertube-models'
+import {
+ ActorImage,
+ UserNewFeatureInfoRead,
+ UserNewFeatureInfoType,
+ User as UserServerModel,
+ UserUpdateMe,
+ UserVideoQuota
+} from '@peertube/peertube-models'
import { from, Observable, of } from 'rxjs'
import { catchError, concatMap, first, map, shareReplay, toArray } from 'rxjs/operators'
import { environment } from '../../../environments/environment'
@@ -208,4 +215,14 @@ export class UserService {
return this.authHttp.post(url, body)
.pipe(catchError(err => this.restExtractor.handleError(err)))
}
+
+ // ---------------------------------------------------------------------------
+
+ markNewFeatureInfoAsRead (feature: UserNewFeatureInfoType) {
+ const url = UserService.BASE_USERS_URL + 'me/new-feature-info/read'
+ const body: UserNewFeatureInfoRead = { feature }
+
+ return this.authHttp.post(url, body)
+ .pipe(catchError(err => this.restExtractor.handleError(err)))
+ }
}
diff --git a/client/src/app/modal/new-feature-info-modal.component.html b/client/src/app/modal/new-feature-info-modal.component.html
new file mode 100644
index 0000000000..1c00b6e140
--- /dev/null
+++ b/client/src/app/modal/new-feature-info-modal.component.html
@@ -0,0 +1,14 @@
+<div class="modal-body">
+ <div class="global-icon-container">
+ <my-global-icon [iconName]="iconName"></my-global-icon>
+ </div>
+
+ <h2>{{ title }}</h2>
+
+ <div class="content" [innerHtml]="html"></div>
+
+ <input
+ type="button" role="button" i18n-value value="Got it" class="peertube-button primary-button"
+ (click)="activeModal.close()" (key.enter)="activeModal.close()"
+ >
+</div>
diff --git a/client/src/app/modal/new-feature-info-modal.component.scss b/client/src/app/modal/new-feature-info-modal.component.scss
new file mode 100644
index 0000000000..c849ad8143
--- /dev/null
+++ b/client/src/app/modal/new-feature-info-modal.component.scss
@@ -0,0 +1,37 @@
+@use "_variables" as *;
+@use "_mixins" as *;
+
+h2 {
+ color: pvar(--fg-350);
+ font-weight: $font-bold;
+
+ @include margin-bottom(2rem);
+ @include font-size(38px);
+}
+
+.modal-body {
+ text-align: center;
+}
+
+.content {
+ color: pvar(--fg-200);
+
+ @include margin-bottom(2.5rem);
+}
+
+.global-icon-container {
+ border-radius: 24px;
+ background: pvar(--bg);
+ padding: 2rem;
+ box-shadow: 12px 0 24px rgba(0, 0, 0, 0.12);
+ transform: rotate(-10deg);
+ display: inline-block;
+ position: relative;
+ top: -2.5rem;
+}
+
+my-global-icon {
+ color: pvar(--bg-secondary-450);
+
+ @include global-icon-size(80px);
+}
diff --git a/client/src/app/modal/new-feature-info-modal.component.ts b/client/src/app/modal/new-feature-info-modal.component.ts
new file mode 100644
index 0000000000..3e730d2ca2
--- /dev/null
+++ b/client/src/app/modal/new-feature-info-modal.component.ts
@@ -0,0 +1,18 @@
+import { Component, inject } from '@angular/core'
+import { FormsModule } from '@angular/forms'
+import { GlobalIconComponent, GlobalIconName } from '@app/shared/shared-icons/global-icon.component'
+import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
+
+@Component({
+ selector: 'my-new-feature-info-modal',
+ templateUrl: './new-feature-info-modal.component.html',
+ styleUrls: [ './new-feature-info-modal.component.scss' ],
+ imports: [ GlobalIconComponent, FormsModule ]
+})
+export class NewFeatureInfoModalComponent {
+ activeModal = inject(NgbActiveModal)
+
+ title: string
+ iconName: GlobalIconName
+ html: string
+}
diff --git a/client/src/app/modal/new-feature-info.service.ts b/client/src/app/modal/new-feature-info.service.ts
new file mode 100644
index 0000000000..2e143b36a2
--- /dev/null
+++ b/client/src/app/modal/new-feature-info.service.ts
@@ -0,0 +1,44 @@
+import { Injectable, inject } from '@angular/core'
+import { AuthService, Notifier, ServerService, UserService } from '@app/core'
+import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
+import { UserNewFeatureInfo } from '@peertube/peertube-models'
+import { NewFeatureInfoModalComponent } from './new-feature-info-modal.component'
+
+@Injectable({ providedIn: 'root' })
+export class NewFeatureInfoService {
+ private auth = inject(AuthService)
+ private modalService = inject(NgbModal)
+ private serverService = inject(ServerService)
+ private userService = inject(UserService)
+ private notifier = inject(Notifier)
+
+ showChannelCollaboration () {
+ this.auth.userInformationLoaded.subscribe(() => {
+ const config = this.serverService.getHTMLConfig()
+ if (config.client.newFeaturesInfo !== true) return
+
+ const user = this.auth.getUser()
+ if (user.newFeaturesInfoRead & UserNewFeatureInfo.CHANNEL_COLLABORATION) return
+
+ const instanceName = this.serverService.getHTMLConfig().instance.name
+
+ const modalRef = this.modalService.open(NewFeatureInfoModalComponent, { size: 'lg', centered: true })
+ const component = modalRef.componentInstance as NewFeatureInfoModalComponent
+
+ component.title = $localize`Collaborations on channels are coming to ${instanceName}`
+ component.iconName = 'channel'
+ component.html = $localize`You can now <strong>invite other users</strong> to collaborate on your channel`
+
+ modalRef.result.finally(() => {
+ this.userService.markNewFeatureInfoAsRead(UserNewFeatureInfo.CHANNEL_COLLABORATION)
+ .subscribe({
+ next: () => {
+ // empty
+ },
+
+ error: err => this.notifier.error(err.message)
+ })
+ })
+ })
+ }
+}
diff --git a/config/default.yaml b/config/default.yaml
index cfb45cc0bd..9afd432798 100644
--- a/config/default.yaml
+++ b/config/default.yaml
@@ -1093,6 +1093,8 @@ search:
# PeerTube client/interface configuration
client:
+ # Display modals to inform users of new features after a PeerTube update
+ new_features_info: true
header:
# Hide the instance name in the header on desktop
diff --git a/config/production.yaml.example b/config/production.yaml.example
index 8b5cf6761a..a757654bb8 100644
--- a/config/production.yaml.example
+++ b/config/production.yaml.example
@@ -816,6 +816,9 @@ import:
# Set a custom video import timeout to not block import queue
timeout: '2 hours'
+ # Number of attempts a user or the channel sync process can do to import a video if an error occurs during the import process
+ max_attempts: 3
+
# Classic HTTP or all sites supported by youtube-dl https://rg3.github.io/youtube-dl/supportedsites.html
http:
# We recommend to use a HTTP proxy if you enable HTTP import to prevent private URL access from this server
@@ -1100,6 +1103,8 @@ search:
# PeerTube client/interface configuration
client:
+ # Display modals to inform users of new features after a PeerTube update
+ new_features_info: true
header:
# Hide the instance name in the header on desktop
diff --git a/packages/models/src/server/server-config.model.ts b/packages/models/src/server/server-config.model.ts
index 0d649075e6..76dbbdb5b3 100644
--- a/packages/models/src/server/server-config.model.ts
+++ b/packages/models/src/server/server-config.model.ts
@@ -37,6 +37,8 @@ export interface ServerConfig {
serverCommit?: string
client: {
+ newFeaturesInfo: boolean
+
header: {
hideInstanceName: boolean
}
diff --git a/packages/models/src/users/index.ts b/packages/models/src/users/index.ts
index 601e475f5c..9159d66001 100644
--- a/packages/models/src/users/index.ts
+++ b/packages/models/src/users/index.ts
@@ -4,6 +4,8 @@ export * from './user-create-result.model.js'
export * from './user-create.model.js'
export * from './user-flag.model.js'
export * from './user-login.model.js'
+export * from './user-new-feature-info-read.model.js'
+export * from './user-new-feature-info.type.js'
export * from './user-notification-data.model.js'
export * from './user-notification-list-query.model.js'
export * from './user-notification-setting.model.js'
diff --git a/packages/models/src/users/user-new-feature-info-read.model.ts b/packages/models/src/users/user-new-feature-info-read.model.ts
new file mode 100644
index 0000000000..2e498b6123
--- /dev/null
+++ b/packages/models/src/users/user-new-feature-info-read.model.ts
@@ -0,0 +1,5 @@
+import { UserNewFeatureInfoType } from './user-new-feature-info.type.js'
+
+export interface UserNewFeatureInfoRead {
+ feature: UserNewFeatureInfoType
+}
diff --git a/packages/models/src/users/user-new-feature-info.type.ts b/packages/models/src/users/user-new-feature-info.type.ts
new file mode 100644
index 0000000000..c87a5e7767
--- /dev/null
+++ b/packages/models/src/users/user-new-feature-info.type.ts
@@ -0,0 +1,6 @@
+export const UserNewFeatureInfo = {
+ NONE: 0,
+ CHANNEL_COLLABORATION: 1 << 0
+} as const
+
+export type UserNewFeatureInfoType = typeof UserNewFeatureInfo[keyof typeof UserNewFeatureInfo]
diff --git a/packages/models/src/users/user.model.ts b/packages/models/src/users/user.model.ts
index c3978e9c78..4e40d7b426 100644
--- a/packages/models/src/users/user.model.ts
+++ b/packages/models/src/users/user.model.ts
@@ -77,6 +77,8 @@ export interface User {
lastLoginDate: Date | null
twoFactorEnabled: boolean
+
+ newFeaturesInfoRead: number
}
export interface MyUserSpecialPlaylist {
diff --git a/packages/server-commands/src/users/users-command.ts b/packages/server-commands/src/users/users-command.ts
index 73bab7c9de..884669eb62 100644
--- a/packages/server-commands/src/users/users-command.ts
+++ b/packages/server-commands/src/users/users-command.ts
@@ -7,6 +7,7 @@ import {
User,
UserAdminFlagType,
UserCreateResult,
+ UserNewFeatureInfoType,
UserRole,
UserRoleType,
UserUpdate,
@@ -455,4 +456,24 @@ export class UsersCommand extends AbstractCommand {
defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
})
}
+
+ // ---------------------------------------------------------------------------
+
+ readNewFeatureInfo (
+ options: OverrideCommandOptions & {
+ feature: UserNewFeatureInfoType
+ }
+ ) {
+ const { feature } = options
+ const path = '/api/v1/users/me/new-feature-info/read'
+
+ return this.postBodyRequest({
+ ...options,
+
+ path,
+ fields: { feature },
+ implicitToken: true,
+ defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204
+ })
+ }
}
diff --git a/packages/tests/src/api/check-params/user-me.ts b/packages/tests/src/api/check-params/user-me.ts
index 3030dc7fee..737806d7ae 100644
--- a/packages/tests/src/api/check-params/user-me.ts
+++ b/packages/tests/src/api/check-params/user-me.ts
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import { HttpStatusCode, UserRole, VideoCreateResult } from '@peertube/peertube-models'
+import { HttpStatusCode, UserNewFeatureInfo, UserRole, VideoCreateResult } from '@peertube/peertube-models'
import { buildAbsoluteFixturePath } from '@peertube/peertube-node-utils'
import {
cleanupTests,
@@ -574,6 +574,27 @@ describe('Test my user API validators', function () {
})
})
+ describe('Whe updating new features info read', function () {
+ it('Should fail without token', async function () {
+ await server.users.readNewFeatureInfo({
+ token: null,
+ feature: UserNewFeatureInfo.CHANNEL_COLLABORATION,
+ expectedStatus: HttpStatusCode.UNAUTHORIZED_401
+ })
+ })
+
+ it('Should fail with bad feature', async function () {
+ await server.users.readNewFeatureInfo({
+ feature: 'toto' as any,
+ expectedStatus: HttpStatusCode.BAD_REQUEST_400
+ })
+ })
+
+ it('Should succeed with correct params', async function () {
+ await server.users.readNewFeatureInfo({ feature: UserNewFeatureInfo.CHANNEL_COLLABORATION })
+ })
+ })
+
after(async function () {
await MockSmtpServer.Instance.kill()
diff --git a/packages/tests/src/api/users/users.ts b/packages/tests/src/api/users/users.ts
index 594ab5584a..cfbbdd54b9 100644
--- a/packages/tests/src/api/users/users.ts
+++ b/packages/tests/src/api/users/users.ts
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
-import { AbuseState, HttpStatusCode, UserAdminFlag, UserRole, VideoPlaylistType } from '@peertube/peertube-models'
+import { AbuseState, HttpStatusCode, UserAdminFlag, UserNewFeatureInfo, UserRole, VideoPlaylistType } from '@peertube/peertube-models'
import { cleanupTests, createSingleServer, PeerTubeServer, setAccessTokensToServers } from '@peertube/peertube-server-commands'
import { testAvatarSize } from '@tests/shared/checks.js'
import { expect } from 'chai'
@@ -586,6 +586,33 @@ describe('Test users', function () {
})
})
+ describe('New features info read', function () {
+ let userToken: string
+
+ it('Should create a new user with all new features info as read', async function () {
+ userToken = await server.users.generateUserAndToken('user_features')
+
+ const { newFeaturesInfoRead } = await server.users.getMyInfo({ token: userToken })
+ expect(newFeaturesInfoRead).to.equal(UserNewFeatureInfo.CHANNEL_COLLABORATION)
+ })
+
+ it('Should update new features info read', async function () {
+ {
+ await server.users.readNewFeatureInfo({ feature: 0, token: userToken })
+
+ const { newFeaturesInfoRead } = await server.users.getMyInfo({ token: userToken })
+ expect(newFeaturesInfoRead).to.equal(UserNewFeatureInfo.CHANNEL_COLLABORATION)
+ }
+
+ {
+ await server.users.readNewFeatureInfo({ feature: 2, token: userToken })
+
+ const { newFeaturesInfoRead } = await server.users.getMyInfo({ token: userToken })
+ expect(newFeaturesInfoRead).to.equal(3)
+ }
+ })
+ })
+
after(async function () {
await cleanupTests([ server ])
})
diff --git a/server/core/controllers/api/users/me.ts b/server/core/controllers/api/users/me.ts
index ebefad6ff1..d038c5ac67 100644
--- a/server/core/controllers/api/users/me.ts
+++ b/server/core/controllers/api/users/me.ts
@@ -3,6 +3,7 @@ import {
ActorImageType,
UserVideoRate as FormattedUserVideoRate,
HttpStatusCode,
+ UserNewFeatureInfoRead,
UserUpdateMe,
UserVideoQuota,
VideoInclude
@@ -42,7 +43,8 @@ import {
listCommentsOnUserVideosValidator,
listMyVideosValidator,
videoImportsSortValidator,
- videosSortValidator
+ videosSortValidator,
+ usersNewFeatureInfoReadValidator
} from '../../../middlewares/validators/index.js'
import { AccountVideoRateModel } from '../../../models/account/account-video-rate.js'
import { AccountModel } from '../../../models/account/account.js'
@@ -124,6 +126,13 @@ meRouter.delete(
asyncRetryTransactionMiddleware(deleteMyAvatar)
)
+meRouter.post(
+ '/me/new-feature-info/read',
+ authenticate,
+ usersNewFeatureInfoReadValidator,
+ asyncMiddleware(usersNewFeatureInfoRead)
+)
+
// ---------------------------------------------------------------------------
export {
@@ -362,3 +371,13 @@ async function deleteMyAvatar (req: express.Request, res: express.Response) {
return res.json({ avatars: [] })
}
+
+async function usersNewFeatureInfoRead (req: express.Request, res: express.Response) {
+ const user = res.locals.oauth.token.user
+ const body: UserNewFeatureInfoRead = req.body
+
+ user.newFeaturesInfoRead |= body.feature
+ await user.save()
+
+ return res.status(HttpStatusCode.NO_CONTENT_204).end()
+}
diff --git a/server/core/helpers/custom-validators/users.ts b/server/core/helpers/custom-validators/users.ts
index e609e2f2be..1cc69fc98c 100644
--- a/server/core/helpers/custom-validators/users.ts
+++ b/server/core/helpers/custom-validators/users.ts
@@ -102,3 +102,7 @@ export function isUserRoleValid (value: any) {
validator.default.isInt('' + value) &&
[ UserRole.ADMINISTRATOR, UserRole.MODERATOR, UserRole.USER ].includes(value)
}
+
+export function isUserFeatureInfo (value: string) {
+ return exists(value) && validator.default.isInt(value + '')
+}
diff --git a/server/core/initializers/config.ts b/server/core/initializers/config.ts
index 66a53bd66a..1797593cf7 100644
--- a/server/core/initializers/config.ts
+++ b/server/core/initializers/config.ts
@@ -79,6 +79,9 @@ const CONFIG = {
},
CLIENT: {
+ get NEW_FEATURES_INFO () {
+ return config.get<boolean>('client.new_features_info')
+ },
HEADER: {
get HIDE_INSTANCE_NAME () {
return config.get<boolean>('client.header.hide_instance_name')
diff --git a/server/core/initializers/constants.ts b/server/core/initializers/constants.ts
index 07ba1f15ea..ecd0f702ef 100644
--- a/server/core/initializers/constants.ts
+++ b/server/core/initializers/constants.ts
@@ -58,7 +58,7 @@ import { CONFIG, registerConfigChangedHandler } from './config.js'
// ---------------------------------------------------------------------------
-export const LAST_MIGRATION_VERSION = 960
+export const LAST_MIGRATION_VERSION = 965
// ---------------------------------------------------------------------------
diff --git a/server/core/initializers/migrations/0965-user-new-feature-info.ts b/server/core/initializers/migrations/0965-user-new-feature-info.ts
new file mode 100644
index 0000000000..f5d35b3cf5
--- /dev/null
+++ b/server/core/initializers/migrations/0965-user-new-feature-info.ts
@@ -0,0 +1,28 @@
+import * as Sequelize from 'sequelize'
+
+async function up (utils: {
+ transaction: Sequelize.Transaction
+ queryInterface: Sequelize.QueryInterface
+ sequelize: Sequelize.Sequelize
+}): Promise<void> {
+ await utils.queryInterface.addColumn('user', 'newFeaturesInfoRead', {
+ type: Sequelize.INTEGER,
+ allowNull: true
+ }, { transaction: utils.transaction })
+
+ await utils.sequelize.query('UPDATE "user" SET "newFeaturesInfoRead" = 0', { transaction: utils.transaction })
+
+ await utils.queryInterface.changeColumn('user', 'newFeaturesInfoRead', {
+ type: Sequelize.INTEGER,
+ allowNull: false
+ }, { transaction: utils.transaction })
+}
+
+function down (options) {
+ throw new Error('Not implemented.')
+}
+
+export {
+ down,
+ up
+}
diff --git a/server/core/lib/server-config-manager.ts b/server/core/lib/server-config-manager.ts
index 74eb97cef5..745b21db5e 100644
--- a/server/core/lib/server-config-manager.ts
+++ b/server/core/lib/server-config-manager.ts
@@ -61,6 +61,7 @@ class ServerConfigManager {
return {
client: {
+ newFeaturesInfo: CONFIG.CLIENT.NEW_FEATURES_INFO,
header: {
hideInstanceName: CONFIG.CLIENT.HEADER.HIDE_INSTANCE_NAME
},
diff --git a/server/core/lib/user.ts b/server/core/lib/user.ts
index 09f533fa86..03329e15f3 100644
--- a/server/core/lib/user.ts
+++ b/server/core/lib/user.ts
@@ -2,6 +2,7 @@ import {
ActivityPubActorType,
UserAdminFlag,
UserAdminFlagType,
+ UserNewFeatureInfo,
UserNotificationSetting,
UserNotificationSettingValue,
UserRole,
@@ -74,7 +75,9 @@ export function buildUser (options: {
videoQuota,
videoQuotaDaily,
- pluginAuth
+ pluginAuth,
+
+ newFeaturesInfoRead: Object.values(UserNewFeatureInfo).reduce((all, curr) => all | curr, 0)
})
}
diff --git a/server/core/middlewares/validators/users/users.ts b/server/core/middlewares/validators/users/users.ts
index 91be9ffb2b..7a5181e9f3 100644
--- a/server/core/middlewares/validators/users/users.ts
+++ b/server/core/middlewares/validators/users/users.ts
@@ -17,6 +17,7 @@ import {
isUserDescriptionValid,
isUserDisplayNameValid,
isUserEmailPublicValid,
+ isUserFeatureInfo,
isUserLanguage,
isUserNoModal,
isUserNSFWPolicyValid,
@@ -489,6 +490,17 @@ export const userAutocompleteValidator = [
.not().isEmpty()
]
+export const usersNewFeatureInfoReadValidator = [
+ body('feature')
+ .custom(isUserFeatureInfo),
+
+ (req: express.Request, res: express.Response, next: express.NextFunction) => {
+ if (areValidationErrors(req, res)) return
+
+ return next()
+ }
+]
+
// ---------------------------------------------------------------------------
// Private
// ---------------------------------------------------------------------------
diff --git a/server/core/models/user/user.ts b/server/core/models/user/user.ts
index 26e1176d36..b762d64b9a 100644
--- a/server/core/models/user/user.ts
+++ b/server/core/models/user/user.ts
@@ -10,6 +10,7 @@ import {
VideoPlaylistType,
type NSFWPolicyType,
type UserAdminFlagType,
+ type UserNewFeatureInfoType,
type UserRoleType
} from '@peertube/peertube-models'
import { isNSFWFlagsValid } from '@server/helpers/custom-validators/videos.js'
@@ -410,6 +411,10 @@ export class UserModel extends SequelizeModel<UserModel> {
@Column
declare noAccountSetupWarningModal: boolean
+ @AllowNull(false)
+ @Column
+ declare newFeaturesInfoRead: UserNewFeatureInfoType
+
@AllowNull(true)
@Default(null)
@Column
@@ -1087,7 +1092,9 @@ export class UserModel extends SequelizeModel<UserModel> {
lastLoginDate: this.lastLoginDate,
- twoFactorEnabled: !!this.otpSecret
+ twoFactorEnabled: !!this.otpSecret,
+
+ newFeaturesInfoRead: this.newFeaturesInfoRead
}
if (parameters.withAdminFlags) {
diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yaml
index 34efce7230..f9e8a113cd 100644
--- a/support/doc/api/openapi.yaml
+++ b/support/doc/api/openapi.yaml
@@ -2580,6 +2580,29 @@ paths:
'204':
description: successful operation
+ /api/v1/users/me/new-feature-info/read:
+ post:
+ tags:
+ - My User
+ summary: Mark feature info as read
+ description: "**PeerTube >= v8.0.0"
+ security:
+ - OAuth2:
+ - user
+ requestBody:
+ content:
+ application/json:
+ schema:
+ type: object
+ properties:
+ feature:
+ $ref: '#/components/schemas/NewFeatureInfoType'
+ required:
+ - feature
+ responses:
+ '204':
+ description: successful operation
+
/api/v1/users/me/history/videos:
get:
summary: List watched videos history
@@ -11113,6 +11136,10 @@ components:
type: boolean
description: Whether the user has enabled two-factor authentication or not
+ newFeaturesInfoRead:
+ type: number
+ description: New features information the user has read
+
UserWithStats:
allOf:
- $ref: '#/components/schemas/User'
@@ -11832,6 +11859,16 @@ components:
- `21` NEW_LIVE_FROM_SUBSCRIPTION
- `22` MY_VIDEO_TRANSCRIPTION_GENERATED
+
+ NewFeatureInfoType:
+ type: integer
+ enum:
+ - 1
+ description: >
+ Represent a new feature that can be displayed to inform users. One of the following values:
+
+ - `1` CHANNEL_COLLABORATION
+
Notification:
properties:
id: