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);