aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/client.ts8
-rw-r--r--server/lib/activitypub/actor.ts4
-rw-r--r--server/lib/activitypub/process/process-follow.ts4
-rw-r--r--server/models/video/video.ts52
4 files changed, 32 insertions, 36 deletions
diff --git a/server/controllers/client.ts b/server/controllers/client.ts
index dc3ff18fc..56685f102 100644
--- a/server/controllers/client.ts
+++ b/server/controllers/client.ts
@@ -2,10 +2,11 @@ import * as express from 'express'
2import { join } from 'path' 2import { join } from 'path'
3import { root } from '../helpers/core-utils' 3import { root } from '../helpers/core-utils'
4import { ACCEPT_HEADERS, STATIC_MAX_AGE } from '../initializers/constants' 4import { ACCEPT_HEADERS, STATIC_MAX_AGE } from '../initializers/constants'
5import { asyncMiddleware } from '../middlewares' 5import { asyncMiddleware, embedCSP } from '../middlewares'
6import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '../../shared/models/i18n/i18n' 6import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '../../shared/models/i18n/i18n'
7import { ClientHtml } from '../lib/client-html' 7import { ClientHtml } from '../lib/client-html'
8import { logger } from '../helpers/logger' 8import { logger } from '../helpers/logger'
9import { CONFIG } from '@server/initializers/config'
9 10
10const clientsRouter = express.Router() 11const clientsRouter = express.Router()
11 12
@@ -19,8 +20,13 @@ clientsRouter.use('/videos/watch/:id', asyncMiddleware(generateWatchHtmlPage))
19clientsRouter.use('/accounts/:nameWithHost', asyncMiddleware(generateAccountHtmlPage)) 20clientsRouter.use('/accounts/:nameWithHost', asyncMiddleware(generateAccountHtmlPage))
20clientsRouter.use('/video-channels/:nameWithHost', asyncMiddleware(generateVideoChannelHtmlPage)) 21clientsRouter.use('/video-channels/:nameWithHost', asyncMiddleware(generateVideoChannelHtmlPage))
21 22
23const embedCSPMiddleware = CONFIG.CSP.ENABLED
24 ? embedCSP
25 : (req: express.Request, res: express.Response, next: express.NextFunction) => next()
26
22clientsRouter.use( 27clientsRouter.use(
23 '/videos/embed', 28 '/videos/embed',
29 embedCSPMiddleware,
24 (req: express.Request, res: express.Response) => { 30 (req: express.Request, res: express.Response) => {
25 res.removeHeader('X-Frame-Options') 31 res.removeHeader('X-Frame-Options')
26 res.sendFile(embedPath) 32 res.sendFile(embedPath)
diff --git a/server/lib/activitypub/actor.ts b/server/lib/activitypub/actor.ts
index f802658cf..0b21de0ca 100644
--- a/server/lib/activitypub/actor.ts
+++ b/server/lib/activitypub/actor.ts
@@ -176,8 +176,8 @@ async function updateActorAvatarInstance (actor: MActorDefault, info: AvatarInfo
176 if (!info.name) return actor 176 if (!info.name) return actor
177 177
178 if (actor.Avatar) { 178 if (actor.Avatar) {
179 // Don't update the avatar if the filename did not change 179 // Don't update the avatar if the file URL did not change
180 if (actor.Avatar.fileUrl === info.fileUrl) return actor 180 if (info.fileUrl && actor.Avatar.fileUrl === info.fileUrl) return actor
181 181
182 try { 182 try {
183 await actor.Avatar.destroy({ transaction: t }) 183 await actor.Avatar.destroy({ transaction: t })
diff --git a/server/lib/activitypub/process/process-follow.ts b/server/lib/activitypub/process/process-follow.ts
index 85f22d654..db7fb8568 100644
--- a/server/lib/activitypub/process/process-follow.ts
+++ b/server/lib/activitypub/process/process-follow.ts
@@ -59,7 +59,9 @@ async function processFollow (byActor: MActorSignature, targetActorURL: string)
59 transaction: t 59 transaction: t
60 }) 60 })
61 61
62 if (actorFollow.state !== 'accepted' && CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL === false) { 62 // Set the follow as accepted if the remote actor follows a channel or account
63 // Or if the instance automatically accepts followers
64 if (actorFollow.state !== 'accepted' && (isFollowingInstance === false || CONFIG.FOLLOWERS.INSTANCE.MANUAL_APPROVAL === false)) {
63 actorFollow.state = 'accepted' 65 actorFollow.state = 'accepted'
64 await actorFollow.save({ transaction: t }) 66 await actorFollow.save({ transaction: t })
65 } 67 }
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index eacffe186..a91a7663d 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -136,8 +136,7 @@ import {
136 MVideoThumbnailBlacklist, 136 MVideoThumbnailBlacklist,
137 MVideoWithAllFiles, 137 MVideoWithAllFiles,
138 MVideoWithFile, 138 MVideoWithFile,
139 MVideoWithRights, 139 MVideoWithRights
140 MStreamingPlaylistFiles
141} from '../../typings/models' 140} from '../../typings/models'
142import { MVideoFile, MVideoFileStreamingPlaylistVideo } from '../../typings/models/video/video-file' 141import { MVideoFile, MVideoFileStreamingPlaylistVideo } from '../../typings/models/video/video-file'
143import { MThumbnail } from '../../typings/models/video/thumbnail' 142import { MThumbnail } from '../../typings/models/video/thumbnail'
@@ -437,42 +436,31 @@ export type AvailableForListIDsOptions = {
437 } 436 }
438 437
439 if (options.followerActorId) { 438 if (options.followerActorId) {
440 let localVideosReq: WhereOptions = {} 439 let localVideosReq = ''
441 if (options.includeLocalVideos === true) { 440 if (options.includeLocalVideos === true) {
442 localVideosReq = { remote: false } 441 localVideosReq = ' UNION ALL SELECT "video"."id" FROM "video" WHERE remote IS FALSE'
443 } 442 }
444 443
445 // Force actorId to be a number to avoid SQL injections 444 // Force actorId to be a number to avoid SQL injections
446 const actorIdNumber = parseInt(options.followerActorId.toString(), 10) 445 const actorIdNumber = parseInt(options.followerActorId.toString(), 10)
447 whereAnd.push({ 446 whereAnd.push({
448 [Op.or]: [ 447 id: {
449 { 448 [Op.in]: Sequelize.literal(
450 id: { 449 '(' +
451 [ Op.in ]: Sequelize.literal( 450 'SELECT "videoShare"."videoId" AS "id" FROM "videoShare" ' +
452 '(' + 451 'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = "videoShare"."actorId" ' +
453 'SELECT "videoShare"."videoId" AS "id" FROM "videoShare" ' + 452 'WHERE "actorFollow"."actorId" = ' + actorIdNumber +
454 'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = "videoShare"."actorId" ' + 453 ' UNION ALL ' +
455 'WHERE "actorFollow"."actorId" = ' + actorIdNumber + 454 'SELECT "video"."id" AS "id" FROM "video" ' +
456 ')' 455 'INNER JOIN "videoChannel" ON "videoChannel"."id" = "video"."channelId" ' +
457 ) 456 'INNER JOIN "account" ON "account"."id" = "videoChannel"."accountId" ' +
458 } 457 'INNER JOIN "actor" ON "account"."actorId" = "actor"."id" ' +
459 }, 458 'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = "actor"."id" ' +
460 { 459 'WHERE "actorFollow"."actorId" = ' + actorIdNumber +
461 id: { 460 localVideosReq +
462 [ Op.in ]: Sequelize.literal( 461 ')'
463 '(' + 462 )
464 'SELECT "video"."id" AS "id" FROM "video" ' + 463 }
465 'INNER JOIN "videoChannel" ON "videoChannel"."id" = "video"."channelId" ' +
466 'INNER JOIN "account" ON "account"."id" = "videoChannel"."accountId" ' +
467 'INNER JOIN "actor" ON "account"."actorId" = "actor"."id" ' +
468 'INNER JOIN "actorFollow" ON "actorFollow"."targetActorId" = "actor"."id" ' +
469 'WHERE "actorFollow"."actorId" = ' + actorIdNumber +
470 ')'
471 )
472 }
473 },
474 localVideosReq
475 ]
476 }) 464 })
477 } 465 }
478 466