fix: DM close visibility flag, wire Remove Friend button, harden deploy script

- Redesign DM close as a visibility flag (closed column) instead of row deletion,
  so message broadcasts still reach users who closed a DM conversation
- Add broadcastDmMessage() helper that auto-resurfaces closed DMs when new messages arrive
- Wire Remove Friend button in DM welcome header with onClick handler and friend check
- Fix deploy.sh to cd to its own directory so rsync always runs from project root
This commit is contained in:
Jannis Braun
2026-02-22 22:29:40 +01:00
parent 6b8fd44a3a
commit 5fe43bc0c8
7 changed files with 112 additions and 108 deletions
+3 -12
View File
@@ -3,6 +3,7 @@ import { getDb, schema } from '../db/index.js';
import { generateSnowflake } from '../utils/snowflake.js';
import { connectionManager } from './handler.js';
import { isMember, getChannelServerId, isDmMember } from '../utils/permissions.js';
import { broadcastDmMessage } from '../routes/dm.js';
import type { User, MessageWithUser, Attachment, DmMessageWithUser } from '@opencord/shared';
function sanitizeUser(row: typeof schema.users.$inferSelect): User {
@@ -497,18 +498,8 @@ function handleDmMessageCreate(event: Record<string, unknown>, userId: string):
user: sanitizeUser(user),
};
// Send to all DM members
const dmMembers = db.select()
.from(schema.dmMembers)
.where(eq(schema.dmMembers.dmChannelId, dmChannelId))
.all();
for (const member of dmMembers) {
connectionManager.sendToUser(member.userId, {
type: 'dm_message_created',
message: dmMessage,
});
}
// Broadcast to all DM members (including those who closed the channel)
broadcastDmMessage(dmChannelId, dmMessage);
}
function handleDmTypingStart(event: Record<string, unknown>, userId: string, username: string): void {