This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2022-11-24 03:50:32 -08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: status_reactions
|
|
|
|
#
|
|
|
|
# id :bigint(8) not null, primary key
|
|
|
|
# account_id :bigint(8) not null
|
|
|
|
# status_id :bigint(8) not null
|
|
|
|
# name :string default(""), not null
|
|
|
|
# custom_emoji_id :bigint(8)
|
|
|
|
# created_at :datetime not null
|
|
|
|
# updated_at :datetime not null
|
|
|
|
#
|
|
|
|
class StatusReaction < ApplicationRecord
|
|
|
|
belongs_to :account
|
|
|
|
belongs_to :status, inverse_of: :status_reactions
|
|
|
|
belongs_to :custom_emoji, optional: true
|
|
|
|
|
2022-12-07 04:47:03 -08:00
|
|
|
has_one :notification, as: :activity, dependent: :destroy
|
|
|
|
|
2022-11-24 03:50:32 -08:00
|
|
|
validates :name, presence: true
|
|
|
|
validates_with StatusReactionValidator
|
|
|
|
|
|
|
|
before_validation :set_custom_emoji
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_custom_emoji
|
2022-12-07 04:19:36 -08:00
|
|
|
self.custom_emoji = CustomEmoji.find_by(shortcode: name, domain: account.domain) if name.blank?
|
2022-11-24 03:50:32 -08:00
|
|
|
end
|
|
|
|
end
|