|
|
@ -335,38 +335,30 @@ def put_mark_comments_read( |
|
|
'new' count. If the query param mark_all_previous is Truthy all |
|
|
'new' count. If the query param mark_all_previous is Truthy all |
|
|
notifications prior to the target will be cleared. |
|
|
notifications prior to the target will be cleared. |
|
|
""" |
|
|
""" |
|
|
comment = request.context |
|
|
|
|
|
|
|
|
notification = request.context |
|
|
response = IC_NOOP |
|
|
response = IC_NOOP |
|
|
|
|
|
|
|
|
if mark_all_previous is True: |
|
|
|
|
|
|
|
|
if mark_all_previous: |
|
|
prev_notifications = ( |
|
|
prev_notifications = ( |
|
|
request.query(CommentNotification).filter( |
|
|
request.query(CommentNotification).filter( |
|
|
CommentNotification.is_unread == True, #noqa |
|
|
CommentNotification.is_unread == True, #noqa |
|
|
CommentNotification.created_time <= |
|
|
|
|
|
request.db_session.query(CommentNotification.created_time) |
|
|
|
|
|
.filter( |
|
|
|
|
|
CommentNotification.user == request.user, |
|
|
|
|
|
CommentNotification.comment_id == comment.comment_id, |
|
|
|
|
|
) |
|
|
|
|
|
.as_scalar() |
|
|
|
|
|
|
|
|
CommentNotification.created_time <= notification.created_time |
|
|
) |
|
|
) |
|
|
.options(joinedload(CommentNotification.comment)) |
|
|
.options(joinedload(CommentNotification.comment)) |
|
|
.all() |
|
|
.all() |
|
|
) |
|
|
) |
|
|
|
|
|
|
|
|
for notification in prev_notifications: |
|
|
|
|
|
notification.is_unread = False |
|
|
|
|
|
_increment_topic_comments_seen(request, notification.comment) |
|
|
|
|
|
|
|
|
for comment_notification in prev_notifications: |
|
|
|
|
|
comment_notification.is_unread = False |
|
|
|
|
|
_increment_topic_comments_seen( |
|
|
|
|
|
request, |
|
|
|
|
|
comment_notification.comment |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
response = Response('Your comment notifications have been cleared.') |
|
|
response = Response('Your comment notifications have been cleared.') |
|
|
|
|
|
|
|
|
else: |
|
|
else: |
|
|
request.query(CommentNotification).filter( |
|
|
|
|
|
CommentNotification.user == request.user, |
|
|
|
|
|
CommentNotification.comment == comment, |
|
|
|
|
|
).update( |
|
|
|
|
|
{CommentNotification.is_unread: False}, synchronize_session=False) |
|
|
|
|
|
|
|
|
|
|
|
_increment_topic_comments_seen(request, comment) |
|
|
|
|
|
|
|
|
notification.is_unread = False |
|
|
|
|
|
_increment_topic_comments_seen(request, notification.comment) |
|
|
|
|
|
|
|
|
return response |
|
|
return response |