Add DISABLE_ANNOUNCEMENT_REACTIONS environment variable to disable emoji reactions in announcements (#40931)
Co-authored-by: Matt Jankowski <[email protected]>
This commit is contained in:
1 parent
681775877a
commit
9844563a3e
6 files changed
+19
-2
No files matched your search
@@ -2,6 +2,7 @@
|
||||
|
||||
class Api::V1::Announcements::ReactionsController < Api::BaseController
|
||||
before_action -> { doorkeeper_authorize! :write, :'write:favourites' }
|
||||
before_action :require_feature_enabled!
|
||||
before_action :require_user!
|
||||
|
||||
before_action :set_announcement
|
||||
@@ -19,6 +20,10 @@ class Api::V1::Announcements::ReactionsController < Api::BaseController
|
||||
|
||||
private
|
||||
|
||||
def require_feature_enabled!
|
||||
render json: { error: 'Emoji reactions are currently not supported on this server' }, status: 400 if Rails.configuration.x.mastodon.disable_announcement_reactions
|
||||
end
|
||||
|
||||
def set_reaction
|
||||
@reaction = @announcement.announcement_reactions.where(account: current_account).find_by!(name: params[:id])
|
||||
end
|
||||
|
||||
@@ -17,6 +17,7 @@ export interface ApiAnnouncementJSON {
|
||||
tags: ApiTagJSON[];
|
||||
emojis: ApiCustomEmojiJSON[];
|
||||
reactions: ApiAnnouncementReactionJSON[];
|
||||
reactions_allowed: boolean;
|
||||
}
|
||||
|
||||
export interface ApiAnnouncementReactionJSON {
|
||||
|
||||
@@ -67,7 +67,11 @@ export const Announcement: FC<AnnouncementProps> = ({
|
||||
extraEmojis={announcement.emojis}
|
||||
/>
|
||||
|
||||
<ReactionsBar reactions={announcement.reactions} id={announcement.id} />
|
||||
{announcement.reactions_allowed ? (
|
||||
<ReactionsBar reactions={announcement.reactions} id={announcement.id} />
|
||||
) : (
|
||||
<div className='reactions-bar reactions-bar--empty' />
|
||||
)}
|
||||
</AnimateEmojiProvider>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -81,7 +81,13 @@ class Announcement < ApplicationRecord
|
||||
@emojis ||= CustomEmoji.from_text(text)
|
||||
end
|
||||
|
||||
def reactions_allowed
|
||||
!Rails.configuration.x.mastodon.disable_announcement_reactions
|
||||
end
|
||||
|
||||
def reactions(account = nil)
|
||||
return [] unless reactions_allowed
|
||||
|
||||
grouped_ordered_announcement_reactions.select(
|
||||
[:name, :custom_emoji_id, 'COUNT(*) as count'].tap do |values|
|
||||
values << value_for_reaction_me_column(account)
|
||||
|
||||
@@ -4,7 +4,7 @@ class REST::AnnouncementSerializer < ActiveModel::Serializer
|
||||
include FormattingHelper
|
||||
|
||||
attributes :id, :content, :starts_at, :ends_at, :all_day,
|
||||
:published_at, :updated_at
|
||||
:published_at, :updated_at, :reactions_allowed
|
||||
|
||||
attribute :read, if: :current_user?
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
shared:
|
||||
disable_announcement_reactions: <%= ENV.fetch('DISABLE_ANNOUNCEMENT_REACTIONS', nil) == 'true' %>
|
||||
experimental_features: <%= ENV.fetch('EXPERIMENTAL_FEATURES', nil) %>
|
||||
limited_federation_mode: <%= (ENV.fetch('LIMITED_FEDERATION_MODE', nil) || ENV.fetch('WHITELIST_MODE', nil)) == 'true' %>
|
||||
self_destruct_value: <%= ENV.fetch('SELF_DESTRUCT', nil)&.to_json %>
|
||||
|
||||
Reference in new issue
Block a user