Loading .zed/settings.json +20 −7 Original line number Diff line number Diff line Loading @@ -4,14 +4,27 @@ }, "ensure_final_newline_on_save": true, "format_on_save": "on", "formatter": { "external": { "command": "deno", "arguments": [ "fmt", "-" "formatter": "language_server", "languages": { "TypeScript": { "language_servers": [ "deno", "!typescript-language-server", "!eslint", "..." ] }, "TSX": { "language_servers": [ "deno", "!typescript-language-server", "!eslint", "..." ] } }, "preferred_line_length": 80 "show_wrap_guides": true, "wrap_guides": [ 80 ] } CHANGES.md +6 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,12 @@ To be released. ``Promise<`@${string}@${string}` | `${string}@${string}`>`` (was ``Promise<`@${string}@${string}`>``). - Added `excludeBaseUris` option to `Context.sendActivity()` and `Federation.sendActivity()` methods. - Added `SendActivityOptions.excludeBaseUris` property. - Added `ExtractInboxesParameters.excludeBaseUris` property. - Added more log messages using the [LogTape] library. Currently the below logger categories are used: Loading docs/manual/send.md +28 −0 Original line number Diff line number Diff line Loading @@ -231,6 +231,34 @@ the digest of the followers collection in the payload. [FEP-8fcf]: https://codeberg.org/fediverse/fep/src/branch/main/fep/8fcf/fep-8fcf.md Excluding same-server recipients -------------------------------- *This API is available since Fedify 0.9.0.* In most cases, you will not want to deliver activities via ActivityPub to recipients on the same server with the sender. To exclude same-server recipients, you can pass the `excludeBaseUris` option to the `~Context.sendActivity()` method: ~~~~ typescript await ctx.sendActivity( { handle: senderHandle }, "followers", activity, { excludeBaseUris: [ctx.getInboxUri()] }, // [!code highlight] ); ~~~~ Excluded recipients do not receive the activity, even if they are included in the recipients parameter. > [!NOTE] > Only the `origin` parts of the specified URIs are compared with the > inbox URLs of the recipients. Even if they have `pathname` or `query` parts, > they are ignored when comparing the URIs. Error handling -------------- Loading federation/context.ts +12 −0 Original line number Diff line number Diff line Loading @@ -260,6 +260,18 @@ export interface SendActivityOptions { * Whether to send the activity immediately, without enqueuing it. * If `true`, the activity will be sent immediately and the retrial * policy will not be applied. * * @since 0.3.0 */ immediate?: boolean; /** * The base URIs to exclude from the recipients' inboxes. It is useful * for excluding the recipients having the same shared inbox with the sender. * * Note that the only `origin` parts of the `URL`s are compared. * * @since 0.9.0 */ excludeBaseUris?: URL[]; } federation/middleware.ts +2 −1 Original line number Diff line number Diff line Loading @@ -1193,7 +1193,7 @@ export class Federation<TContextData> { { keyId, privateKey }: { keyId: URL; privateKey: CryptoKey }, recipients: Recipient | Recipient[], activity: Activity, { preferSharedInbox, immediate, collectionSync }: { preferSharedInbox, immediate, excludeBaseUris, collectionSync }: SendActivityInternalOptions = {}, ): Promise<void> { const logger = getLogger(["fedify", "federation", "outbox"]); Loading @@ -1216,6 +1216,7 @@ export class Federation<TContextData> { const inboxes = extractInboxes({ recipients: Array.isArray(recipients) ? recipients : [recipients], preferSharedInbox, excludeBaseUris, }); logger.debug("Sending activity {activityId} to inboxes:\n{inboxes}", { inboxes: globalThis.Object.keys(inboxes), Loading Loading
.zed/settings.json +20 −7 Original line number Diff line number Diff line Loading @@ -4,14 +4,27 @@ }, "ensure_final_newline_on_save": true, "format_on_save": "on", "formatter": { "external": { "command": "deno", "arguments": [ "fmt", "-" "formatter": "language_server", "languages": { "TypeScript": { "language_servers": [ "deno", "!typescript-language-server", "!eslint", "..." ] }, "TSX": { "language_servers": [ "deno", "!typescript-language-server", "!eslint", "..." ] } }, "preferred_line_length": 80 "show_wrap_guides": true, "wrap_guides": [ 80 ] }
CHANGES.md +6 −0 Original line number Diff line number Diff line Loading @@ -23,6 +23,12 @@ To be released. ``Promise<`@${string}@${string}` | `${string}@${string}`>`` (was ``Promise<`@${string}@${string}`>``). - Added `excludeBaseUris` option to `Context.sendActivity()` and `Federation.sendActivity()` methods. - Added `SendActivityOptions.excludeBaseUris` property. - Added `ExtractInboxesParameters.excludeBaseUris` property. - Added more log messages using the [LogTape] library. Currently the below logger categories are used: Loading
docs/manual/send.md +28 −0 Original line number Diff line number Diff line Loading @@ -231,6 +231,34 @@ the digest of the followers collection in the payload. [FEP-8fcf]: https://codeberg.org/fediverse/fep/src/branch/main/fep/8fcf/fep-8fcf.md Excluding same-server recipients -------------------------------- *This API is available since Fedify 0.9.0.* In most cases, you will not want to deliver activities via ActivityPub to recipients on the same server with the sender. To exclude same-server recipients, you can pass the `excludeBaseUris` option to the `~Context.sendActivity()` method: ~~~~ typescript await ctx.sendActivity( { handle: senderHandle }, "followers", activity, { excludeBaseUris: [ctx.getInboxUri()] }, // [!code highlight] ); ~~~~ Excluded recipients do not receive the activity, even if they are included in the recipients parameter. > [!NOTE] > Only the `origin` parts of the specified URIs are compared with the > inbox URLs of the recipients. Even if they have `pathname` or `query` parts, > they are ignored when comparing the URIs. Error handling -------------- Loading
federation/context.ts +12 −0 Original line number Diff line number Diff line Loading @@ -260,6 +260,18 @@ export interface SendActivityOptions { * Whether to send the activity immediately, without enqueuing it. * If `true`, the activity will be sent immediately and the retrial * policy will not be applied. * * @since 0.3.0 */ immediate?: boolean; /** * The base URIs to exclude from the recipients' inboxes. It is useful * for excluding the recipients having the same shared inbox with the sender. * * Note that the only `origin` parts of the `URL`s are compared. * * @since 0.9.0 */ excludeBaseUris?: URL[]; }
federation/middleware.ts +2 −1 Original line number Diff line number Diff line Loading @@ -1193,7 +1193,7 @@ export class Federation<TContextData> { { keyId, privateKey }: { keyId: URL; privateKey: CryptoKey }, recipients: Recipient | Recipient[], activity: Activity, { preferSharedInbox, immediate, collectionSync }: { preferSharedInbox, immediate, excludeBaseUris, collectionSync }: SendActivityInternalOptions = {}, ): Promise<void> { const logger = getLogger(["fedify", "federation", "outbox"]); Loading @@ -1216,6 +1216,7 @@ export class Federation<TContextData> { const inboxes = extractInboxes({ recipients: Array.isArray(recipients) ? recipients : [recipients], preferSharedInbox, excludeBaseUris, }); logger.debug("Sending activity {activityId} to inboxes:\n{inboxes}", { inboxes: globalThis.Object.keys(inboxes), Loading