diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/controllers/client.ts | 8 | ||||
-rw-r--r-- | server/lib/activitypub/actor.ts | 4 | ||||
-rw-r--r-- | server/lib/activitypub/process/process-follow.ts | 4 | ||||
-rw-r--r-- | server/models/video/video.ts | 52 |
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' | |||
2 | import { join } from 'path' | 2 | import { join } from 'path' |
3 | import { root } from '../helpers/core-utils' | 3 | import { root } from '../helpers/core-utils' |
4 | import { ACCEPT_HEADERS, STATIC_MAX_AGE } from '../initializers/constants' | 4 | import { ACCEPT_HEADERS, STATIC_MAX_AGE } from '../initializers/constants' |
5 | import { asyncMiddleware } from '../middlewares' | 5 | import { asyncMiddleware, embedCSP } from '../middlewares' |
6 | import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '../../shared/models/i18n/i18n' | 6 | import { buildFileLocale, getCompleteLocale, is18nLocale, LOCALE_FILES } from '../../shared/models/i18n/i18n' |
7 | import { ClientHtml } from '../lib/client-html' | 7 | import { ClientHtml } from '../lib/client-html' |
8 | import { logger } from '../helpers/logger' | 8 | import { logger } from '../helpers/logger' |
9 | import { CONFIG } from '@server/initializers/config' | ||
9 | 10 | ||
10 | const clientsRouter = express.Router() | 11 | const clientsRouter = express.Router() |
11 | 12 | ||
@@ -19,8 +20,13 @@ clientsRouter.use('/videos/watch/:id', asyncMiddleware(generateWatchHtmlPage)) | |||
19 | clientsRouter.use('/accounts/:nameWithHost', asyncMiddleware(generateAccountHtmlPage)) | 20 | clientsRouter.use('/accounts/:nameWithHost', asyncMiddleware(generateAccountHtmlPage)) |
20 | clientsRouter.use('/video-channels/:nameWithHost', asyncMiddleware(generateVideoChannelHtmlPage)) | 21 | clientsRouter.use('/video-channels/:nameWithHost', asyncMiddleware(generateVideoChannelHtmlPage)) |
21 | 22 | ||
23 | const embedCSPMiddleware = CONFIG.CSP.ENABLED | ||
24 | ? embedCSP | ||
25 | : (req: express.Request, res: express.Response, next: express.NextFunction) => next() | ||
26 | |||
22 | clientsRouter.use( | 27 | clientsRouter.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' |
142 | import { MVideoFile, MVideoFileStreamingPlaylistVideo } from '../../typings/models/video/video-file' | 141 | import { MVideoFile, MVideoFileStreamingPlaylistVideo } from '../../typings/models/video/video-file' |
143 | import { MThumbnail } from '../../typings/models/video/thumbnail' | 142 | import { 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 | ||