Progress on DMs
Progress on DMs
This commit is contained in:
@@ -27,7 +27,7 @@ class ChatConversationAccount < ApplicationRecord
|
||||
EXPIRATION_POLICY_MAP = {
|
||||
none: nil,
|
||||
five_minutes: '1',
|
||||
sixty_minutes: '2',
|
||||
one_hour: '2',
|
||||
six_hours: '3',
|
||||
one_day: '4',
|
||||
three_days: '5',
|
||||
|
||||
@@ -23,6 +23,7 @@ class ChatMessage < ApplicationRecord
|
||||
|
||||
default_scope { recent }
|
||||
|
||||
scope :expired, -> { where.not(expires_at: nil).where('expires_at < ?', Time.now.utc) }
|
||||
scope :recent, -> { reorder(created_at: :desc) }
|
||||
|
||||
def emojis
|
||||
|
||||
@@ -24,6 +24,14 @@ module AccountInteractions
|
||||
follow_mapping(Block.where(account_id: target_account_ids, target_account_id: account_id), :account_id)
|
||||
end
|
||||
|
||||
def chat_blocking_map(target_account_ids, account_id)
|
||||
follow_mapping(ChatBlock.where(target_account_id: target_account_ids, account_id: account_id), :target_account_id)
|
||||
end
|
||||
|
||||
def chat_blocked_by_map(target_account_ids, account_id)
|
||||
follow_mapping(ChatBlock.where(account_id: target_account_ids, target_account_id: account_id), :account_id)
|
||||
end
|
||||
|
||||
def muting_map(target_account_ids, account_id)
|
||||
Mute.where(target_account_id: target_account_ids, account_id: account_id).each_with_object({}) do |mute, mapping|
|
||||
mapping[mute.target_account_id] = {
|
||||
@@ -97,6 +105,10 @@ module AccountInteractions
|
||||
.find_or_create_by!(target_account: other_account)
|
||||
end
|
||||
|
||||
def chat_block!(other_account)
|
||||
chat_block_relationships.find_or_create_by!(target_account: other_account)
|
||||
end
|
||||
|
||||
def mute!(other_account, notifications: nil)
|
||||
notifications = true if notifications.nil?
|
||||
mute = mute_relationships.create_with(hide_notifications: notifications).find_or_create_by!(target_account: other_account)
|
||||
@@ -120,6 +132,11 @@ module AccountInteractions
|
||||
block&.destroy
|
||||
end
|
||||
|
||||
def chat_unblock!(other_account)
|
||||
block = chat_block_relationships.find_by(target_account: other_account)
|
||||
block&.destroy
|
||||
end
|
||||
|
||||
def unmute!(other_account)
|
||||
mute = mute_relationships.find_by(target_account: other_account)
|
||||
mute&.destroy
|
||||
@@ -133,6 +150,14 @@ module AccountInteractions
|
||||
block_relationships.where(target_account: other_account).exists?
|
||||
end
|
||||
|
||||
def chat_blocking?(other_account)
|
||||
chat_block_relationships.where(target_account: other_account).exists?
|
||||
end
|
||||
|
||||
def chat_blocked_by(target_account_id, account_id)
|
||||
ChatBlock.where(account_id: target_account_id, target_account_id: account_id).exists?
|
||||
end
|
||||
|
||||
def muting?(other_account)
|
||||
mute_relationships.where(target_account: other_account).exists?
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user