From fdfc10d13c8ad6456f44b0d51f1d86e5a5adf74b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 16 May 2024 16:07:17 +0200 Subject: [PATCH 1/6] Fix left/right logical properties --- client/src/sass/include/_mixins.scss | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/client/src/sass/include/_mixins.scss b/client/src/sass/include/_mixins.scss index 83cf6e220..dbe29a2dd 100644 --- a/client/src/sass/include/_mixins.scss +++ b/client/src/sass/include/_mixins.scss @@ -885,21 +885,23 @@ */ @mixin right ($value) { - right: $value; - @supports (inset-inline-end: $value) { inset-inline-end: $value; - right: unset; + } + + @supports not (inset-inline-end: $value) { + right: $value; } } @mixin left ($value) { - left: $value; - @supports (inset-inline-start: $value) { inset-inline-start: $value; - left: unset; + } + + @supports not (inset-inline-start: $value) { + left: $value; } } From 9ee1f7b57c1d10c9e7646d6188295659478775a0 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 17 May 2024 11:07:30 +0200 Subject: [PATCH 2/6] Don't mark as ready already read notifications --- server/core/models/user/user-notification.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/core/models/user/user-notification.ts b/server/core/models/user/user-notification.ts index 2765dbf2a..28a5bb894 100644 --- a/server/core/models/user/user-notification.ts +++ b/server/core/models/user/user-notification.ts @@ -290,7 +290,8 @@ export class UserNotificationModel extends SequelizeModel userId, id: { [Op.in]: notificationIds - } + }, + read: false } } @@ -298,7 +299,7 @@ export class UserNotificationModel extends SequelizeModel } static markAllAsRead (userId: number) { - const query = { where: { userId } } + const query = { where: { userId, read: false } } return UserNotificationModel.update({ read: true }, query) } From cb88f25ffa333a9dd931dde359882c85c264b42b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 17 May 2024 11:12:11 +0200 Subject: [PATCH 3/6] Don't count deleted comments for stats --- packages/tests/src/api/server/stats.ts | 11 +++++++---- server/core/models/video/video-comment.ts | 19 ++++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/packages/tests/src/api/server/stats.ts b/packages/tests/src/api/server/stats.ts index 3afe2156f..df65990e7 100644 --- a/packages/tests/src/api/server/stats.ts +++ b/packages/tests/src/api/server/stats.ts @@ -34,11 +34,14 @@ describe('Test stats (excluding redundancy)', function () { const { account } = await servers[0].users.create({ username: user.username, password: user.password }) userAccountId = account.id - const { uuid } = await servers[0].videos.upload({ attributes: { fixture: 'video_short.webm' } }) + { + const { uuid } = await servers[0].videos.quickUpload({ name: 'video', fixture: 'video_short.webm' }) + await servers[0].views.simulateView({ id: uuid }) - await servers[0].comments.createThread({ videoId: uuid, text: 'comment' }) - - await servers[0].views.simulateView({ id: uuid }) + await servers[0].comments.createThread({ videoId: uuid, text: 'comment' }) + const toDelete = await servers[0].comments.createThread({ videoId: uuid, text: 'deleted' }) + await servers[0].comments.delete({ videoId: uuid, commentId: toDelete.id }) + } // Wait the video views repeatable job await wait(8000) diff --git a/server/core/models/video/video-comment.ts b/server/core/models/video/video-comment.ts index b73dfedea..d41d7974b 100644 --- a/server/core/models/video/video-comment.ts +++ b/server/core/models/video/video-comment.ts @@ -1,3 +1,8 @@ +import { pick } from '@peertube/peertube-core-utils' +import { ActivityTagObject, ActivityTombstoneObject, VideoComment, VideoCommentAdmin, VideoCommentObject } from '@peertube/peertube-models' +import { extractMentions } from '@server/helpers/mentions.js' +import { getServerActor } from '@server/models/application/application.js' +import { MAccount, MAccountId, MUserAccountId } from '@server/types/models/index.js' import { Op, Order, QueryTypes, Sequelize, Transaction } from 'sequelize' import { AllowNull, @@ -11,17 +16,12 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { pick } from '@peertube/peertube-core-utils' -import { ActivityTagObject, ActivityTombstoneObject, VideoComment, VideoCommentAdmin, VideoCommentObject } from '@peertube/peertube-models' -import { extractMentions } from '@server/helpers/mentions.js' -import { getServerActor } from '@server/models/application/application.js' -import { MAccount, MAccountId, MUserAccountId } from '@server/types/models/index.js' import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc.js' import { CONSTRAINTS_FIELDS, USER_EXPORT_MAX_ITEMS } from '../../initializers/constants.js' import { MComment, - MCommentAdminFormattable, MCommentAP, + MCommentAdminFormattable, MCommentExport, MCommentFormattable, MCommentId, @@ -480,7 +480,12 @@ export class VideoCommentModel extends SequelizeModel { } static async getStats () { + const where = { + deletedAt: null + } + const totalLocalVideoComments = await VideoCommentModel.count({ + where, include: [ { model: AccountModel.unscoped(), @@ -497,7 +502,7 @@ export class VideoCommentModel extends SequelizeModel { } ] }) - const totalVideoComments = await VideoCommentModel.count() + const totalVideoComments = await VideoCommentModel.count({ where }) return { totalLocalVideoComments, From 74b62dcb850a1315585e64f8a8639a390d1826e2 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 17 May 2024 11:18:43 +0200 Subject: [PATCH 4/6] Remove invalid db value checker fileUrl can use localhost in some specific cases for example --- server/core/models/actor/actor-image.ts | 7 ++-- .../models/redundancy/video-redundancy.ts | 33 +++++++++---------- .../models/video/video-streaming-playlist.ts | 3 -- 3 files changed, 18 insertions(+), 25 deletions(-) diff --git a/server/core/models/actor/actor-image.ts b/server/core/models/actor/actor-image.ts index 782578ca1..d7e7b163e 100644 --- a/server/core/models/actor/actor-image.ts +++ b/server/core/models/actor/actor-image.ts @@ -10,15 +10,13 @@ import { Column, CreatedAt, Default, - ForeignKey, - Is, Table, + ForeignKey, Table, UpdatedAt } from 'sequelize-typescript' -import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc.js' import { logger } from '../../helpers/logger.js' import { CONFIG } from '../../initializers/config.js' import { LAZY_STATIC_PATHS, MIMETYPES, WEBSERVER } from '../../initializers/constants.js' -import { SequelizeModel, buildSQLAttributes, throwIfNotValid } from '../shared/index.js' +import { SequelizeModel, buildSQLAttributes } from '../shared/index.js' import { ActorModel } from './actor.js' @Table({ @@ -51,7 +49,6 @@ export class ActorImageModel extends SequelizeModel { width: number @AllowNull(true) - @Is('ActorImageFileUrl', value => throwIfNotValid(value, isActivityPubUrlValid, 'fileUrl', true)) @Column fileUrl: string diff --git a/server/core/models/redundancy/video-redundancy.ts b/server/core/models/redundancy/video-redundancy.ts index 3e44caf5f..aa0126cd5 100644 --- a/server/core/models/redundancy/video-redundancy.ts +++ b/server/core/models/redundancy/video-redundancy.ts @@ -1,3 +1,18 @@ +import { + ActivityVideoUrlObject, + CacheFileObject, + FileRedundancyInformation, + StreamingPlaylistRedundancyInformation, + VideoPrivacy, + VideoRedundanciesTarget, + VideoRedundancy, + VideoRedundancyStrategy, + VideoRedundancyStrategyWithManual +} from '@peertube/peertube-models' +import { isTestInstance } from '@peertube/peertube-node-utils' +import { getVideoFileMimeType } from '@server/lib/video-file.js' +import { getServerActor } from '@server/models/application/application.js' +import { MActor, MVideoForRedundancyAPI, MVideoRedundancy, MVideoRedundancyAP, MVideoRedundancyVideo } from '@server/types/models/index.js' import sample from 'lodash-es/sample.js' import { literal, Op, QueryTypes, Transaction, WhereOptions } from 'sequelize' import { @@ -12,21 +27,7 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { - ActivityVideoUrlObject, - CacheFileObject, - FileRedundancyInformation, - StreamingPlaylistRedundancyInformation, - VideoPrivacy, - VideoRedundanciesTarget, - VideoRedundancy, - VideoRedundancyStrategy, - VideoRedundancyStrategyWithManual -} from '@peertube/peertube-models' -import { isTestInstance } from '@peertube/peertube-node-utils' -import { getServerActor } from '@server/models/application/application.js' -import { MActor, MVideoForRedundancyAPI, MVideoRedundancy, MVideoRedundancyAP, MVideoRedundancyVideo } from '@server/types/models/index.js' -import { isActivityPubUrlValid, isUrlValid } from '../../helpers/custom-validators/activitypub/misc.js' +import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc.js' import { logger } from '../../helpers/logger.js' import { CONFIG } from '../../initializers/config.js' import { CONSTRAINTS_FIELDS } from '../../initializers/constants.js' @@ -38,7 +39,6 @@ import { VideoChannelModel } from '../video/video-channel.js' import { VideoFileModel } from '../video/video-file.js' import { VideoStreamingPlaylistModel } from '../video/video-streaming-playlist.js' import { VideoModel } from '../video/video.js' -import { getVideoFileMimeType } from '@server/lib/video-file.js' export enum ScopeNames { WITH_VIDEO = 'WITH_VIDEO' @@ -102,7 +102,6 @@ export class VideoRedundancyModel extends SequelizeModel { expiresOn: Date @AllowNull(false) - @Is('VideoRedundancyFileUrl', value => throwIfNotValid(value, isUrlValid, 'fileUrl')) @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEOS_REDUNDANCY.URL.max)) fileUrl: string diff --git a/server/core/models/video/video-streaming-playlist.ts b/server/core/models/video/video-streaming-playlist.ts index 4f4cfbee8..c5d107e23 100644 --- a/server/core/models/video/video-streaming-playlist.ts +++ b/server/core/models/video/video-streaming-playlist.ts @@ -26,7 +26,6 @@ import { Is, Table, UpdatedAt } from 'sequelize-typescript' -import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc.js' import { isArrayOf } from '../../helpers/custom-validators/misc.js' import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos.js' import { @@ -73,7 +72,6 @@ export class VideoStreamingPlaylistModel extends SequelizeModel throwIfNotValid(value, isActivityPubUrlValid, 'playlist url', true)) @Column(DataType.STRING(CONSTRAINTS_FIELDS.VIDEOS.URL.max)) playlistUrl: string @@ -91,7 +89,6 @@ export class VideoStreamingPlaylistModel extends SequelizeModel throwIfNotValid(value, isActivityPubUrlValid, 'segments sha256 url', true)) @Column segmentsSha256Url: string From dd77235f2c2368f841376a042b9ceec66640524d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 17 May 2024 11:26:28 +0200 Subject: [PATCH 5/6] Fix missing link in welcome user modal --- client/src/app/modal/account-setup-warning-modal.component.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/src/app/modal/account-setup-warning-modal.component.ts b/client/src/app/modal/account-setup-warning-modal.component.ts index 41d2cd4d1..90bc6b75e 100644 --- a/client/src/app/modal/account-setup-warning-modal.component.ts +++ b/client/src/app/modal/account-setup-warning-modal.component.ts @@ -1,6 +1,7 @@ import { CommonModule } from '@angular/common' import { Component, ElementRef, ViewChild } from '@angular/core' import { FormsModule } from '@angular/forms' +import { RouterLink } from '@angular/router' import { Notifier, ServerService, User, UserService } from '@app/core' import { PeertubeCheckboxComponent } from '@app/shared/shared-forms/peertube-checkbox.component' import { GlobalIconComponent } from '@app/shared/shared-icons/global-icon.component' @@ -13,7 +14,7 @@ import { peertubeLocalStorage } from '@root-helpers/peertube-web-storage' templateUrl: './account-setup-warning-modal.component.html', styleUrls: [ './account-setup-warning-modal.component.scss' ], standalone: true, - imports: [ CommonModule, GlobalIconComponent, PeertubeCheckboxComponent, FormsModule ] + imports: [ CommonModule, GlobalIconComponent, PeertubeCheckboxComponent, FormsModule, RouterLink ] }) export class AccountSetupWarningModalComponent { @ViewChild('modal', { static: true }) modal: ElementRef From 3b1646f27d4817647c4d773a062527b0005e8e1c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 17 May 2024 11:30:48 +0200 Subject: [PATCH 6/6] Fix modal close button position --- client/src/sass/bootstrap.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/sass/bootstrap.scss b/client/src/sass/bootstrap.scss index 8c4729966..e9aa63dca 100644 --- a/client/src/sass/bootstrap.scss +++ b/client/src/sass/bootstrap.scss @@ -390,7 +390,7 @@ body { // RTL compatibility // --------------------------------------------------------------------------- -.modal .modal-header .modal-title { +:root[dir=rtl] .modal .modal-header .modal-title { margin-inline-end: auto; margin-right: unset; }