fix(iios): thread subject on create, graceful open_thread error, isolated test DB
- openThread/createThread accept a generic `subject` (group name) — stored on the
thread, echoed via listThreads; kernel never interprets it.
- Gateway open_thread now returns an ACK'd { error } on failure instead of throwing
(which never acked → clients hung on "loading"). Non-member/missing-thread opens
fail cleanly.
- Tests run against an isolated `iios_test` database (vitest globalSetup creates +
migrates it; test.env overrides DATABASE_URL) so `pnpm test` can never TRUNCATE the
dev database again. Verified: full suite green, dev DB row counts unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -66,11 +66,20 @@ export class MessageGateway implements OnGatewayInit, OnGatewayConnection {
|
||||
}
|
||||
|
||||
@SubscribeMessage('open_thread')
|
||||
async openThread(@ConnectedSocket() client: Socket, @MessageBody() body: { threadId?: string; membership?: string; creatorRole?: string }) {
|
||||
async openThread(@ConnectedSocket() client: Socket, @MessageBody() body: { threadId?: string; membership?: string; creatorRole?: string; subject?: string }) {
|
||||
const { principal } = client.data as SocketState;
|
||||
const result = await this.messages.openThread(body?.threadId ?? null, principal, { membership: body?.membership, creatorRole: body?.creatorRole });
|
||||
await client.join(result.threadId);
|
||||
return result;
|
||||
try {
|
||||
const result = await this.messages.openThread(body?.threadId ?? null, principal, {
|
||||
membership: body?.membership,
|
||||
creatorRole: body?.creatorRole,
|
||||
subject: body?.subject,
|
||||
});
|
||||
await client.join(result.threadId);
|
||||
return result;
|
||||
} catch (err) {
|
||||
// Fail to an ACK'd error instead of throwing (which never acks → client hangs on "loading").
|
||||
return { error: (err as Error).message ?? 'could not open the conversation' };
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeMessage('add_participant')
|
||||
|
||||
Reference in New Issue
Block a user