Webhooks for the AT Protocol airglow.run
atproto atprotocol automation webhook
12
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: allow to remove all conditions

Hugo e3ed6425 2ccaf6a4

+31 -2
+2 -2
app/islands/AutomationForm.tsx
··· 472 472 const payload: Record<string, unknown> = { name, lexicon }; 473 473 if (description.trim()) payload.description = description.trim(); 474 474 const filteredFetches = fetches.filter((f) => f.name && f.uri); 475 - if (filteredFetches.length > 0) { 475 + if (filteredFetches.length > 0 || isEdit) { 476 476 payload.fetches = filteredFetches.map((f) => ({ 477 477 name: f.name, 478 478 uri: f.uri, ··· 480 480 })); 481 481 } 482 482 const filteredConditions = conditions.filter((c) => c.field && c.value); 483 - if (filteredConditions.length > 0) { 483 + if (filteredConditions.length > 0 || isEdit) { 484 484 payload.conditions = filteredConditions.map((c) => ({ 485 485 field: c.field, 486 486 operator: c.operator,
+29
app/routes/api/automations/[rkey].test.ts
··· 224 224 expect(action.secret).toHaveLength(32); 225 225 }); 226 226 227 + it("clears conditions when empty array is sent", async () => { 228 + // Start with conditions 229 + await db 230 + .update(automations) 231 + .set({ conditions: [{ field: "event.did", operator: "eq", value: "did:plc:someone" }] }) 232 + .where(eq(automations.uri, TEST_AUTO.uri)); 233 + 234 + const res = await app.request(patchReq("rk1", { conditions: [] })); 235 + expect(res.status).toBe(200); 236 + 237 + const auto = await db.query.automations.findFirst(); 238 + expect(auto!.conditions).toEqual([]); 239 + }); 240 + 241 + it("preserves conditions when field is omitted from PATCH body", async () => { 242 + const existingConditions = [{ field: "event.did", operator: "eq", value: "did:plc:someone" }]; 243 + await db 244 + .update(automations) 245 + .set({ conditions: existingConditions }) 246 + .where(eq(automations.uri, TEST_AUTO.uri)); 247 + 248 + const res = await app.request(patchReq("rk1", { name: "Renamed" })); 249 + expect(res.status).toBe(200); 250 + 251 + const auto = await db.query.automations.findFirst(); 252 + expect(auto!.conditions).toEqual(existingConditions); 253 + expect(auto!.name).toBe("Renamed"); 254 + }); 255 + 227 256 it("validates conditions", async () => { 228 257 const res = await app.request( 229 258 patchReq("rk1", {