Fix `Rails/WhereExists` cop in account/interactions concern (#28789)

shrike
Matt Jankowski 2024-01-18 04:36:16 -05:00 committed by GitHub
parent 4c23297c04
commit 89c9a4502d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 14 deletions

View File

@ -82,7 +82,6 @@ Rails/WhereExists:
- 'app/lib/feed_manager.rb' - 'app/lib/feed_manager.rb'
- 'app/lib/status_cache_hydrator.rb' - 'app/lib/status_cache_hydrator.rb'
- 'app/lib/suspicious_sign_in_detector.rb' - 'app/lib/suspicious_sign_in_detector.rb'
- 'app/models/concerns/account/interactions.rb'
- 'app/models/featured_tag.rb' - 'app/models/featured_tag.rb'
- 'app/models/poll.rb' - 'app/models/poll.rb'
- 'app/models/session_activation.rb' - 'app/models/session_activation.rb'

View File

@ -183,7 +183,7 @@ module Account::Interactions
end end
def following?(other_account) def following?(other_account)
active_relationships.where(target_account: other_account).exists? active_relationships.exists?(target_account: other_account)
end end
def following_anyone? def following_anyone?
@ -199,51 +199,51 @@ module Account::Interactions
end end
def blocking?(other_account) def blocking?(other_account)
block_relationships.where(target_account: other_account).exists? block_relationships.exists?(target_account: other_account)
end end
def domain_blocking?(other_domain) def domain_blocking?(other_domain)
domain_blocks.where(domain: other_domain).exists? domain_blocks.exists?(domain: other_domain)
end end
def muting?(other_account) def muting?(other_account)
mute_relationships.where(target_account: other_account).exists? mute_relationships.exists?(target_account: other_account)
end end
def muting_conversation?(conversation) def muting_conversation?(conversation)
conversation_mutes.where(conversation: conversation).exists? conversation_mutes.exists?(conversation: conversation)
end end
def muting_notifications?(other_account) def muting_notifications?(other_account)
mute_relationships.where(target_account: other_account, hide_notifications: true).exists? mute_relationships.exists?(target_account: other_account, hide_notifications: true)
end end
def muting_reblogs?(other_account) def muting_reblogs?(other_account)
active_relationships.where(target_account: other_account, show_reblogs: false).exists? active_relationships.exists?(target_account: other_account, show_reblogs: false)
end end
def requested?(other_account) def requested?(other_account)
follow_requests.where(target_account: other_account).exists? follow_requests.exists?(target_account: other_account)
end end
def favourited?(status) def favourited?(status)
status.proper.favourites.where(account: self).exists? status.proper.favourites.exists?(account: self)
end end
def bookmarked?(status) def bookmarked?(status)
status.proper.bookmarks.where(account: self).exists? status.proper.bookmarks.exists?(account: self)
end end
def reblogged?(status) def reblogged?(status)
status.proper.reblogs.where(account: self).exists? status.proper.reblogs.exists?(account: self)
end end
def pinned?(status) def pinned?(status)
status_pins.where(status: status).exists? status_pins.exists?(status: status)
end end
def endorsed?(account) def endorsed?(account)
account_pins.where(target_account: account).exists? account_pins.exists?(target_account: account)
end end
def status_matches_filters(status) def status_matches_filters(status)