ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix last commit
Chocobozzz2cebd7970145
diff --git a/server/helpers/custom-validators/videos.ts b/server/helpers/custom-validators/videos.tsindex 70904af0c7..338c96582e 100644--- a/server/helpers/custom-validators/videos.ts+++ b/server/helpers/custom-validators/videos.ts@@ -110,7 +110,7 @@ function isScheduleVideoUpdatePrivacyValid (value: number) {)}-function isVideoFileInfoHashValid (value: string) {+function isVideoFileInfoHashValid (value: string | null | undefined) {return exists(value) && validator.isLength(value, VIDEOS_CONSTRAINTS_FIELDS.INFO_HASH)}@@ -158,7 +158,7 @@ async function isVideoExist (id: string, res: Response) {video = await VideoModel.loadByUUIDAndPopulateAccountAndServerAndTags(id)}- if (video && video !== null) {+ if (video === null) {res.status(404).json({ error: 'Video not found' }).end()@@ -173,7 +173,7 @@ async function isVideoExist (id: string, res: Response) {async function isVideoChannelOfAccountExist (channelId: number, user: UserModel, res: Response) {if (user.hasRight(UserRight.UPDATE_ANY_VIDEO) === true) {const videoChannel = await VideoChannelModel.loadAndPopulateAccount(channelId)- if (videoChannel && videoChannel !== null) {+ if (videoChannel === null) {res.status(400).json({ error: 'Unknown video video channel on this instance.' }).end()@@ -186,7 +186,7 @@ async function isVideoChannelOfAccountExist (channelId: number, user: UserModel,}const videoChannel = await VideoChannelModel.loadByIdAndAccount(channelId, user.Account.id)- if (videoChannel && videoChannel !== null) {+ if (videoChannel === null) {res.status(400).json({ error: 'Unknown video video channel for this account.' }).end()diff --git a/server/helpers/utils.ts b/server/helpers/utils.tsindex 7ff1556e3c..cfb4275703 100644--- a/server/helpers/utils.ts+++ b/server/helpers/utils.ts@@ -144,7 +144,8 @@ let serverActor: ActorModelasync function getServerActor () {if (serverActor === undefined) {const application = await ApplicationModel.load()- if (!application) throw Error('Could not application.')+ if (!application) throw Error('Could not load Application from database.')+serverActor = application.Account.Actor}diff --git a/server/initializers/database.ts b/server/initializers/database.tsindex d95e34bce5..1a9ce5a61d 100644--- a/server/initializers/database.ts+++ b/server/initializers/database.ts@@ -125,10 +125,11 @@ async function checkPostgresExtensions () {}async function createFunctions () {- const query = `CREATE OR REPLACE FUNCTION immutable_unaccent(varchar)- RETURNS text AS $$- SELECT unaccent($1)- $$ LANGUAGE sql IMMUTABLE;`+ const query = `CREATE OR REPLACE FUNCTION immutable_unaccent(text)+ RETURNS text AS+$func$+SELECT public.unaccent('public.unaccent', $1::text)+$func$ LANGUAGE sql IMMUTABLE;`return sequelizeTypescript.query(query, { raw: true })}diff --git a/server/initializers/migrations/0055-video-uuid.ts b/server/initializers/migrations/0055-video-uuid.tsindex 6db25f1938..e0f9040807 100644--- a/server/initializers/migrations/0055-video-uuid.ts+++ b/server/initializers/migrations/0055-video-uuid.ts@@ -1,5 +1,6 @@import * as Sequelize from 'sequelize'import * as Promise from 'bluebird'+import { Migration } from '../../models/migrations'function up (utils: {transaction: Sequelize.Transaction,@@ -12,7 +13,7 @@ function up (utils: {type: Sequelize.UUID,defaultValue: Sequelize.UUIDV4,allowNull: true- }+ } as Migration.UUIDreturn q.addColumn('Videos', 'uuid', dataUUID).then(() => {@@ -24,7 +25,7 @@ function up (utils: {return utils.sequelize.query(query)}).then(() => {- dataUUID.defaultValue = null // FIXME:default value cannot be null if string+ dataUUID.defaultValue = nullreturn q.changeColumn('Videos', 'uuid', dataUUID)})diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.tsindex 2944cb7295..b6f57e0abe 100644--- a/server/lib/activitypub/videos.ts+++ b/server/lib/activitypub/videos.ts@@ -38,7 +38,7 @@ async function federateVideoIfNeeded (video: VideoModel, isNewVideo: boolean, tr}) as VideoCaptionModel[]}- if (isNewVideo === true) {+ if (isNewVideo) {// Now we'll add the video's meta data to our followersawait sendCreateVideo(video, transaction)await shareVideoByServerAndChannel(video, transaction)@@ -153,9 +153,7 @@ function videoFileActivityUrlToDBAttributes (videoCreated: VideoModel, videoObjeif (!magnet) throw new Error('Cannot find associated magnet uri for file ' + fileUrl.href)const parsed = magnetUtil.decode(magnet.href)- if (!parsed ||- (parsed.infoHash &&- (isVideoFileInfoHashValid(parsed.infoHash) === false))) {+ if (!parsed || isVideoFileInfoHashValid(parsed.infoHash) === false) {throw new Error('Cannot parse magnet URI ' + magnet.href)}diff --git a/server/lib/redis.ts b/server/lib/redis.tsindex e547537c33..941f7d5574 100644--- a/server/lib/redis.ts+++ b/server/lib/redis.ts@@ -6,8 +6,8 @@ import { CONFIG, USER_PASSWORD_RESET_LIFETIME, VIDEO_VIEW_LIFETIME } from '../intype CachedRoute = {body: string,- contentType: string- statusCode: string+ contentType?: string+ statusCode?: string}class Redis {diff --git a/server/models/migrations/index.ts b/server/models/migrations/index.tsindex c2b31b05eb..24badb1668 100644--- a/server/models/migrations/index.ts+++ b/server/models/migrations/index.ts@@ -16,6 +16,10 @@ declare namespace Migration {interface BigInteger extends Sequelize.DefineAttributeColumnOptions {defaultValue: Sequelize.DataTypeBigInt | number | null}++ interface UUID extends Sequelize.DefineAttributeColumnOptions {+ defaultValue: Sequelize.DataTypeUUIDv4 | null+ }}export {diff --git a/server/models/utils.ts b/server/models/utils.tsindex 393f8f0363..99e1465832 100644--- a/server/models/utils.ts+++ b/server/models/utils.ts@@ -76,7 +76,7 @@ export {// ---------------------------------------------------------------------------function searchTrigramNormalizeValue (value: string) {- return Sequelize.fn('lower', Sequelize.fn('unaccent', value))+ return Sequelize.fn('lower', Sequelize.fn('immutable_unaccent', value))}function searchTrigramNormalizeCol (col: string) {diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.tsindex 03122dc031..f84c1880c6 100644--- a/server/models/video/video-comment.ts+++ b/server/models/video/video-comment.ts@@ -417,7 +417,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> {toActivityPubObject (threadParentComments: VideoCommentModel[]): VideoCommentObject {let inReplyTo: string// New thread, so in AS we reply to the video- if ((this.inReplyToCommentId !== null) || (this.InReplyToVideoComment !== null)) {+ if (this.inReplyToCommentId === null) {inReplyTo = this.Video.url} else {inReplyTo = this.InReplyToVideoComment.url