Skip to content

Commit 5284ec7

Browse files
committed
lint
1 parent 88f4ff9 commit 5284ec7

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

agixt/Conversations.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4527,11 +4527,12 @@ def get_group_conversations_for_company(self, company_id):
45274527
notification_mode = (
45284528
getattr(participant, "notification_mode", None) or "all"
45294529
)
4530+
notification_count = 0
45304531
if notification_mode == "none":
45314532
# User muted this channel — never show notification dot
45324533
has_notifications = False
45334534
elif participant and participant.last_read_at:
4534-
unread_count = (
4535+
notification_count = (
45354536
session.query(Message)
45364537
.filter(
45374538
Message.conversation_id == conv_id,
@@ -4542,18 +4543,18 @@ def get_group_conversations_for_company(self, company_id):
45424543
)
45434544
.count()
45444545
)
4545-
has_notifications = unread_count > 0
4546+
has_notifications = notification_count > 0
45464547
else:
45474548
# Check notify flag as fallback
4548-
has_notifications = (
4549+
notification_count = (
45494550
session.query(Message)
45504551
.filter(
45514552
Message.conversation_id == conv_id,
45524553
Message.notify == True,
45534554
)
45544555
.count()
4555-
> 0
45564556
)
4557+
has_notifications = notification_count > 0
45574558

45584559
# Count participants
45594560
participant_count = (
@@ -4590,6 +4591,7 @@ def get_group_conversations_for_company(self, company_id):
45904591
conversation.updated_at, user_id=user_id
45914592
),
45924593
"has_notifications": has_notifications,
4594+
"notification_count": notification_count,
45934595
"summary": conversation.summary or "None available",
45944596
"attachment_count": conversation.attachment_count or 0,
45954597
"pin_order": conversation.pin_order,

agixt/endpoints/Conversation.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2963,10 +2963,29 @@ async def notify_conversation_participants_message_added(
29632963
Also sends targeted 'mention' and 'reply' notifications to @mentioned and replied-to users.
29642964
"""
29652965
try:
2966-
from DB import get_session, ConversationParticipant
2966+
from DB import get_session, ConversationParticipant, User, Conversation
29672967
import re
29682968

29692969
preview = message[:100] + "..." if len(message) > 100 else message
2970+
2971+
# Look up sender display name and conversation's company_id
2972+
sender_name = "Someone"
2973+
company_id = None
2974+
with get_session() as session:
2975+
sender = session.query(User).filter(User.id == sender_user_id).first()
2976+
if sender:
2977+
first = getattr(sender, "first_name", "") or ""
2978+
last = getattr(sender, "last_name", "") or ""
2979+
sender_name = f"{first} {last}".strip() or "Someone"
2980+
# Look up company_id from the conversation
2981+
conv = (
2982+
session.query(Conversation)
2983+
.filter(Conversation.id == conversation_id)
2984+
.first()
2985+
)
2986+
if conv and conv.company_id:
2987+
company_id = str(conv.company_id)
2988+
29702989
notification_data = {
29712990
"type": "message_added",
29722991
"data": {
@@ -2976,6 +2995,8 @@ async def notify_conversation_participants_message_added(
29762995
"message_preview": preview,
29772996
"role": role,
29782997
"sender_user_id": sender_user_id,
2998+
"sender_name": sender_name,
2999+
"company_id": company_id,
29793000
"timestamp": datetime.now().isoformat(),
29803001
},
29813002
}
@@ -3027,6 +3048,8 @@ async def notify_conversation_participants_message_added(
30273048
"message_preview": preview,
30283049
"role": role,
30293050
"sender_user_id": sender_user_id,
3051+
"sender_name": sender_name,
3052+
"company_id": company_id,
30303053
"timestamp": datetime.now().isoformat(),
30313054
},
30323055
}
@@ -3044,6 +3067,8 @@ async def notify_conversation_participants_message_added(
30443067
"message_preview": preview,
30453068
"role": role,
30463069
"sender_user_id": sender_user_id,
3070+
"sender_name": sender_name,
3071+
"company_id": company_id,
30473072
"timestamp": datetime.now().isoformat(),
30483073
},
30493074
}

0 commit comments

Comments
 (0)