fix: unread badge counts messages from new conversation system
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
The badge endpoint api_unread_count only counted legacy private_messages and group_messages. Now also counts unread conv_messages from the new conversations system, fixing phantom unread counts for users. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
026190d740
commit
fcea91fb2a
@ -669,7 +669,23 @@ def api_unread_count():
|
|||||||
q = q.filter(GroupMessage.created_at > m.last_read_at)
|
q = q.filter(GroupMessage.created_at > m.last_read_at)
|
||||||
group_count += q.scalar() or 0
|
group_count += q.scalar() or 0
|
||||||
|
|
||||||
return jsonify({'count': pm_count + group_count})
|
# Conversations unread (new messaging system)
|
||||||
|
from database import ConversationMember, ConvMessage
|
||||||
|
conv_count = 0
|
||||||
|
conv_memberships = db.query(ConversationMember).filter(
|
||||||
|
ConversationMember.user_id == current_user.id,
|
||||||
|
ConversationMember.is_archived == False
|
||||||
|
).all()
|
||||||
|
for cm in conv_memberships:
|
||||||
|
q = db.query(func.count(ConvMessage.id)).filter(
|
||||||
|
ConvMessage.conversation_id == cm.conversation_id,
|
||||||
|
ConvMessage.sender_id != current_user.id
|
||||||
|
)
|
||||||
|
if cm.last_read_at:
|
||||||
|
q = q.filter(ConvMessage.created_at > cm.last_read_at)
|
||||||
|
conv_count += q.scalar() or 0
|
||||||
|
|
||||||
|
return jsonify({'count': pm_count + group_count + conv_count})
|
||||||
finally:
|
finally:
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user