feat(pairing): show sender ids across providers
This commit is contained in:
@@ -60,5 +60,28 @@ describe("pairing cli", () => {
|
||||
expect.stringContaining("telegramUserId=123"),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("labels Discord ids as discordUserId", async () => {
|
||||
const { registerPairingCli } = await import("./pairing-cli.js");
|
||||
listProviderPairingRequests.mockResolvedValueOnce([
|
||||
{
|
||||
id: "999",
|
||||
code: "DEF456",
|
||||
createdAt: "2026-01-08T00:00:00Z",
|
||||
lastSeenAt: "2026-01-08T00:00:00Z",
|
||||
meta: { tag: "Ada#0001" },
|
||||
},
|
||||
]);
|
||||
|
||||
const log = vi.spyOn(console, "log").mockImplementation(() => {});
|
||||
const program = new Command();
|
||||
program.name("test");
|
||||
registerPairingCli(program);
|
||||
await program.parseAsync(["pairing", "list", "--provider", "discord"], {
|
||||
from: "user",
|
||||
});
|
||||
expect(log).toHaveBeenCalledWith(
|
||||
expect.stringContaining("discordUserId=999"),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,6 +22,15 @@ const PROVIDERS: PairingProvider[] = [
|
||||
"whatsapp",
|
||||
];
|
||||
|
||||
const PROVIDER_ID_LABELS: Record<PairingProvider, string> = {
|
||||
telegram: "telegramUserId",
|
||||
discord: "discordUserId",
|
||||
slack: "slackUserId",
|
||||
signal: "signalNumber",
|
||||
imessage: "imessageSenderId",
|
||||
whatsapp: "whatsappSenderId",
|
||||
};
|
||||
|
||||
function parseProvider(raw: unknown): PairingProvider {
|
||||
const value = (
|
||||
typeof raw === "string"
|
||||
@@ -93,7 +102,7 @@ export function registerPairingCli(program: Command) {
|
||||
}
|
||||
for (const r of requests) {
|
||||
const meta = r.meta ? JSON.stringify(r.meta) : "";
|
||||
const idLabel = provider === "telegram" ? "telegramUserId" : "id";
|
||||
const idLabel = PROVIDER_ID_LABELS[provider];
|
||||
console.log(
|
||||
`${r.code} ${idLabel}=${r.id}${meta ? ` meta=${meta}` : ""} ${r.createdAt}`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user