fix: unread badge counts only new conversation system, removes legacy PM/group counting
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
Legacy private_messages and group_messages are no longer used. Badge now only counts from conv_messages table. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
7b000dc3e0
commit
c293e7b631
@ -643,34 +643,12 @@ def messages_reply(message_id):
|
||||
@login_required
|
||||
@member_required
|
||||
def api_unread_count():
|
||||
"""API: Liczba nieprzeczytanych wiadomości (1:1 + grupowe)"""
|
||||
"""API: Liczba nieprzeczytanych wiadomości (nowy system konwersacji)"""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
from sqlalchemy import func
|
||||
from database import MessageGroupMember, GroupMessage
|
||||
|
||||
# 1:1 unread
|
||||
pm_count = db.query(PrivateMessage).filter(
|
||||
PrivateMessage.recipient_id == current_user.id,
|
||||
PrivateMessage.is_read == False
|
||||
).count()
|
||||
|
||||
# Group unread
|
||||
group_count = 0
|
||||
memberships = db.query(MessageGroupMember).filter(
|
||||
MessageGroupMember.user_id == current_user.id
|
||||
).all()
|
||||
for m in memberships:
|
||||
q = db.query(func.count(GroupMessage.id)).filter(
|
||||
GroupMessage.group_id == m.group_id,
|
||||
GroupMessage.sender_id != current_user.id
|
||||
)
|
||||
if m.last_read_at:
|
||||
q = q.filter(GroupMessage.created_at > m.last_read_at)
|
||||
group_count += q.scalar() or 0
|
||||
|
||||
# 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,
|
||||
@ -685,7 +663,7 @@ def api_unread_count():
|
||||
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})
|
||||
return jsonify({'count': conv_count})
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user