Mute button progress so far. WIP, doesn't entirely work correctly.
This commit is contained in:
parent
89fc2d7f48
commit
442fdbfc53
26 changed files with 390 additions and 33 deletions
|
@ -46,6 +46,10 @@ class Account < ApplicationRecord
|
|||
has_many :block_relationships, class_name: 'Block', foreign_key: 'account_id', dependent: :destroy
|
||||
has_many :blocking, -> { order('blocks.id desc') }, through: :block_relationships, source: :target_account
|
||||
|
||||
# Mute relationships
|
||||
has_many :mute_relationships, class_name: 'Mute', foreign_key: 'account_id', dependent: :destroy
|
||||
has_many :muting, -> { order('mutes.id desc') }, through: :mute_relationships, source: :target_account
|
||||
|
||||
# Media
|
||||
has_many :media_attachments, dependent: :destroy
|
||||
|
||||
|
@ -73,6 +77,10 @@ class Account < ApplicationRecord
|
|||
block_relationships.where(target_account: other_account).first_or_create!(target_account: other_account)
|
||||
end
|
||||
|
||||
def mute!(other_account)
|
||||
mute_relationships.where(target_account: other_account).first_or_create!(target_account: other_account)
|
||||
end
|
||||
|
||||
def unfollow!(other_account)
|
||||
follow = active_relationships.find_by(target_account: other_account)
|
||||
follow&.destroy
|
||||
|
@ -83,6 +91,11 @@ class Account < ApplicationRecord
|
|||
block&.destroy
|
||||
end
|
||||
|
||||
def unmute!(other_account)
|
||||
mute = mute_relationships.find_by(target_account: other_account)
|
||||
mute&.destroy
|
||||
end
|
||||
|
||||
def following?(other_account)
|
||||
following.include?(other_account)
|
||||
end
|
||||
|
@ -91,6 +104,10 @@ class Account < ApplicationRecord
|
|||
blocking.include?(other_account)
|
||||
end
|
||||
|
||||
def muting?(other_account)
|
||||
muting.include?(other_account)
|
||||
end
|
||||
|
||||
def requested?(other_account)
|
||||
follow_requests.where(target_account: other_account).exists?
|
||||
end
|
||||
|
@ -188,6 +205,10 @@ class Account < ApplicationRecord
|
|||
follow_mapping(Block.where(target_account_id: target_account_ids, account_id: account_id), :target_account_id)
|
||||
end
|
||||
|
||||
def muting_map(target_account_ids, account_id)
|
||||
follow_mapping(Mute.where(target_account_id: target_account_ids, account_id: account_id), :target_account_id)
|
||||
end
|
||||
|
||||
def requested_map(target_account_ids, account_id)
|
||||
follow_mapping(FollowRequest.where(target_account_id: target_account_ids, account_id: account_id), :target_account_id)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue