about summary refs log tree commit diff
path: root/app/models
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-10-19 01:47:29 +0200
committerGitHub <noreply@github.com>2018-10-19 01:47:29 +0200
commita38a452481d0f5207bb27ba7a2707c0028d2ac18 (patch)
tree5dfe4cab0fd6ebe15c924bd83e3abb6efca210db /app/models
parentbebe8ec887ba67c51353e09d7758819b117bf62d (diff)
Add unread indicator to conversations (#9009)
Diffstat (limited to 'app/models')
-rw-r--r--app/models/account_conversation.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/app/models/account_conversation.rb b/app/models/account_conversation.rb
index c12c8d233..b7447d805 100644
--- a/app/models/account_conversation.rb
+++ b/app/models/account_conversation.rb
@@ -10,6 +10,7 @@
 #  status_ids              :bigint(8)        default([]), not null, is an Array
 #  last_status_id          :bigint(8)
 #  lock_version            :integer          default(0), not null
+#  unread                  :boolean          default(FALSE), not null
 #
 
 class AccountConversation < ApplicationRecord
@@ -58,6 +59,7 @@ class AccountConversation < ApplicationRecord
     def add_status(recipient, status)
       conversation = find_or_initialize_by(account: recipient, conversation_id: status.conversation_id, participant_account_ids: participants_from_status(recipient, status))
       conversation.status_ids << status.id
+      conversation.unread = status.account_id != recipient.id
       conversation.save
       conversation
     rescue ActiveRecord::StaleObjectError