diff options
-rw-r--r-- | server/controllers/api/metrics.ts | 5 | ||||
-rw-r--r-- | server/controllers/api/server/contact.ts | 7 |
2 files changed, 11 insertions, 1 deletions
diff --git a/server/controllers/api/metrics.ts b/server/controllers/api/metrics.ts index 578b023a1..f66173875 100644 --- a/server/controllers/api/metrics.ts +++ b/server/controllers/api/metrics.ts | |||
@@ -2,6 +2,7 @@ import express from 'express' | |||
2 | import { OpenTelemetryMetrics } from '@server/lib/opentelemetry/metrics' | 2 | import { OpenTelemetryMetrics } from '@server/lib/opentelemetry/metrics' |
3 | import { HttpStatusCode, PlaybackMetricCreate } from '@shared/models' | 3 | import { HttpStatusCode, PlaybackMetricCreate } from '@shared/models' |
4 | import { addPlaybackMetricValidator, asyncMiddleware } from '../../middlewares' | 4 | import { addPlaybackMetricValidator, asyncMiddleware } from '../../middlewares' |
5 | import { CONFIG } from '@server/initializers/config' | ||
5 | 6 | ||
6 | const metricsRouter = express.Router() | 7 | const metricsRouter = express.Router() |
7 | 8 | ||
@@ -19,6 +20,10 @@ export { | |||
19 | // --------------------------------------------------------------------------- | 20 | // --------------------------------------------------------------------------- |
20 | 21 | ||
21 | function addPlaybackMetric (req: express.Request, res: express.Response) { | 22 | function addPlaybackMetric (req: express.Request, res: express.Response) { |
23 | if (!CONFIG.OPEN_TELEMETRY.METRICS.ENABLED) { | ||
24 | return res.sendStatus(HttpStatusCode.FORBIDDEN_403) | ||
25 | } | ||
26 | |||
22 | const body: PlaybackMetricCreate = req.body | 27 | const body: PlaybackMetricCreate = req.body |
23 | 28 | ||
24 | OpenTelemetryMetrics.Instance.observePlaybackMetric(res.locals.onlyImmutableVideo, body) | 29 | OpenTelemetryMetrics.Instance.observePlaybackMetric(res.locals.onlyImmutableVideo, body) |
diff --git a/server/controllers/api/server/contact.ts b/server/controllers/api/server/contact.ts index 09ff50f69..56596bea5 100644 --- a/server/controllers/api/server/contact.ts +++ b/server/controllers/api/server/contact.ts | |||
@@ -1,3 +1,4 @@ | |||
1 | import { logger } from '@server/helpers/logger' | ||
1 | import express from 'express' | 2 | import express from 'express' |
2 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' | 3 | import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' |
3 | import { ContactForm } from '../../../../shared/models/server' | 4 | import { ContactForm } from '../../../../shared/models/server' |
@@ -17,7 +18,11 @@ async function contactAdministrator (req: express.Request, res: express.Response | |||
17 | 18 | ||
18 | Emailer.Instance.addContactFormJob(data.fromEmail, data.fromName, data.subject, data.body) | 19 | Emailer.Instance.addContactFormJob(data.fromEmail, data.fromName, data.subject, data.body) |
19 | 20 | ||
20 | await Redis.Instance.setContactFormIp(req.ip) | 21 | try { |
22 | await Redis.Instance.setContactFormIp(req.ip) | ||
23 | } catch (err) { | ||
24 | logger.error(err) | ||
25 | } | ||
21 | 26 | ||
22 | return res.status(HttpStatusCode.NO_CONTENT_204).end() | 27 | return res.status(HttpStatusCode.NO_CONTENT_204).end() |
23 | } | 28 | } |