aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/lib
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-07-06 15:44:14 +0200
committerChocobozzz <me@florianbigard.com>2022-07-06 16:12:17 +0200
commit9452d4fd3321148fb80b64a67bd9983fee6c208e (patch)
tree62ad9be8d3f4bfcf63196274ad4b736372c05f2c /server/lib
parent630d0a1bf5897fff203cb07e426223f55dcc882d (diff)
downloadPeerTube-9452d4fd3321148fb80b64a67bd9983fee6c208e.tar.gz
PeerTube-9452d4fd3321148fb80b64a67bd9983fee6c208e.tar.zst
PeerTube-9452d4fd3321148fb80b64a67bd9983fee6c208e.zip
/!\ Use a dedicated config file for development
It means you have to replace NODE_ENV=test to NODE_ENV=dev if you use it npm run dev:* commands are already updated
Diffstat (limited to 'server/lib')
-rw-r--r--server/lib/client-html.ts4
-rw-r--r--server/lib/emailer.ts6
-rw-r--r--server/lib/job-queue/handlers/video-views-stats.ts4
-rw-r--r--server/lib/schedulers/actor-follow-scheduler.ts4
-rw-r--r--server/lib/schedulers/remove-old-jobs-scheduler.ts6
-rw-r--r--server/lib/views/shared/video-viewer-counters.ts4
-rw-r--r--server/lib/views/shared/video-viewer-stats.ts4
7 files changed, 16 insertions, 16 deletions
diff --git a/server/lib/client-html.ts b/server/lib/client-html.ts
index 1e8d03023..899d80c15 100644
--- a/server/lib/client-html.ts
+++ b/server/lib/client-html.ts
@@ -2,6 +2,7 @@ import express from 'express'
2import { readFile } from 'fs-extra' 2import { readFile } from 'fs-extra'
3import { join } from 'path' 3import { join } from 'path'
4import validator from 'validator' 4import validator from 'validator'
5import { isTestOrDevInstance } from '@server/helpers/core-utils'
5import { toCompleteUUID } from '@server/helpers/custom-validators/misc' 6import { toCompleteUUID } from '@server/helpers/custom-validators/misc'
6import { mdToOneLinePlainText } from '@server/helpers/markdown' 7import { mdToOneLinePlainText } from '@server/helpers/markdown'
7import { ActorImageModel } from '@server/models/actor/actor-image' 8import { ActorImageModel } from '@server/models/actor/actor-image'
@@ -30,7 +31,6 @@ import { MAccountActor, MChannelActor } from '../types/models'
30import { getActivityStreamDuration } from './activitypub/activity' 31import { getActivityStreamDuration } from './activitypub/activity'
31import { getBiggestActorImage } from './actor-image' 32import { getBiggestActorImage } from './actor-image'
32import { ServerConfigManager } from './server-config-manager' 33import { ServerConfigManager } from './server-config-manager'
33import { isTestInstance } from '@server/helpers/core-utils'
34 34
35type Tags = { 35type Tags = {
36 ogType: string 36 ogType: string
@@ -234,7 +234,7 @@ class ClientHtml {
234 const path = ClientHtml.getEmbedPath() 234 const path = ClientHtml.getEmbedPath()
235 235
236 // Disable HTML cache in dev mode because webpack can regenerate JS files 236 // Disable HTML cache in dev mode because webpack can regenerate JS files
237 if (!isTestInstance() && ClientHtml.htmlCache[path]) { 237 if (!isTestOrDevInstance() && ClientHtml.htmlCache[path]) {
238 return ClientHtml.htmlCache[path] 238 return ClientHtml.htmlCache[path]
239 } 239 }
240 240
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts
index edc99057c..42d7650dd 100644
--- a/server/lib/emailer.ts
+++ b/server/lib/emailer.ts
@@ -2,10 +2,10 @@ import { readFileSync } from 'fs-extra'
2import { isArray, merge } from 'lodash' 2import { isArray, merge } from 'lodash'
3import { createTransport, Transporter } from 'nodemailer' 3import { createTransport, Transporter } from 'nodemailer'
4import { join } from 'path' 4import { join } from 'path'
5import { root } from '@shared/core-utils'
5import { EmailPayload } from '@shared/models' 6import { EmailPayload } from '@shared/models'
6import { SendEmailDefaultOptions } from '../../shared/models/server/emailer.model' 7import { SendEmailDefaultOptions } from '../../shared/models/server/emailer.model'
7import { isTestInstance } from '../helpers/core-utils' 8import { isTestOrDevInstance } from '../helpers/core-utils'
8import { root } from '@shared/core-utils'
9import { bunyanLogger, logger } from '../helpers/logger' 9import { bunyanLogger, logger } from '../helpers/logger'
10import { CONFIG, isEmailEnabled } from '../initializers/config' 10import { CONFIG, isEmailEnabled } from '../initializers/config'
11import { WEBSERVER } from '../initializers/constants' 11import { WEBSERVER } from '../initializers/constants'
@@ -29,7 +29,7 @@ class Emailer {
29 this.initialized = true 29 this.initialized = true
30 30
31 if (!isEmailEnabled()) { 31 if (!isEmailEnabled()) {
32 if (!isTestInstance()) { 32 if (!isTestOrDevInstance()) {
33 logger.error('Cannot use SMTP server because of lack of configuration. PeerTube will not be able to send mails!') 33 logger.error('Cannot use SMTP server because of lack of configuration. PeerTube will not be able to send mails!')
34 } 34 }
35 35
diff --git a/server/lib/job-queue/handlers/video-views-stats.ts b/server/lib/job-queue/handlers/video-views-stats.ts
index 689a5a3b4..c9aa218e5 100644
--- a/server/lib/job-queue/handlers/video-views-stats.ts
+++ b/server/lib/job-queue/handlers/video-views-stats.ts
@@ -1,5 +1,5 @@
1import { VideoViewModel } from '@server/models/view/video-view' 1import { VideoViewModel } from '@server/models/view/video-view'
2import { isTestInstance } from '../../../helpers/core-utils' 2import { isTestOrDevInstance } from '../../../helpers/core-utils'
3import { logger } from '../../../helpers/logger' 3import { logger } from '../../../helpers/logger'
4import { VideoModel } from '../../../models/video/video' 4import { VideoModel } from '../../../models/video/video'
5import { Redis } from '../../redis' 5import { Redis } from '../../redis'
@@ -8,7 +8,7 @@ async function processVideosViewsStats () {
8 const lastHour = new Date() 8 const lastHour = new Date()
9 9
10 // In test mode, we run this function multiple times per hour, so we don't want the values of the previous hour 10 // In test mode, we run this function multiple times per hour, so we don't want the values of the previous hour
11 if (!isTestInstance()) lastHour.setHours(lastHour.getHours() - 1) 11 if (!isTestOrDevInstance()) lastHour.setHours(lastHour.getHours() - 1)
12 12
13 const hour = lastHour.getHours() 13 const hour = lastHour.getHours()
14 const startDate = lastHour.setMinutes(0, 0, 0) 14 const startDate = lastHour.setMinutes(0, 0, 0)
diff --git a/server/lib/schedulers/actor-follow-scheduler.ts b/server/lib/schedulers/actor-follow-scheduler.ts
index 560f97f3e..e1c56c135 100644
--- a/server/lib/schedulers/actor-follow-scheduler.ts
+++ b/server/lib/schedulers/actor-follow-scheduler.ts
@@ -1,4 +1,4 @@
1import { isTestInstance } from '../../helpers/core-utils' 1import { isTestOrDevInstance } from '../../helpers/core-utils'
2import { logger } from '../../helpers/logger' 2import { logger } from '../../helpers/logger'
3import { ACTOR_FOLLOW_SCORE, SCHEDULER_INTERVALS_MS } from '../../initializers/constants' 3import { ACTOR_FOLLOW_SCORE, SCHEDULER_INTERVALS_MS } from '../../initializers/constants'
4import { ActorFollowModel } from '../../models/actor/actor-follow' 4import { ActorFollowModel } from '../../models/actor/actor-follow'
@@ -39,7 +39,7 @@ export class ActorFollowScheduler extends AbstractScheduler {
39 } 39 }
40 40
41 private async removeBadActorFollows () { 41 private async removeBadActorFollows () {
42 if (!isTestInstance()) logger.info('Removing bad actor follows (scheduler).') 42 if (!isTestOrDevInstance()) logger.info('Removing bad actor follows (scheduler).')
43 43
44 try { 44 try {
45 await ActorFollowModel.removeBadActorFollows() 45 await ActorFollowModel.removeBadActorFollows()
diff --git a/server/lib/schedulers/remove-old-jobs-scheduler.ts b/server/lib/schedulers/remove-old-jobs-scheduler.ts
index dffef3542..879846999 100644
--- a/server/lib/schedulers/remove-old-jobs-scheduler.ts
+++ b/server/lib/schedulers/remove-old-jobs-scheduler.ts
@@ -1,8 +1,8 @@
1import { isTestInstance } from '../../helpers/core-utils' 1import { isTestOrDevInstance } from '../../helpers/core-utils'
2import { logger } from '../../helpers/logger' 2import { logger } from '../../helpers/logger'
3import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants'
3import { JobQueue } from '../job-queue' 4import { JobQueue } from '../job-queue'
4import { AbstractScheduler } from './abstract-scheduler' 5import { AbstractScheduler } from './abstract-scheduler'
5import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants'
6 6
7export class RemoveOldJobsScheduler extends AbstractScheduler { 7export class RemoveOldJobsScheduler extends AbstractScheduler {
8 8
@@ -15,7 +15,7 @@ export class RemoveOldJobsScheduler extends AbstractScheduler {
15 } 15 }
16 16
17 protected internalExecute () { 17 protected internalExecute () {
18 if (!isTestInstance()) logger.info('Removing old jobs in scheduler.') 18 if (!isTestOrDevInstance()) logger.info('Removing old jobs in scheduler.')
19 19
20 return JobQueue.Instance.removeOldJobs() 20 return JobQueue.Instance.removeOldJobs()
21 } 21 }
diff --git a/server/lib/views/shared/video-viewer-counters.ts b/server/lib/views/shared/video-viewer-counters.ts
index cf3fa5882..f851ce050 100644
--- a/server/lib/views/shared/video-viewer-counters.ts
+++ b/server/lib/views/shared/video-viewer-counters.ts
@@ -1,4 +1,4 @@
1import { isTestInstance } from '@server/helpers/core-utils' 1import { isTestOrDevInstance } from '@server/helpers/core-utils'
2import { logger, loggerTagsFactory } from '@server/helpers/logger' 2import { logger, loggerTagsFactory } from '@server/helpers/logger'
3import { VIEW_LIFETIME } from '@server/initializers/constants' 3import { VIEW_LIFETIME } from '@server/initializers/constants'
4import { sendView } from '@server/lib/activitypub/send/send-view' 4import { sendView } from '@server/lib/activitypub/send/send-view'
@@ -117,7 +117,7 @@ export class VideoViewerCounters {
117 if (this.processingViewerCounters) return 117 if (this.processingViewerCounters) return
118 this.processingViewerCounters = true 118 this.processingViewerCounters = true
119 119
120 if (!isTestInstance()) logger.info('Cleaning video viewers.', lTags()) 120 if (!isTestOrDevInstance()) logger.info('Cleaning video viewers.', lTags())
121 121
122 try { 122 try {
123 for (const videoId of this.viewersPerVideo.keys()) { 123 for (const videoId of this.viewersPerVideo.keys()) {
diff --git a/server/lib/views/shared/video-viewer-stats.ts b/server/lib/views/shared/video-viewer-stats.ts
index a56c20559..542bd51cf 100644
--- a/server/lib/views/shared/video-viewer-stats.ts
+++ b/server/lib/views/shared/video-viewer-stats.ts
@@ -1,5 +1,5 @@
1import { Transaction } from 'sequelize/types' 1import { Transaction } from 'sequelize/types'
2import { isTestInstance } from '@server/helpers/core-utils' 2import { isTestOrDevInstance } from '@server/helpers/core-utils'
3import { GeoIP } from '@server/helpers/geo-ip' 3import { GeoIP } from '@server/helpers/geo-ip'
4import { logger, loggerTagsFactory } from '@server/helpers/logger' 4import { logger, loggerTagsFactory } from '@server/helpers/logger'
5import { MAX_LOCAL_VIEWER_WATCH_SECTIONS, VIEW_LIFETIME } from '@server/initializers/constants' 5import { MAX_LOCAL_VIEWER_WATCH_SECTIONS, VIEW_LIFETIME } from '@server/initializers/constants'
@@ -118,7 +118,7 @@ export class VideoViewerStats {
118 if (this.processingViewersStats) return 118 if (this.processingViewersStats) return
119 this.processingViewersStats = true 119 this.processingViewersStats = true
120 120
121 if (!isTestInstance()) logger.info('Processing viewer statistics.', lTags()) 121 if (!isTestOrDevInstance()) logger.info('Processing viewer statistics.', lTags())
122 122
123 const now = new Date().getTime() 123 const now = new Date().getTime()
124 124