Add custom_emoji
to reacted?
Signed-off-by: Plastikmensch <plastikmensch@users.noreply.github.com>
This commit is contained in:
parent
029e18f9b8
commit
762d9bbb97
4 changed files with 19 additions and 6 deletions
|
@ -6,8 +6,7 @@ class ActivityPub::Activity::EmojiReact < ActivityPub::Activity
|
|||
name = @json['content']
|
||||
return if original_status.nil? ||
|
||||
!original_status.account.local? ||
|
||||
delete_arrived_first?(@json['id']) ||
|
||||
@account.reacted?(original_status, name)
|
||||
delete_arrived_first?(@json['id'])
|
||||
|
||||
custom_emoji = nil
|
||||
if /^:.*:$/.match?(name)
|
||||
|
@ -18,6 +17,8 @@ class ActivityPub::Activity::EmojiReact < ActivityPub::Activity
|
|||
return if custom_emoji.nil?
|
||||
end
|
||||
|
||||
return if @account.reacted?(original_status, name, custom_emoji)
|
||||
|
||||
reaction = original_status.status_reactions.create!(account: @account, name: name, custom_emoji: custom_emoji)
|
||||
|
||||
LocalNotificationWorker.perform_async(original_status.account_id, reaction.id, 'StatusReaction', 'reaction')
|
||||
|
|
|
@ -29,7 +29,7 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
|
|||
custom_emoji = CustomEmoji.find_by(shortcode: name, domain: @account.domain)
|
||||
return false if custom_emoji.nil? # invalid custom emoji, treat it as a regular like
|
||||
end
|
||||
return true if @account.reacted?(original_status, name)
|
||||
return true if @account.reacted?(original_status, name, custom_emoji)
|
||||
|
||||
reaction = original_status.status_reactions.create!(account: @account, name: name, custom_emoji: custom_emoji)
|
||||
LocalNotificationWorker.perform_async(original_status.account_id, reaction.id, 'StatusReaction', 'reaction')
|
||||
|
|
|
@ -117,13 +117,25 @@ class ActivityPub::Activity::Undo < ActivityPub::Activity
|
|||
|
||||
def undo_emoji_react
|
||||
name = @object['content']
|
||||
tags = @object['tag']
|
||||
return if name.nil?
|
||||
|
||||
status = status_from_uri(target_uri)
|
||||
name.delete! ':'
|
||||
|
||||
return if status.nil? || !status.account.local?
|
||||
|
||||
if @account.reacted?(status, name.delete(':'))
|
||||
custom_emoji = nil
|
||||
emoji_tag = as_array(tags).find { |tag| tag['type'] == 'Emoji' }
|
||||
|
||||
if emoji_tag
|
||||
custom_emoji_parser = ActivityPub::Parser::CustomEmojiParser.new(emoji_tag)
|
||||
return if custom_emoji_parser.shortcode.blank? || custom_emoji_parser.image_remote_url.blank?
|
||||
|
||||
custom_emoji = CustomEmoji.find_by(shortcode: custom_emoji_parser.shortcode, domain: @account.domain)
|
||||
end
|
||||
|
||||
if @account.reacted?(status, name, custom_emoji)
|
||||
reaction = status.status_reactions.where(account: @account, name: name).first
|
||||
reaction&.destroy
|
||||
else
|
||||
|
|
|
@ -243,8 +243,8 @@ module AccountInteractions
|
|||
status.proper.favourites.where(account: self).exists?
|
||||
end
|
||||
|
||||
def reacted?(status, name)
|
||||
status.proper.status_reactions.where(account: self, name: name).exists?
|
||||
def reacted?(status, name, custom_emoji = nil)
|
||||
status.proper.status_reactions.where(account: self, name: name, custom_emoji: custom_emoji).exists?
|
||||
end
|
||||
|
||||
def bookmarked?(status)
|
||||
|
|
Loading…
Reference in a new issue