Loading CHANGES.md +3 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,9 @@ To be released. - Added `federation()` function. - Added `ContextDataFactory` type. - `Context.sendActivity()` method now throws `TypeError` instead of silently failing when the given `Activity` object lacks the actor property. [Hono]: https://hono.dev/ [#25]: https://github.com/dahlia/fedify/issues/25 [#27]: https://github.com/dahlia/fedify/issues/27 Loading federation/middleware.test.ts +12 −1 Original line number Diff line number Diff line Loading @@ -121,7 +121,18 @@ Deno.test("Federation.createContext()", async (t) => { documentUrl: "https://example.com/object", document: true, }); await ctx.sendActivity({ handle: "handle" }, [], new Create({})); assertRejects( () => ctx.sendActivity({ handle: "handle" }, [], new Create({})), TypeError, "The activity to send must have at least one actor property.", ); await ctx.sendActivity( { handle: "handle" }, [], new Create({ actor: new URL("https://example.com/users/handle"), }), ); federation.setInboxListeners("/users/{handle}/inbox", "/inbox"); assertEquals(ctx.getInboxUri(), new URL("https://example.com/inbox")); Loading federation/middleware.ts +6 −0 Original line number Diff line number Diff line Loading @@ -674,6 +674,7 @@ export class Federation<TContextData> { * @param recipients The recipients of the activity. * @param activity The activity to send. * @param options Options for sending the activity. * @throws {TypeError} If the activity to send does not have an actor. */ async sendActivity( { keyId, privateKey }: { keyId: URL; privateKey: CryptoKey }, Loading @@ -681,6 +682,11 @@ export class Federation<TContextData> { activity: Activity, { preferSharedInbox, immediate }: SendActivityOptions = {}, ): Promise<void> { if (activity.actorId == null) { throw new TypeError( "The activity to send must have at least one actor property.", ); } if (activity.id == null) { activity = activity.clone({ id: new URL(`urn:uuid:${crypto.randomUUID()}`), Loading Loading
CHANGES.md +3 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,9 @@ To be released. - Added `federation()` function. - Added `ContextDataFactory` type. - `Context.sendActivity()` method now throws `TypeError` instead of silently failing when the given `Activity` object lacks the actor property. [Hono]: https://hono.dev/ [#25]: https://github.com/dahlia/fedify/issues/25 [#27]: https://github.com/dahlia/fedify/issues/27 Loading
federation/middleware.test.ts +12 −1 Original line number Diff line number Diff line Loading @@ -121,7 +121,18 @@ Deno.test("Federation.createContext()", async (t) => { documentUrl: "https://example.com/object", document: true, }); await ctx.sendActivity({ handle: "handle" }, [], new Create({})); assertRejects( () => ctx.sendActivity({ handle: "handle" }, [], new Create({})), TypeError, "The activity to send must have at least one actor property.", ); await ctx.sendActivity( { handle: "handle" }, [], new Create({ actor: new URL("https://example.com/users/handle"), }), ); federation.setInboxListeners("/users/{handle}/inbox", "/inbox"); assertEquals(ctx.getInboxUri(), new URL("https://example.com/inbox")); Loading
federation/middleware.ts +6 −0 Original line number Diff line number Diff line Loading @@ -674,6 +674,7 @@ export class Federation<TContextData> { * @param recipients The recipients of the activity. * @param activity The activity to send. * @param options Options for sending the activity. * @throws {TypeError} If the activity to send does not have an actor. */ async sendActivity( { keyId, privateKey }: { keyId: URL; privateKey: CryptoKey }, Loading @@ -681,6 +682,11 @@ export class Federation<TContextData> { activity: Activity, { preferSharedInbox, immediate }: SendActivityOptions = {}, ): Promise<void> { if (activity.actorId == null) { throw new TypeError( "The activity to send must have at least one actor property.", ); } if (activity.id == null) { activity = activity.clone({ id: new URL(`urn:uuid:${crypto.randomUUID()}`), Loading