From 09f04d710d2b3acbd604ca1678c59c4bd5edfa78 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Thu, 27 Oct 2022 19:17:48 +0200 Subject: [PATCH] Change `closed_registrations_message` to `message` and add Markdown (#19486) --- app/serializers/rest/instance_serializer.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/serializers/rest/instance_serializer.rb b/app/serializers/rest/instance_serializer.rb index 2a4da8c3b3..5ae1099d04 100644 --- a/app/serializers/rest/instance_serializer.rb +++ b/app/serializers/rest/instance_serializer.rb @@ -83,7 +83,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer { enabled: registrations_enabled?, approval_required: Setting.registrations_mode == 'approved', - closed_registrations_message: registrations_enabled? ? nil : Setting.closed_registrations_message, + message: registrations_enabled? ? nil : registrations_message, } end @@ -92,4 +92,16 @@ class REST::InstanceSerializer < ActiveModel::Serializer def registrations_enabled? Setting.registrations_mode != 'none' && !Rails.configuration.x.single_user_mode end + + def registrations_message + if Setting.closed_registrations_message.present? + markdown.render(Setting.closed_registrations_message) + else + nil + end + end + + def markdown + @markdown ||= Redcarpet::Markdown.new(Redcarpet::Render::HTML, no_images: true) + end end