Loading backend/src/handoff/activitypub.ts +6 −5 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import { APub } from "../lib/apub/utils.js"; import { USER_IDENTIFIER } from "../lib/apub/federation.js"; import { Temporal } from "@js-temporal/polyfill"; import { stripHtml } from "string-strip-html"; import { Handoff } from "./index.js"; type Message = Note | ChatMessage; Loading Loading @@ -39,7 +40,7 @@ export class HandoffActivityPub { name: actor.id!.toString(), }), ], }) }), ); } Loading @@ -56,20 +57,20 @@ export class HandoffActivityPub { published: Temporal.Instant.from(handoff.createdAt.toISOString()), replyTarget: object, content: handoff.getURL().toString(), }) }), ); } } isObjectValid( object: Message object: Message, ): { valid: false } | { valid: true; software: string } { const TOKEN = process.env.AUTOMATED_EXCHANGE_TOKEN; const TOKEN = Handoff.HANDOFF_TOKEN; if (!TOKEN) return { valid: false }; const content = stripHtml( object.content?.toString() || object.contents[0]?.toString() object.content?.toString() || object.contents[0]?.toString(), ).result; if (content.indexOf(TOKEN) === -1) return { valid: false }; Loading Loading
backend/src/handoff/activitypub.ts +6 −5 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ import { APub } from "../lib/apub/utils.js"; import { USER_IDENTIFIER } from "../lib/apub/federation.js"; import { Temporal } from "@js-temporal/polyfill"; import { stripHtml } from "string-strip-html"; import { Handoff } from "./index.js"; type Message = Note | ChatMessage; Loading Loading @@ -39,7 +40,7 @@ export class HandoffActivityPub { name: actor.id!.toString(), }), ], }) }), ); } Loading @@ -56,20 +57,20 @@ export class HandoffActivityPub { published: Temporal.Instant.from(handoff.createdAt.toISOString()), replyTarget: object, content: handoff.getURL().toString(), }) }), ); } } isObjectValid( object: Message object: Message, ): { valid: false } | { valid: true; software: string } { const TOKEN = process.env.AUTOMATED_EXCHANGE_TOKEN; const TOKEN = Handoff.HANDOFF_TOKEN; if (!TOKEN) return { valid: false }; const content = stripHtml( object.content?.toString() || object.contents[0]?.toString() object.content?.toString() || object.contents[0]?.toString(), ).result; if (content.indexOf(TOKEN) === -1) return { valid: false }; Loading