fix: one more

This commit is contained in:
Julian Lam
2024-11-27 14:07:47 -05:00
parent 69d5544a7b
commit 304fa554ce

View File

@@ -191,11 +191,18 @@ inbox.update = async (req) => {
inbox.delete = async (req) => {
const { actor, object } = req.body;
if (typeof object !== 'string') {
const { id } = object;
if (!id) {
throw new Error('[[error:invalid-pid]]');
}
}
const pid = object.id || object;
// Deletes don't have their objects resolved automatically
let method = 'purge';
try {
const { type } = await activitypub.get('uid', 0, object);
const { type } = await activitypub.get('uid', 0, pid);
if (type === 'Tombstone') {
method = 'delete';
}
@@ -205,13 +212,7 @@ inbox.delete = async (req) => {
// Deletions must be made by an actor of the same origin
const actorHostname = new URL(actor).hostname;
if (typeof object !== 'string') {
const { id } = object;
if (!id) {
throw new Error('[[error:activitypub.origin-mismatch]]');
}
}
const pid = object.id || object;
const objectHostname = new URL(pid).hostname;
if (actorHostname !== objectHostname) {
throw new Error('[[error:activitypub.origin-mismatch]]');