Fix ruby lint
This commit is contained in:
parent
df6de7daf5
commit
f157a509d6
6 changed files with 52 additions and 65 deletions
|
@ -10,8 +10,8 @@
|
|||
# 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
|
||||
|
@ -25,20 +25,19 @@ class EmojiReaction < ApplicationRecord
|
|||
|
||||
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_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,12 +1,5 @@
|
|||
# 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
|
||||
|
||||
|
@ -14,7 +7,7 @@ class REST::EmojiReactionsGroupedByNameSerializer < ActiveModel::Serializer
|
|||
attribute :url, if: :custom_emoji?
|
||||
attribute :static_url, if: :custom_emoji?
|
||||
attribute :domain, if: :custom_emoji?
|
||||
attribute :account_ids, if: :has_account_ids?
|
||||
attribute :account_ids, if: :account_ids?
|
||||
|
||||
def current_user?
|
||||
!current_user.nil?
|
||||
|
@ -24,8 +17,7 @@ class REST::EmojiReactionsGroupedByNameSerializer < ActiveModel::Serializer
|
|||
object.respond_to?(:custom_emoji)
|
||||
end
|
||||
|
||||
def has_account_ids?
|
||||
def account_ids?
|
||||
object.respond_to?(:account_ids)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
class CreateEmojiReactions < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
create_table :emoji_reactions do |t|
|
||||
|
||||
t.belongs_to :account, null: false, foreign_key: { on_delete: :cascade }, index: false
|
||||
t.belongs_to :account, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.belongs_to :status, null: false, foreign_key: { on_delete: :cascade }
|
||||
t.string :name, null: false, default: ''
|
||||
t.belongs_to :custom_emoji, foreign_key: { on_delete: :cascade }, index: false
|
||||
t.belongs_to :custom_emoji, foreign_key: { on_delete: :cascade }
|
||||
t.string :uri
|
||||
|
||||
t.datetime :created_at, null: false
|
||||
t.datetime :updated_at, null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
class AddCreateAtToEmojiReactions < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :emoji_reactions, :created_at, :timestamp
|
||||
add_column :emoji_reactions, :updated_at, :timestamp
|
||||
end
|
||||
end
|
|
@ -417,8 +417,10 @@ ActiveRecord::Schema.define(version: 2023_02_23_102416) do
|
|||
t.string "name", default: "", null: false
|
||||
t.bigint "custom_emoji_id"
|
||||
t.string "uri"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["account_id"], name: "index_emoji_reactions_on_account_id"
|
||||
t.index ["custom_emoji_id"], name: "index_emoji_reactions_on_custom_emoji_id"
|
||||
t.index ["status_id"], name: "index_emoji_reactions_on_status_id"
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue