From aea8a2d82632bcfbe7b44b4b2212a033cfe9cb62 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 18 Aug 2019 17:15:39 -0400 Subject: [PATCH] Fix not accepting deletes --- lib/activitypub/inbox.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/activitypub/inbox.ts b/lib/activitypub/inbox.ts index 67da356..0de1deb 100644 --- a/lib/activitypub/inbox.ts +++ b/lib/activitypub/inbox.ts @@ -90,11 +90,11 @@ function sanitizeStatus(content: string): string { async function handleCreateNote(create: CreateActivity, req: Request, res: Response) { const noteObject = create.object as NoteObject; - getActor(noteObject.attributedTo); // get and cache the actor if it's not already cached + const actor = await getActor(noteObject.attributedTo); // get and cache the actor if it's not already cached const sanitizedContent = sanitizeStatus(noteObject.content); const note = new Note(); note.id = noteObject.id; - note.actor = await getConnection().getRepository(Actor).findOne(noteObject.attributedTo); + note.actor = await getConnection().getRepository(Actor).findOne(actor.id); note.content = sanitizedContent; note.attributedTo = noteObject.attributedTo; note.inReplyTo = noteObject.inReplyTo; @@ -115,7 +115,7 @@ async function handleDelete(activity: Activity, req: Request, res: Response) { .delete() .from(Note, "note") .where("note.id = :id", { id: deleteActivity.object }) - .andWhere("note.actor = :actor", { actor: deleteActivity.actor }) + .andWhere("note.\"actorId\" = :actor", { actor: deleteActivity.actor }) .execute(); } catch (err) { console.error(`Encountered error deleting ${deleteActivity.object}`, err);