diff --git a/app/activitypub/routes.py b/app/activitypub/routes.py index 8a55f262..d84c5794 100644 --- a/app/activitypub/routes.py +++ b/app/activitypub/routes.py @@ -458,7 +458,7 @@ def process_inbox_request(request_json, activitypublog_id, ip_address): # Notify recipient notify = Notification(title=shorten_string('New message from ' + sender.display_name()), - url=f'/chat/{existing_conversation.id}', user_id=recipient.id, + url=f'/chat/{existing_conversation.id}#message_{new_message}', user_id=recipient.id, author_id=sender.id) db.session.add(notify) recipient.unread_notifications += 1 diff --git a/app/chat/util.py b/app/chat/util.py index 8b149641..4f5114b9 100644 --- a/app/chat/util.py +++ b/app/chat/util.py @@ -14,21 +14,20 @@ def send_message(message: str, conversation_id: int) -> ChatMessage: reply = ChatMessage(sender_id=current_user.id, conversation_id=conversation.id, body=message, body_html=allowlist_html(markdown_to_html(message))) conversation.updated_at = utcnow() + db.session.add(reply) + db.session.commit() for recipient in conversation.members: if recipient.id != current_user.id: if recipient.is_local(): # Notify local recipient notify = Notification(title=shorten_string('New message from ' + current_user.display_name()), - url='/chat/' + str(conversation_id), + url=f'/chat/{conversation_id}#message_{reply.id}', user_id=recipient.id, author_id=current_user.id) db.session.add(notify) recipient.unread_notifications += 1 - db.session.add(reply) db.session.commit() else: - db.session.add(reply) - db.session.commit() # Federate reply reply_json = { "actor": current_user.profile_id(),