mirror of
https://codeberg.org/rimu/pyfedi
synced 2025-01-24 03:43:42 -08:00
better chat notification link
This commit is contained in:
parent
a652cb7302
commit
e5bfd1b4c9
2 changed files with 4 additions and 5 deletions
|
@ -458,7 +458,7 @@ def process_inbox_request(request_json, activitypublog_id, ip_address):
|
||||||
|
|
||||||
# Notify recipient
|
# Notify recipient
|
||||||
notify = Notification(title=shorten_string('New message from ' + sender.display_name()),
|
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)
|
author_id=sender.id)
|
||||||
db.session.add(notify)
|
db.session.add(notify)
|
||||||
recipient.unread_notifications += 1
|
recipient.unread_notifications += 1
|
||||||
|
|
|
@ -14,21 +14,20 @@ def send_message(message: str, conversation_id: int) -> ChatMessage:
|
||||||
reply = ChatMessage(sender_id=current_user.id, conversation_id=conversation.id,
|
reply = ChatMessage(sender_id=current_user.id, conversation_id=conversation.id,
|
||||||
body=message, body_html=allowlist_html(markdown_to_html(message)))
|
body=message, body_html=allowlist_html(markdown_to_html(message)))
|
||||||
conversation.updated_at = utcnow()
|
conversation.updated_at = utcnow()
|
||||||
|
db.session.add(reply)
|
||||||
|
db.session.commit()
|
||||||
for recipient in conversation.members:
|
for recipient in conversation.members:
|
||||||
if recipient.id != current_user.id:
|
if recipient.id != current_user.id:
|
||||||
if recipient.is_local():
|
if recipient.is_local():
|
||||||
# Notify local recipient
|
# Notify local recipient
|
||||||
notify = Notification(title=shorten_string('New message from ' + current_user.display_name()),
|
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,
|
user_id=recipient.id,
|
||||||
author_id=current_user.id)
|
author_id=current_user.id)
|
||||||
db.session.add(notify)
|
db.session.add(notify)
|
||||||
recipient.unread_notifications += 1
|
recipient.unread_notifications += 1
|
||||||
db.session.add(reply)
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
else:
|
else:
|
||||||
db.session.add(reply)
|
|
||||||
db.session.commit()
|
|
||||||
# Federate reply
|
# Federate reply
|
||||||
reply_json = {
|
reply_json = {
|
||||||
"actor": current_user.profile_id(),
|
"actor": current_user.profile_id(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue