smodusermc commited on
Commit
7ef9510
·
verified ·
1 Parent(s): cfceaf9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -258,12 +258,14 @@ async def init_database():
258
  (GLOBAL_CONVERSATION_ID,)
259
  )
260
 
261
- # Backfill: any message that somehow predates conversations gets the lobby
 
 
262
  await db.execute(
263
  "UPDATE messages SET conversation_id = ? "
264
  "WHERE conversation_id IS NULL OR conversation_id NOT IN "
265
- "(SELECT id FROM conversations WHERE id = ?)",
266
- (GLOBAL_CONVERSATION_ID, GLOBAL_CONVERSATION_ID)
267
  )
268
 
269
  # --- Indexes ---
 
258
  (GLOBAL_CONVERSATION_ID,)
259
  )
260
 
261
+ # Backfill: any message that somehow predates conversations gets the lobby.
262
+ # Only do this when there is no matching conversation id at all (NULL or
263
+ # missing) — never rewrite valid DM/group messages back to Global.
264
  await db.execute(
265
  "UPDATE messages SET conversation_id = ? "
266
  "WHERE conversation_id IS NULL OR conversation_id NOT IN "
267
+ "(SELECT id FROM conversations)",
268
+ (GLOBAL_CONVERSATION_ID,)
269
  )
270
 
271
  # --- Indexes ---