aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/server/logs.ts3
-rw-r--r--server/controllers/bots.ts16
-rw-r--r--server/controllers/feeds.ts2
-rw-r--r--server/helpers/logger.ts23
-rw-r--r--server/initializers/constants.ts2
-rw-r--r--server/lib/schedulers/plugins-check-scheduler.ts10
-rw-r--r--server/models/video/video-playlist.ts8
-rw-r--r--server/models/video/video.ts7
8 files changed, 46 insertions, 25 deletions
diff --git a/server/controllers/api/server/logs.ts b/server/controllers/api/server/logs.ts
index f78607d35..39eceb654 100644
--- a/server/controllers/api/server/logs.ts
+++ b/server/controllers/api/server/logs.ts
@@ -1,8 +1,7 @@
1import * as express from 'express' 1import * as express from 'express'
2import { readdir, readFile } from 'fs-extra' 2import { readdir, readFile } from 'fs-extra'
3import { join } from 'path' 3import { join } from 'path'
4import { logger } from '@server/helpers/logger' 4import { logger, mtimeSortFilesDesc } from '@server/helpers/logger'
5import { mtimeSortFilesDesc } from '../../../../shared/core-utils/logs/logs'
6import { LogLevel } from '../../../../shared/models/server/log-level.type' 5import { LogLevel } from '../../../../shared/models/server/log-level.type'
7import { UserRight } from '../../../../shared/models/users' 6import { UserRight } from '../../../../shared/models/users'
8import { CONFIG } from '../../../initializers/config' 7import { CONFIG } from '../../../initializers/config'
diff --git a/server/controllers/bots.ts b/server/controllers/bots.ts
index 93aa0cf30..de0411608 100644
--- a/server/controllers/bots.ts
+++ b/server/controllers/bots.ts
@@ -1,13 +1,13 @@
1import * as express from 'express' 1import * as express from 'express'
2import { asyncMiddleware } from '../middlewares' 2import { truncate } from 'lodash'
3import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants'
4import { SitemapStream, streamToPromise } from 'sitemap' 3import { SitemapStream, streamToPromise } from 'sitemap'
4import { buildNSFWFilter } from '../helpers/express-utils'
5import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../initializers/constants'
6import { asyncMiddleware } from '../middlewares'
7import { cacheRoute } from '../middlewares/cache/cache'
8import { AccountModel } from '../models/account/account'
5import { VideoModel } from '../models/video/video' 9import { VideoModel } from '../models/video/video'
6import { VideoChannelModel } from '../models/video/video-channel' 10import { VideoChannelModel } from '../models/video/video-channel'
7import { AccountModel } from '../models/account/account'
8import { cacheRoute } from '../middlewares/cache/cache'
9import { buildNSFWFilter } from '../helpers/express-utils'
10import { truncate } from 'lodash'
11 11
12const botsRouter = express.Router() 12const botsRouter = express.Router()
13 13
@@ -75,13 +75,13 @@ async function getSitemapLocalVideoUrls () {
75 }) 75 })
76 76
77 return data.map(v => ({ 77 return data.map(v => ({
78 url: WEBSERVER.URL + '/w/' + v.uuid, 78 url: WEBSERVER.URL + v.getWatchStaticPath(),
79 video: [ 79 video: [
80 { 80 {
81 title: v.name, 81 title: v.name,
82 // Sitemap description should be < 2000 characters 82 // Sitemap description should be < 2000 characters
83 description: truncate(v.description || v.name, { length: 2000, omission: '...' }), 83 description: truncate(v.description || v.name, { length: 2000, omission: '...' }),
84 player_loc: WEBSERVER.URL + '/videos/embed/' + v.uuid, 84 player_loc: WEBSERVER.URL + v.getEmbedStaticPath(),
85 thumbnail_loc: WEBSERVER.URL + v.getMiniatureStaticPath() 85 thumbnail_loc: WEBSERVER.URL + v.getMiniatureStaticPath()
86 } 86 }
87 ] 87 ]
diff --git a/server/controllers/feeds.ts b/server/controllers/feeds.ts
index cdc6bfb8b..9fa70a7c8 100644
--- a/server/controllers/feeds.ts
+++ b/server/controllers/feeds.ts
@@ -286,7 +286,7 @@ function addVideosToFeed (feed, videos: VideoModel[]) {
286 feed.addItem({ 286 feed.addItem({
287 title: video.name, 287 title: video.name,
288 id: video.url, 288 id: video.url,
289 link: WEBSERVER.URL + '/w/' + video.uuid, 289 link: WEBSERVER.URL + video.getWatchStaticPath(),
290 description: video.getTruncatedDescription(), 290 description: video.getTruncatedDescription(),
291 content: video.description, 291 content: video.description,
292 author: [ 292 author: [
diff --git a/server/helpers/logger.ts b/server/helpers/logger.ts
index 29e06860d..20c3c3edb 100644
--- a/server/helpers/logger.ts
+++ b/server/helpers/logger.ts
@@ -1,5 +1,5 @@
1// Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/ 1// Thanks http://tostring.it/2014/06/23/advanced-logging-with-nodejs/
2import { mkdirpSync } from 'fs-extra' 2import { mkdirpSync, stat } from 'fs-extra'
3import { omit } from 'lodash' 3import { omit } from 'lodash'
4import * as path from 'path' 4import * as path from 'path'
5import { format as sqlFormat } from 'sql-formatter' 5import { format as sqlFormat } from 'sql-formatter'
@@ -158,6 +158,26 @@ function loggerTagsFactory (...defaultTags: string[]): LoggerTagsFn {
158 } 158 }
159} 159}
160 160
161async function mtimeSortFilesDesc (files: string[], basePath: string) {
162 const promises = []
163 const out: { file: string, mtime: number }[] = []
164
165 for (const file of files) {
166 const p = stat(basePath + '/' + file)
167 .then(stats => {
168 if (stats.isFile()) out.push({ file, mtime: stats.mtime.getTime() })
169 })
170
171 promises.push(p)
172 }
173
174 await Promise.all(promises)
175
176 out.sort((a, b) => b.mtime - a.mtime)
177
178 return out
179}
180
161// --------------------------------------------------------------------------- 181// ---------------------------------------------------------------------------
162 182
163export { 183export {
@@ -168,6 +188,7 @@ export {
168 labelFormatter, 188 labelFormatter,
169 consoleLoggerFormat, 189 consoleLoggerFormat,
170 jsonLoggerFormat, 190 jsonLoggerFormat,
191 mtimeSortFilesDesc,
171 logger, 192 logger,
172 loggerTagsFactory, 193 loggerTagsFactory,
173 bunyanLogger 194 bunyanLogger
diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts
index ee4503b2c..5f121d9a4 100644
--- a/server/initializers/constants.ts
+++ b/server/initializers/constants.ts
@@ -2,7 +2,7 @@ import { CronRepeatOptions, EveryRepeatOptions } from 'bull'
2import { randomBytes } from 'crypto' 2import { randomBytes } from 'crypto'
3import { invert } from 'lodash' 3import { invert } from 'lodash'
4import { join } from 'path' 4import { join } from 'path'
5import { randomInt } from '../../shared/core-utils/miscs/miscs' 5import { randomInt } from '../../shared/core-utils/common/miscs'
6import { 6import {
7 AbuseState, 7 AbuseState,
8 JobType, 8 JobType,
diff --git a/server/lib/schedulers/plugins-check-scheduler.ts b/server/lib/schedulers/plugins-check-scheduler.ts
index 9a1ae3ec5..c95e109b0 100644
--- a/server/lib/schedulers/plugins-check-scheduler.ts
+++ b/server/lib/schedulers/plugins-check-scheduler.ts
@@ -1,12 +1,12 @@
1import { chunk } from 'lodash'
2import { compareSemVer } from '@shared/core-utils'
1import { logger } from '../../helpers/logger' 3import { logger } from '../../helpers/logger'
2import { AbstractScheduler } from './abstract-scheduler'
3import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants'
4import { CONFIG } from '../../initializers/config' 4import { CONFIG } from '../../initializers/config'
5import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants'
5import { PluginModel } from '../../models/server/plugin' 6import { PluginModel } from '../../models/server/plugin'
6import { chunk } from 'lodash'
7import { getLatestPluginsVersion } from '../plugins/plugin-index'
8import { compareSemVer } from '../../../shared/core-utils/miscs/miscs'
9import { Notifier } from '../notifier' 7import { Notifier } from '../notifier'
8import { getLatestPluginsVersion } from '../plugins/plugin-index'
9import { AbstractScheduler } from './abstract-scheduler'
10 10
11export class PluginsCheckScheduler extends AbstractScheduler { 11export class PluginsCheckScheduler extends AbstractScheduler {
12 12
diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts
index af81c9906..245475f94 100644
--- a/server/models/video/video-playlist.ts
+++ b/server/models/video/video-playlist.ts
@@ -20,7 +20,7 @@ import {
20import { setAsUpdated } from '@server/helpers/database-utils' 20import { setAsUpdated } from '@server/helpers/database-utils'
21import { buildUUID, uuidToShort } from '@server/helpers/uuid' 21import { buildUUID, uuidToShort } from '@server/helpers/uuid'
22import { MAccountId, MChannelId } from '@server/types/models' 22import { MAccountId, MChannelId } from '@server/types/models'
23import { AttributesOnly } from '@shared/core-utils' 23import { AttributesOnly, buildPlaylistEmbedPath, buildPlaylistLink, buildPlaylistWatchPath } from '@shared/core-utils'
24import { ActivityIconObject } from '../../../shared/models/activitypub/objects' 24import { ActivityIconObject } from '../../../shared/models/activitypub/objects'
25import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object' 25import { PlaylistObject } from '../../../shared/models/activitypub/objects/playlist-object'
26import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model' 26import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
@@ -560,12 +560,12 @@ export class VideoPlaylistModel extends Model<Partial<AttributesOnly<VideoPlayli
560 return join(STATIC_PATHS.THUMBNAILS, this.Thumbnail.filename) 560 return join(STATIC_PATHS.THUMBNAILS, this.Thumbnail.filename)
561 } 561 }
562 562
563 getWatchUrl () { 563 getWatchStaticPath () {
564 return WEBSERVER.URL + '/w/p/' + this.uuid 564 return buildPlaylistWatchPath({ shortUUID: uuidToShort(this.uuid) })
565 } 565 }
566 566
567 getEmbedStaticPath () { 567 getEmbedStaticPath () {
568 return '/video-playlists/embed/' + this.uuid 568 return buildPlaylistEmbedPath(this)
569 } 569 }
570 570
571 static async getStats () { 571 static async getStats () {
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 0f0f894e4..543e604bb 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -26,12 +26,13 @@ import {
26} from 'sequelize-typescript' 26} from 'sequelize-typescript'
27import { setAsUpdated } from '@server/helpers/database-utils' 27import { setAsUpdated } from '@server/helpers/database-utils'
28import { buildNSFWFilter } from '@server/helpers/express-utils' 28import { buildNSFWFilter } from '@server/helpers/express-utils'
29import { shortToUUID } from '@server/helpers/uuid'
29import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video' 30import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video'
30import { LiveManager } from '@server/lib/live/live-manager' 31import { LiveManager } from '@server/lib/live/live-manager'
31import { getHLSDirectory, getVideoFilePath } from '@server/lib/video-paths' 32import { getHLSDirectory, getVideoFilePath } from '@server/lib/video-paths'
32import { getServerActor } from '@server/models/application/application' 33import { getServerActor } from '@server/models/application/application'
33import { ModelCache } from '@server/models/model-cache' 34import { ModelCache } from '@server/models/model-cache'
34import { AttributesOnly } from '@shared/core-utils' 35import { AttributesOnly, buildVideoEmbedPath, buildVideoWatchPath } from '@shared/core-utils'
35import { VideoFile } from '@shared/models/videos/video-file.model' 36import { VideoFile } from '@shared/models/videos/video-file.model'
36import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared' 37import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared'
37import { VideoObject } from '../../../shared/models/activitypub/objects' 38import { VideoObject } from '../../../shared/models/activitypub/objects'
@@ -1578,11 +1579,11 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1578 } 1579 }
1579 1580
1580 getWatchStaticPath () { 1581 getWatchStaticPath () {
1581 return '/w/' + this.uuid 1582 return buildVideoWatchPath({ shortUUID: shortToUUID(this.uuid) })
1582 } 1583 }
1583 1584
1584 getEmbedStaticPath () { 1585 getEmbedStaticPath () {
1585 return '/videos/embed/' + this.uuid 1586 return buildVideoEmbedPath(this)
1586 } 1587 }
1587 1588
1588 getMiniatureStaticPath () { 1589 getMiniatureStaticPath () {