Move emoji reaction limitation constraints
This commit is contained in:
parent
dcf52daa9b
commit
47bedd20ca
6 changed files with 21 additions and 5 deletions
|
@ -3,7 +3,6 @@
|
|||
class Api::BaseController < ApplicationController
|
||||
DEFAULT_STATUSES_LIMIT = 20
|
||||
DEFAULT_ACCOUNTS_LIMIT = 40
|
||||
DEFAULT_EMOJI_REACTION_LIMIT = 10
|
||||
|
||||
include RateLimitHeaders
|
||||
include AccessTokenTrackingConcern
|
||||
|
|
|
@ -42,7 +42,7 @@ class Api::V1::Statuses::EmojiReactionsController < Api::BaseController
|
|||
def create_private(emoji)
|
||||
count = EmojiReaction.where(account: current_account, status: @status).count
|
||||
|
||||
if count >= DEFAULT_EMOJI_REACTION_LIMIT
|
||||
if count >= EmojiReaction::EMOJI_REACTION_PER_ACCOUNT_LIMIT
|
||||
bad_request
|
||||
return
|
||||
end
|
||||
|
|
|
@ -38,7 +38,7 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
|
|||
end
|
||||
end
|
||||
|
||||
return if EmojiReaction.where(account: @account, status: @original_status).count >= 10
|
||||
return if EmojiReaction.where(account: @account, status: @original_status).count >= EmojiReaction::EMOJI_REACTION_PER_ACCOUNT_LIMIT
|
||||
|
||||
reaction = @original_status.emoji_reactions.create!(account: @account, name: shortcode, custom_emoji: emoji, uri: @json['id'])
|
||||
write_stream(reaction)
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
class EmojiReaction < ApplicationRecord
|
||||
include Paginable
|
||||
|
||||
EMOJI_REACTION_LIMIT = 32767
|
||||
EMOJI_REACTION_PER_ACCOUNT_LIMIT = 5
|
||||
|
||||
update_index('statuses', :status)
|
||||
|
||||
belongs_to :account, inverse_of: :emoji_reactions
|
||||
|
|
|
@ -77,6 +77,11 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
|||
translation: {
|
||||
enabled: TranslationService.configured?,
|
||||
},
|
||||
|
||||
emoji_reactions: {
|
||||
max_reactions: EmojiReaction::EMOJI_REACTION_LIMIT,
|
||||
max_reactions_per_account: EmojiReaction::EMOJI_REACTION_PER_ACCOUNT_LIMIT,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -92,7 +97,9 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
|||
def fedibird_capabilities
|
||||
capabilities = [
|
||||
:emoji_reaction,
|
||||
:visibility_public_unlisted
|
||||
:visibility_public_unlisted,
|
||||
:enable_wide_emoji,
|
||||
:enable_wide_emoji_reaction,
|
||||
]
|
||||
|
||||
capabilities << :profile_search unless Chewy.enabled?
|
||||
|
|
|
@ -83,6 +83,11 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer
|
|||
min_expiration: PollValidator::MIN_EXPIRATION,
|
||||
max_expiration: PollValidator::MAX_EXPIRATION,
|
||||
},
|
||||
|
||||
emoji_reactions: {
|
||||
max_reactions: EmojiReaction::EMOJI_REACTION_LIMIT,
|
||||
max_reactions_per_account: EmojiReaction::EMOJI_REACTION_PER_ACCOUNT_LIMIT,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -102,7 +107,9 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer
|
|||
def fedibird_capabilities
|
||||
capabilities = [
|
||||
:emoji_reaction,
|
||||
:visibility_public_unlisted
|
||||
:visibility_public_unlisted,
|
||||
:enable_wide_emoji,
|
||||
:enable_wide_emoji_reaction,
|
||||
]
|
||||
|
||||
capabilities << :profile_search unless Chewy.enabled?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue