Rubocop fixes

This commit is contained in:
Jeremy Kescher 2023-05-08 19:37:56 +02:00
parent 8c64325cc6
commit 0cf94443bd
No known key found for this signature in database
GPG key ID: 80A419A7A613DFA4
7 changed files with 25 additions and 23 deletions

View file

@ -222,6 +222,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
account = account_from_uri(tag['href']) account = account_from_uri(tag['href'])
begin begin
return unless account || DeliveryFailureTracker.available?(tag['href']) return unless account || DeliveryFailureTracker.available?(tag['href'])
account = ActivityPub::FetchRemoteAccountService.new.call(tag['href'], request_id: @options[:request_id]) if account.nil? account = ActivityPub::FetchRemoteAccountService.new.call(tag['href'], request_id: @options[:request_id]) if account.nil?
rescue HTTP::ConnectionError => e rescue HTTP::ConnectionError => e
Rails.logger.info "Fetching account #{tag['href']} failed: #{e}" Rails.logger.info "Fetching account #{tag['href']} failed: #{e}"

View file

@ -10,7 +10,7 @@ class ActivityPub::Activity::EmojiReact < ActivityPub::Activity
@account.reacted?(original_status, name) @account.reacted?(original_status, name)
custom_emoji = nil custom_emoji = nil
if name =~ /^:.*:$/ if /^:.*:$/.match?(name)
process_emoji_tags(@json['tag']) process_emoji_tags(@json['tag'])
name.delete! ':' name.delete! ':'

View file

@ -22,7 +22,7 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
return false if name.nil? return false if name.nil?
custom_emoji = nil custom_emoji = nil
if name =~ /^:.*:$/ if /^:.*:$/.match?(name)
process_emoji_tags(@json['tag']) process_emoji_tags(@json['tag'])
name.delete! ':' name.delete! ':'

View file

@ -20,13 +20,13 @@ class Notification < ApplicationRecord
include Paginable include Paginable
LEGACY_TYPE_CLASS_MAP = { LEGACY_TYPE_CLASS_MAP = {
'Mention' => :mention, 'Mention' => :mention,
'Status' => :reblog, 'Status' => :reblog,
'Follow' => :follow, 'Follow' => :follow,
'FollowRequest' => :follow_request, 'FollowRequest' => :follow_request,
'Favourite' => :favourite, 'Favourite' => :favourite,
'StatusReaction' => :reaction, 'StatusReaction' => :reaction,
'Poll' => :poll, 'Poll' => :poll,
}.freeze }.freeze
TYPES = %i( TYPES = %i(

View file

@ -1,4 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
# == Schema Information # == Schema Information
# #
# Table name: status_reactions # Table name: status_reactions

View file

@ -4,20 +4,20 @@ class UnreactService < BaseService
include Payloadable include Payloadable
def call(account, status, emoji) def call(account, status, emoji)
name, domain = emoji.split('@') name, domain = emoji.split('@')
custom_emoji = CustomEmoji.find_by(shortcode: name, domain: domain) custom_emoji = CustomEmoji.find_by(shortcode: name, domain: domain)
reaction = StatusReaction.find_by(account: account, status: status, name: name, custom_emoji: custom_emoji) reaction = StatusReaction.find_by(account: account, status: status, name: name, custom_emoji: custom_emoji)
return if reaction.nil? return if reaction.nil?
reaction.destroy! reaction.destroy!
json = Oj.dump(serialize_payload(reaction, ActivityPub::UndoEmojiReactionSerializer)) json = Oj.dump(serialize_payload(reaction, ActivityPub::UndoEmojiReactionSerializer))
if status.account.local? if status.account.local?
ActivityPub::RawDistributionWorker.perform_async(json, status.account.id) ActivityPub::RawDistributionWorker.perform_async(json, status.account.id)
else else
ActivityPub::DeliveryWorker.perform_async(json, reaction.account_id, status.account.inbox_url) ActivityPub::DeliveryWorker.perform_async(json, reaction.account_id, status.account.inbox_url)
end
reaction
end end
reaction
end
end end

View file

@ -1,6 +1,6 @@
Fabricator(:status_reaction) do Fabricator(:status_reaction) do
account nil account nil
status nil status nil
name "MyString" name 'MyString'
custom_emoji nil custom_emoji nil
end end