fix PUT-1888 (#3992)

This commit is contained in:
Neal Shah authored and GitHub committed 2026-09-29 17:06:28 -04:00
1 parent cd37cf147f
commit 9aa3989e9d
2 files changed
+36

No files matched your search

@@ -93,6 +93,22 @@ export class HostingController extends PuterController {
userId: req.actor.user.id,
});
// Same event the `puter-subdomains` driver fires on delete —
// listeners (CDN purge, abuse tracking, worker cleanup)
// depend on it.
try {
this.clients.event.emit(
'subdomain.delete',
{
subdomain: row.subdomain,
uid: String(row.uuid),
},
{},
);
} catch {
// Non-critical.
}
res.json({});
},
);
@@ -181,4 +181,24 @@ describe('HostingController /delete-site', () => {
expect(captured.body).toEqual({});
expect(await server.stores.subdomain.getByUuid(site.uuid)).toBeNull();
});
it('emits subdomain.delete so listeners can purge caches', async () => {
const { userId, actor } = await makeUser();
const site = await makeSite(userId);
const emitSpy = vi.spyOn(server.clients.event, 'emit');
try {
await deleteSite(
makeReq({ body: { site_uuid: site.uuid }, actor }),
makeRes().res,
);
expect(emitSpy).toHaveBeenCalledWith(
'subdomain.delete',
{ subdomain: site.subdomain, uid: String(site.uuid) },
{},
);
} finally {
emitSpy.mockRestore();
}
});
});