Add reactiondeck limit variable and improve sql
This commit is contained in:
parent
8e794d50b5
commit
f93679566b
4 changed files with 13 additions and 4 deletions
|
@ -20,9 +20,16 @@ class Api::V1::ReactionDeckController < Api::BaseController
|
||||||
def create
|
def create
|
||||||
deck = []
|
deck = []
|
||||||
|
|
||||||
|
shortcodes = []
|
||||||
(deck_params['emojis'] || []).each do |shortcode|
|
(deck_params['emojis'] || []).each do |shortcode|
|
||||||
shortcode = shortcode.delete(':')
|
shortcodes << shortcode.delete(':')
|
||||||
custom_emoji = CustomEmoji.find_by(shortcode: shortcode, domain: nil)
|
break if shortcodes.length >= User::REACTION_DECK_MAX
|
||||||
|
end
|
||||||
|
|
||||||
|
custom_emojis = CustomEmoji.where(shortcode: shortcodes, domain: nil)
|
||||||
|
|
||||||
|
shortcodes.each do |shortcode|
|
||||||
|
custom_emoji = custom_emojis.find { |em| em.shortcode == shortcode }
|
||||||
|
|
||||||
emoji_data = {}
|
emoji_data = {}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,8 @@ class User < ApplicationRecord
|
||||||
# to check their feed
|
# to check their feed
|
||||||
ACTIVE_DURATION = ENV.fetch('USER_ACTIVE_DAYS', 7).to_i.days.freeze
|
ACTIVE_DURATION = ENV.fetch('USER_ACTIVE_DAYS', 7).to_i.days.freeze
|
||||||
|
|
||||||
|
REACTION_DECK_MAX = 256
|
||||||
|
|
||||||
devise :two_factor_authenticatable,
|
devise :two_factor_authenticatable,
|
||||||
otp_secret_encryption_key: Rails.configuration.x.otp_secret
|
otp_secret_encryption_key: Rails.configuration.x.otp_secret
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
||||||
},
|
},
|
||||||
|
|
||||||
reaction_deck: {
|
reaction_deck: {
|
||||||
max_emojis: 32_767,
|
max_emojis: User::REACTION_DECK_MAX,
|
||||||
},
|
},
|
||||||
|
|
||||||
reactions: {
|
reactions: {
|
||||||
|
|
|
@ -92,7 +92,7 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer
|
||||||
},
|
},
|
||||||
|
|
||||||
reaction_deck: {
|
reaction_deck: {
|
||||||
max_emojis: 32_767,
|
max_emojis: User::REACTION_DECK_MAX,
|
||||||
},
|
},
|
||||||
|
|
||||||
reactions: {
|
reactions: {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue