Skip to content

Commit 056257a

Browse files
sweetmantechclaude
andauthored
feat: add --account flag to notifications command (#12)
Passes account_id in POST body so org keys can send notifications on behalf of member accounts. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0a2c6d2 commit 056257a

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

__tests__/commands/notifications.test.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,49 @@ describe("notifications command", () => {
134134
);
135135
});
136136

137+
it("passes account_id when --account flag is provided", async () => {
138+
vi.mocked(post).mockResolvedValue({
139+
success: true,
140+
message: "Email sent successfully.",
141+
id: "email-account",
142+
});
143+
144+
await notificationsCommand.parseAsync(
145+
[
146+
"--subject",
147+
"Override Test",
148+
"--text",
149+
"Hello member",
150+
"--account",
151+
"550e8400-e29b-41d4-a716-446655440000",
152+
],
153+
{ from: "user" },
154+
);
155+
156+
expect(post).toHaveBeenCalledWith("/api/notifications", {
157+
subject: "Override Test",
158+
text: "Hello member",
159+
account_id: "550e8400-e29b-41d4-a716-446655440000",
160+
});
161+
});
162+
163+
it("does not include account_id when --account is omitted", async () => {
164+
vi.mocked(post).mockResolvedValue({
165+
success: true,
166+
message: "Email sent successfully.",
167+
id: "email-no-account",
168+
});
169+
170+
await notificationsCommand.parseAsync(
171+
["--subject", "Test"],
172+
{ from: "user" },
173+
);
174+
175+
expect(post).toHaveBeenCalledWith("/api/notifications", {
176+
subject: "Test",
177+
});
178+
});
179+
137180
it("prints error on failure", async () => {
138181
vi.mocked(post).mockRejectedValue(new Error("No email address found"));
139182

src/commands/notifications.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const notificationsCommand = new Command("notifications")
99
.option("--html <body>", "Raw HTML body (takes precedence over --text)")
1010
.option("--cc <email>", "CC recipient (repeatable)", (val: string, prev: string[]) => prev.concat(val), [] as string[])
1111
.option("--room-id <id>", "Room ID for chat link in footer")
12+
.option("--account <accountId>", "Send to a specific account (org keys only)")
1213
.option("--json", "Output as JSON")
1314
.action(async (opts) => {
1415
try {
@@ -19,6 +20,7 @@ export const notificationsCommand = new Command("notifications")
1920
if (opts.html) body.html = opts.html;
2021
if (opts.cc && opts.cc.length > 0) body.cc = opts.cc;
2122
if (opts.roomId) body.room_id = opts.roomId;
23+
if (opts.account) body.account_id = opts.account;
2224

2325
const data = await post("/api/notifications", body);
2426

0 commit comments

Comments
 (0)