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' import { OpenTelemetryMetrics } from '@server/lib/opentelemetry/metrics' import { HttpStatusCode, PlaybackMetricCreate } from '@shared/models' import { addPlaybackMetricValidator, asyncMiddleware } from '../../middlewares' +import { CONFIG } from '@server/initializers/config' const metricsRouter = express.Router() @@ -19,6 +20,10 @@ export { // --------------------------------------------------------------------------- function addPlaybackMetric (req: express.Request, res: express.Response) { + if (!CONFIG.OPEN_TELEMETRY.METRICS.ENABLED) { + return res.sendStatus(HttpStatusCode.FORBIDDEN_403) + } + const body: PlaybackMetricCreate = req.body 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 @@ +import { logger } from '@server/helpers/logger' import express from 'express' import { HttpStatusCode } from '../../../../shared/models/http/http-error-codes' import { ContactForm } from '../../../../shared/models/server' @@ -17,7 +18,11 @@ async function contactAdministrator (req: express.Request, res: express.Response Emailer.Instance.addContactFormJob(data.fromEmail, data.fromName, data.subject, data.body) - await Redis.Instance.setContactFormIp(req.ip) + try { + await Redis.Instance.setContactFormIp(req.ip) + } catch (err) { + logger.error(err) + } return res.status(HttpStatusCode.NO_CONTENT_204).end() }