Fix last commit
This commit is contained in:
parent
c1e791bad0
commit
2cebd79701
|
@ -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()
|
||||
|
|
|
@ -144,7 +144,8 @@ let serverActor: ActorModel
|
|||
async 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
|
||||
}
|
||||
|
||||
|
|
|
@ -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 })
|
||||
}
|
||||
|
|
|
@ -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.UUID
|
||||
|
||||
return 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 = null
|
||||
|
||||
return q.changeColumn('Videos', 'uuid', dataUUID)
|
||||
})
|
||||
|
|
|
@ -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 followers
|
||||
await sendCreateVideo(video, transaction)
|
||||
await shareVideoByServerAndChannel(video, transaction)
|
||||
|
@ -153,9 +153,7 @@ function videoFileActivityUrlToDBAttributes (videoCreated: VideoModel, videoObje
|
|||
if (!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)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ import { CONFIG, USER_PASSWORD_RESET_LIFETIME, VIDEO_VIEW_LIFETIME } from '../in
|
|||
|
||||
type CachedRoute = {
|
||||
body: string,
|
||||
contentType: string
|
||||
statusCode: string
|
||||
contentType?: string
|
||||
statusCode?: string
|
||||
}
|
||||
|
||||
class Redis {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue