parent
77a1cabb97
commit
45cc8fff7a
15 changed files with 107 additions and 8 deletions
|
@ -259,6 +259,10 @@ module HasUserSettings
|
|||
settings['lock_follow_from_bot']
|
||||
end
|
||||
|
||||
def setting_hide_emoji_reaction_unavailable_server
|
||||
settings['web.hide_emoji_reaction_unavailable_server']
|
||||
end
|
||||
|
||||
def allows_report_emails?
|
||||
settings['notification_emails.report']
|
||||
end
|
||||
|
|
|
@ -14,4 +14,36 @@
|
|||
#
|
||||
|
||||
class InstanceInfo < ApplicationRecord
|
||||
EMOJI_REACTION_AVAILABLE_SOFTWARES = %w(
|
||||
misskey
|
||||
calckey
|
||||
cherrypick
|
||||
meisskey
|
||||
firefish
|
||||
renedon
|
||||
fedibird
|
||||
kmyblue
|
||||
pleroma
|
||||
akkoma
|
||||
).freeze
|
||||
|
||||
def self.emoji_reaction_available?(domain)
|
||||
return Setting.enable_emoji_reaction if domain.nil?
|
||||
|
||||
Rails.cache.fetch("emoji_reaction_available_domain:#{domain}") { fetch_emoji_reaction_available(domain) }
|
||||
end
|
||||
|
||||
def self.fetch_emoji_reaction_available(domain)
|
||||
return Setting.enable_emoji_reaction if domain.nil?
|
||||
|
||||
info = InstanceInfo.find_by(domain: domain)
|
||||
return false if info.nil?
|
||||
|
||||
return true if EMOJI_REACTION_AVAILABLE_SOFTWARES.include?(info['software'])
|
||||
|
||||
features = info.data.dig('metadata', 'features')
|
||||
return false if features.nil? || !features.is_a?(Array)
|
||||
|
||||
features.include?('emoji_reaction')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -525,6 +525,10 @@ class Status < ApplicationRecord
|
|||
Status.where(id: status_ids).pluck(:account_id).uniq.index_with { |a| Account.find_by(id: a).show_emoji_reaction?(my_account) }
|
||||
end
|
||||
|
||||
def emoji_reaction_availables_map(domains)
|
||||
domains.index_with { |d| InstanceInfo.emoji_reaction_available?(d) }
|
||||
end
|
||||
|
||||
def reload_stale_associations!(cached_items)
|
||||
account_ids = []
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ class UserSettings
|
|||
setting :show_quote_in_home, default: true
|
||||
setting :show_quote_in_public, default: false
|
||||
setting :hide_blocking_quote, default: true
|
||||
setting :hide_emoji_reaction_unavailable_server, default: false
|
||||
end
|
||||
|
||||
namespace :notification_emails do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue