diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2018-10-07 23:44:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-07 23:44:58 +0200 |
commit | 774ac473736cbf348827cf6d861e7fbbb72d7623 (patch) | |
tree | c8ce87b43cd8fa58f7124a8a6baf93a71cb274e8 /app/models/status.rb | |
parent | 25744d43b0c9ae58227e1e46ac9e2b33a7944925 (diff) |
Add conversations API (#8832)
* Add conversations API * Add web UI for conversations * Add test for conversations API * Add tests for ConversationAccount * Improve web UI * Rename ConversationAccount to AccountConversation * Remove conversations on block and mute * Change last_status_id to be a denormalization of status_ids * Add optimistic locking
Diffstat (limited to 'app/models/status.rb')
-rw-r--r-- | app/models/status.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/app/models/status.rb b/app/models/status.rb index f2b5cc6ce..f61bd0fee 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -24,6 +24,8 @@ # class Status < ApplicationRecord + before_destroy :unlink_from_conversations + include Paginable include Streamable include Cacheable @@ -473,4 +475,15 @@ class Status < ApplicationRecord reblog&.decrement_count!(:reblogs_count) if reblog? thread&.decrement_count!(:replies_count) if in_reply_to_id.present? && (public_visibility? || unlisted_visibility?) end + + def unlink_from_conversations + return unless direct_visibility? + + mentioned_accounts = mentions.includes(:account).map(&:account) + inbox_owners = mentioned_accounts.select(&:local?) + (account.local? ? [account] : []) + + inbox_owners.each do |inbox_owner| + AccountConversation.remove_status(inbox_owner, self) + end + end end |