Add api for set emoji reactions to toot
This commit is contained in:
parent
f157a509d6
commit
5f7da7bff1
17 changed files with 276 additions and 18 deletions
|
@ -13,6 +13,7 @@ module AccountAssociations
|
|||
# Timelines
|
||||
has_many :statuses, inverse_of: :account, dependent: :destroy
|
||||
has_many :favourites, inverse_of: :account, dependent: :destroy
|
||||
has_many :emoji_reactions, inverse_of: :account, dependent: :destroy
|
||||
has_many :bookmarks, inverse_of: :account, dependent: :destroy
|
||||
has_many :mentions, inverse_of: :account, dependent: :destroy
|
||||
has_many :notifications, inverse_of: :account, dependent: :destroy
|
||||
|
|
|
@ -37,6 +37,7 @@ class CustomEmoji < ApplicationRecord
|
|||
|
||||
belongs_to :category, class_name: 'CustomEmojiCategory', optional: true
|
||||
has_one :local_counterpart, -> { where(domain: nil) }, class_name: 'CustomEmoji', primary_key: :shortcode, foreign_key: :shortcode
|
||||
has_many :emoji_reactions, inverse_of: :custom_emoji, dependent: :destroy
|
||||
|
||||
has_attached_file :image, styles: { static: { format: 'png', convert_options: '-coalesce +profile "!icc,*" +set modify-date +set create-date' } }, validate_media_type: false
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class EmojiReaction < ApplicationRecord
|
|||
|
||||
belongs_to :account, inverse_of: :emoji_reactions
|
||||
belongs_to :status, inverse_of: :emoji_reactions
|
||||
belongs_to :custom_emojis, optional: true
|
||||
belongs_to :custom_emoji, optional: true
|
||||
|
||||
has_one :notification, as: :activity, dependent: :destroy
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ class Notification < ApplicationRecord
|
|||
belongs_to :follow, foreign_key: 'activity_id', optional: true
|
||||
belongs_to :follow_request, foreign_key: 'activity_id', optional: true
|
||||
belongs_to :favourite, foreign_key: 'activity_id', optional: true
|
||||
belongs_to :emoji_reaction, foreign_key: 'activity_id', optional: true
|
||||
belongs_to :poll, foreign_key: 'activity_id', optional: true
|
||||
belongs_to :report, foreign_key: 'activity_id', optional: true
|
||||
|
||||
|
@ -79,6 +80,8 @@ class Notification < ApplicationRecord
|
|||
status&.reblog
|
||||
when :favourite
|
||||
favourite&.status
|
||||
when :emoji_reaction
|
||||
emoji_reaction&.status
|
||||
when :mention
|
||||
mention&.status
|
||||
when :poll
|
||||
|
@ -128,6 +131,8 @@ class Notification < ApplicationRecord
|
|||
notification.status.reblog = cached_status
|
||||
when :favourite
|
||||
notification.favourite.status = cached_status
|
||||
when :emoji_reaction
|
||||
notification.emoji_reaction.status = cached_status
|
||||
when :mention
|
||||
notification.mention.status = cached_status
|
||||
when :poll
|
||||
|
@ -148,7 +153,7 @@ class Notification < ApplicationRecord
|
|||
return unless new_record?
|
||||
|
||||
case activity_type
|
||||
when 'Status', 'Follow', 'Favourite', 'FollowRequest', 'Poll', 'Report'
|
||||
when 'Status', 'Follow', 'Favourite', 'EmojiReaction', 'FollowRequest', 'Poll', 'Report'
|
||||
self.from_account_id = activity&.account_id
|
||||
when 'Mention'
|
||||
self.from_account_id = activity&.status&.account_id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue