fix: catch exceptions in assertPayload, closes #13611

This commit is contained in:
Barış Soner Uşaklı
2025-08-21 21:25:14 -04:00
parent 74cd68b865
commit 9bdf24f08b

View File

@@ -4,6 +4,7 @@ const db = require('../database');
const meta = require('../meta'); const meta = require('../meta');
const activitypub = require('../activitypub'); const activitypub = require('../activitypub');
const analytics = require('../analytics'); const analytics = require('../analytics');
const helpers = require('./helpers');
const middleware = module.exports; const middleware = module.exports;
@@ -59,7 +60,7 @@ middleware.verify = async function (req, res, next) {
next(); next();
}; };
middleware.assertPayload = async function (req, res, next) { middleware.assertPayload = helpers.try(async function (req, res, next) {
// Checks the validity of the incoming payload against the sender and rejects on failure // Checks the validity of the incoming payload against the sender and rejects on failure
activitypub.helpers.log('[middleware/activitypub] Validating incoming payload...'); activitypub.helpers.log('[middleware/activitypub] Validating incoming payload...');
@@ -131,7 +132,7 @@ middleware.assertPayload = async function (req, res, next) {
activitypub.helpers.log('[middleware/activitypub] Key ownership cross-check passed.'); activitypub.helpers.log('[middleware/activitypub] Key ownership cross-check passed.');
next(); next();
}; });
middleware.resolveObjects = async function (req, res, next) { middleware.resolveObjects = async function (req, res, next) {
const { type, object } = req.body; const { type, object } = req.body;