Fix ruby lint
This commit is contained in:
parent
df6de7daf5
commit
f157a509d6
6 changed files with 52 additions and 65 deletions
|
@ -10,35 +10,34 @@
|
|||
# name :string default(""), not null
|
||||
# custom_emoji_id :bigint(8)
|
||||
# uri :string
|
||||
# created_at :datetime
|
||||
# updated_at :datetime
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
||||
class EmojiReaction < ApplicationRecord
|
||||
include Paginable
|
||||
|
||||
update_index('statuses', :status)
|
||||
|
||||
belongs_to :account, inverse_of: :emoji_reactions
|
||||
belongs_to :status, inverse_of: :emoji_reactions
|
||||
belongs_to :custom_emojis, optional: true
|
||||
|
||||
has_one :notification, as: :activity, dependent: :destroy
|
||||
|
||||
validates :status_id, uniqueness: { scope: :account_id }
|
||||
|
||||
before_validation do
|
||||
self.status = status.reblog if status&.reblog?
|
||||
end
|
||||
|
||||
after_destroy :invalidate_cleanup_info
|
||||
|
||||
private
|
||||
|
||||
def invalidate_cleanup_info
|
||||
return unless status&.account_id == account_id && account.local?
|
||||
|
||||
account.statuses_cleanup_policy&.invalidate_last_inspected(status, :unfav)
|
||||
end
|
||||
include Paginable
|
||||
|
||||
update_index('statuses', :status)
|
||||
|
||||
belongs_to :account, inverse_of: :emoji_reactions
|
||||
belongs_to :status, inverse_of: :emoji_reactions
|
||||
belongs_to :custom_emojis, optional: true
|
||||
|
||||
has_one :notification, as: :activity, dependent: :destroy
|
||||
|
||||
after_create :refresh_cache
|
||||
after_destroy :refresh_cache
|
||||
after_destroy :invalidate_cleanup_info
|
||||
|
||||
private
|
||||
|
||||
def refresh_cache
|
||||
status&.refresh_emoji_reactions_grouped_by_name!
|
||||
end
|
||||
|
||||
|
||||
def invalidate_cleanup_info
|
||||
return unless status&.account_id == account_id && account.local?
|
||||
|
||||
account.statuses_cleanup_policy&.invalidate_last_inspected(status, :unfav)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
# replies_count :bigint(8) default(0), not null
|
||||
# reblogs_count :bigint(8) default(0), not null
|
||||
# favourites_count :bigint(8) default(0), not null
|
||||
# emoji_reactions :string
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# emoji_reactions :string
|
||||
#
|
||||
|
||||
class StatusStat < ApplicationRecord
|
||||
|
|
|
@ -1,31 +1,23 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# name: string,
|
||||
#count: number,
|
||||
#account_ids: Array<string>,
|
||||
#me: boolean,
|
||||
#url: string,
|
||||
#domain: string
|
||||
|
||||
class REST::EmojiReactionsGroupedByNameSerializer < ActiveModel::Serializer
|
||||
attributes :name, :count
|
||||
|
||||
attribute :me, if: :current_user?
|
||||
attribute :url, if: :custom_emoji?
|
||||
attribute :static_url, if: :custom_emoji?
|
||||
attribute :domain, if: :custom_emoji?
|
||||
attribute :account_ids, if: :has_account_ids?
|
||||
attributes :name, :count
|
||||
|
||||
def current_user?
|
||||
!current_user.nil?
|
||||
end
|
||||
attribute :me, if: :current_user?
|
||||
attribute :url, if: :custom_emoji?
|
||||
attribute :static_url, if: :custom_emoji?
|
||||
attribute :domain, if: :custom_emoji?
|
||||
attribute :account_ids, if: :account_ids?
|
||||
|
||||
def custom_emoji?
|
||||
object.respond_to?(:custom_emoji)
|
||||
end
|
||||
def current_user?
|
||||
!current_user.nil?
|
||||
end
|
||||
|
||||
def has_account_ids?
|
||||
object.respond_to?(:account_ids)
|
||||
end
|
||||
def custom_emoji?
|
||||
object.respond_to?(:custom_emoji)
|
||||
end
|
||||
|
||||
def account_ids?
|
||||
object.respond_to?(:account_ids)
|
||||
end
|
||||
end
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue