Make notifications open comments below THREAD_CUTOFF_DEPTH

This commit is contained in:
Hendrik L 2024-08-19 10:32:54 +02:00
parent db6e198457
commit 11a4f1b101

View file

@ -1921,10 +1921,16 @@ def notify_about_post_reply(parent_reply: Union[PostReply, None], new_reply: Pos
send_notifs_to = set(notification_subscribers(parent_reply.id, NOTIF_REPLY)) send_notifs_to = set(notification_subscribers(parent_reply.id, NOTIF_REPLY))
for notify_id in send_notifs_to: for notify_id in send_notifs_to:
if new_reply.user_id != notify_id: if new_reply.user_id != notify_id:
new_notification = Notification(title=shorten_string(_('Reply to comment on %(post_title)s', if new_reply.depth <= THREAD_CUTOFF_DEPTH:
post_title=parent_reply.post.title), 50), new_notification = Notification(title=shorten_string(_('Reply to comment on %(post_title)s',
url=f"/post/{parent_reply.post.id}#comment_{new_reply.id}", post_title=parent_reply.post.title), 50),
user_id=notify_id, author_id=new_reply.user_id) url=f"/post/{parent_reply.post.id}#comment_{new_reply.id}",
user_id=notify_id, author_id=new_reply.user_id)
else:
new_notification = Notification(title=shorten_string(_('Reply to comment on %(post_title)s',
post_title=parent_reply.post.title), 50),
url=f"/post/{parent_reply.post.id}/comment/{parent_reply.id}#comment_{new_reply.id}",
user_id=notify_id, author_id=new_reply.user_id)
db.session.add(new_notification) db.session.add(new_notification)
user = User.query.get(notify_id) user = User.query.get(notify_id)
user.unread_notifications += 1 user.unread_notifications += 1