Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Neff <benjamin@coding4coffee.ch>2016-03-07 04:01:02 +0300
committerBenjamin Neff <benjamin@coding4coffee.ch>2016-03-07 07:52:54 +0300
commit017842cc0100a40db9b99edbbf71d2238856f226 (patch)
tree5013eb136f686bdc6aa556ec492c7142b1cda939 /app/services
parentd94eae0d45b6a081813271f3d889cf6c430cd8ec (diff)
don't update updated_at date when read the notifications.
updated_at is displayed in the frontend and should only be updated when another notification_actor gets added Also improved the sql-queries: update directly and not select first and update then.
Diffstat (limited to 'app/services')
-rw-r--r--app/services/post_service.rb12
1 files changed, 5 insertions, 7 deletions
diff --git a/app/services/post_service.rb b/app/services/post_service.rb
index 928375e29..4c3d7a6b5 100644
--- a/app/services/post_service.rb
+++ b/app/services/post_service.rb
@@ -46,15 +46,13 @@ class PostService
end
def mark_comment_reshare_like_notifications_read(post_id)
- notifications = Notification.where(recipient_id: user.id, target_type: "Post", target_id: post_id, unread: true)
- notifications.each do |notification|
- notification.set_read_state(true)
- end
+ Notification.where(recipient_id: user.id, target_type: "Post", target_id: post_id, unread: true)
+ .update_all(unread: false)
end
def mark_mention_notifications_read(post_id)
- mention = find(post_id).mentions.where(person_id: user.person_id).first
- Notification.where(recipient_id: user.id, target_type: "Mention", target_id: mention.id, unread: true)
- .first.try(:set_read_state, true) if mention
+ mention_id = Mention.where(post_id: post_id, person_id: user.person_id).pluck(:id)
+ Notification.where(recipient_id: user.id, target_type: "Mention", target_id: mention_id, unread: true)
+ .update_all(unread: false) if mention_id
end
end