Loading CHANGES.md +7 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,13 @@ Version 1.7.4 To be released. - Fixed a bug the `-T`/`--no-tunnel` option in the `fedify inbox` command was being ignored, causing the server to always create a public tunnel regardless of the flag. [[#243], [#284] by Lee ByeongJun] [#243]: https://github.com/fedify-dev/fedify/issues/243 [#284]: https://github.com/fedify-dev/fedify/pull/284 Version 1.7.3 ------------- Loading cli/inbox.test.ts 0 → 100644 +77 −0 Original line number Diff line number Diff line import { assertEquals } from "@std/assert"; import { type InboxOptions, TunnelConfig } from "./inbox.tsx"; Deno.test("handles --no-tunnel flag correctly", () => { const optionsWithNoTunnel: InboxOptions = { tunnel: false, follow: undefined, acceptFollow: undefined, }; assertEquals( TunnelConfig.shouldDisableTunnel(optionsWithNoTunnel), true, "--no-tunnel flag should disable tunnel", ); }); Deno.test("set noTunnel true, should handles -T flag correctly", () => { const optionsWithT: InboxOptions = { tunnel: true, noTunnel: true, follow: undefined, acceptFollow: undefined, }; assertEquals( TunnelConfig.shouldDisableTunnel(optionsWithT), true, "-T flag should disable tunnel", ); }); Deno.test("handles default behavior (no flags)", () => { const optionsDefault: InboxOptions = { tunnel: true, follow: undefined, acceptFollow: undefined, }; assertEquals( TunnelConfig.shouldDisableTunnel(optionsDefault), false, "Default behavior should enable tunnel", ); }); Deno.test("handles both flags together", () => { const optionsBothFlags: InboxOptions = { tunnel: false, noTunnel: true, follow: undefined, acceptFollow: undefined, }; assertEquals( TunnelConfig.shouldDisableTunnel(optionsBothFlags), true, "Both flags should disable tunnel", ); }); Deno.test("Various InboxOptions combinations", () => { const validOptions: InboxOptions[] = [ { tunnel: true }, { tunnel: false }, { tunnel: true, noTunnel: true }, { tunnel: false, noTunnel: false }, { tunnel: true, follow: ["@user@example.com"] }, { tunnel: true, acceptFollow: ["*"] }, { tunnel: true, follow: [], acceptFollow: [] }, ]; for (const options of validOptions) { const result = TunnelConfig.shouldDisableTunnel(options); assertEquals( typeof result, "boolean", "shouldDisableTunnel must return boolean", ); } }); cli/inbox.tsx +18 −2 Original line number Diff line number Diff line Loading @@ -37,6 +37,22 @@ import { spawnTemporaryServer, type TemporaryServer } from "./tempserver.ts"; const logger = getLogger(["fedify", "cli", "inbox"]); /** * Options for the inbox command. */ export interface InboxOptions { follow?: string[]; acceptFollow?: string[]; tunnel: boolean; noTunnel?: boolean; // for -T shorthand support } export const TunnelConfig = { shouldDisableTunnel: (opts: InboxOptions): boolean => { return opts.tunnel === false || opts.noTunnel === true; }, } as const; export const command = new Command() .description( "Spins up an ephemeral server that serves the ActivityPub inbox with " + Loading @@ -61,13 +77,13 @@ export const command = new Command() "-T, --no-tunnel", "Do not tunnel the ephemeral ActivityPub server to the public Internet.", ) .action(async (options) => { .action(async (options: InboxOptions) => { const spinner = ora({ text: "Spinning up an ephemeral ActivityPub server...", discardStdin: false, }).start(); const server = await spawnTemporaryServer(fetch, { noTunnel: !options.tunnel, noTunnel: TunnelConfig.shouldDisableTunnel(options), }); spinner.succeed( `The ephemeral ActivityPub server is up and running: ${ Loading Loading
CHANGES.md +7 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,13 @@ Version 1.7.4 To be released. - Fixed a bug the `-T`/`--no-tunnel` option in the `fedify inbox` command was being ignored, causing the server to always create a public tunnel regardless of the flag. [[#243], [#284] by Lee ByeongJun] [#243]: https://github.com/fedify-dev/fedify/issues/243 [#284]: https://github.com/fedify-dev/fedify/pull/284 Version 1.7.3 ------------- Loading
cli/inbox.test.ts 0 → 100644 +77 −0 Original line number Diff line number Diff line import { assertEquals } from "@std/assert"; import { type InboxOptions, TunnelConfig } from "./inbox.tsx"; Deno.test("handles --no-tunnel flag correctly", () => { const optionsWithNoTunnel: InboxOptions = { tunnel: false, follow: undefined, acceptFollow: undefined, }; assertEquals( TunnelConfig.shouldDisableTunnel(optionsWithNoTunnel), true, "--no-tunnel flag should disable tunnel", ); }); Deno.test("set noTunnel true, should handles -T flag correctly", () => { const optionsWithT: InboxOptions = { tunnel: true, noTunnel: true, follow: undefined, acceptFollow: undefined, }; assertEquals( TunnelConfig.shouldDisableTunnel(optionsWithT), true, "-T flag should disable tunnel", ); }); Deno.test("handles default behavior (no flags)", () => { const optionsDefault: InboxOptions = { tunnel: true, follow: undefined, acceptFollow: undefined, }; assertEquals( TunnelConfig.shouldDisableTunnel(optionsDefault), false, "Default behavior should enable tunnel", ); }); Deno.test("handles both flags together", () => { const optionsBothFlags: InboxOptions = { tunnel: false, noTunnel: true, follow: undefined, acceptFollow: undefined, }; assertEquals( TunnelConfig.shouldDisableTunnel(optionsBothFlags), true, "Both flags should disable tunnel", ); }); Deno.test("Various InboxOptions combinations", () => { const validOptions: InboxOptions[] = [ { tunnel: true }, { tunnel: false }, { tunnel: true, noTunnel: true }, { tunnel: false, noTunnel: false }, { tunnel: true, follow: ["@user@example.com"] }, { tunnel: true, acceptFollow: ["*"] }, { tunnel: true, follow: [], acceptFollow: [] }, ]; for (const options of validOptions) { const result = TunnelConfig.shouldDisableTunnel(options); assertEquals( typeof result, "boolean", "shouldDisableTunnel must return boolean", ); } });
cli/inbox.tsx +18 −2 Original line number Diff line number Diff line Loading @@ -37,6 +37,22 @@ import { spawnTemporaryServer, type TemporaryServer } from "./tempserver.ts"; const logger = getLogger(["fedify", "cli", "inbox"]); /** * Options for the inbox command. */ export interface InboxOptions { follow?: string[]; acceptFollow?: string[]; tunnel: boolean; noTunnel?: boolean; // for -T shorthand support } export const TunnelConfig = { shouldDisableTunnel: (opts: InboxOptions): boolean => { return opts.tunnel === false || opts.noTunnel === true; }, } as const; export const command = new Command() .description( "Spins up an ephemeral server that serves the ActivityPub inbox with " + Loading @@ -61,13 +77,13 @@ export const command = new Command() "-T, --no-tunnel", "Do not tunnel the ephemeral ActivityPub server to the public Internet.", ) .action(async (options) => { .action(async (options: InboxOptions) => { const spinner = ora({ text: "Spinning up an ephemeral ActivityPub server...", discardStdin: false, }).start(); const server = await spawnTemporaryServer(fetch, { noTunnel: !options.tunnel, noTunnel: TunnelConfig.shouldDisableTunnel(options), }); spinner.succeed( `The ephemeral ActivityPub server is up and running: ${ Loading