DEV: Do not require restart to enable signatures
add_to_serializer checks whether the plugin is enabled at runtime, and supports multisite environments
This commit is contained in:
@@ -20,24 +20,22 @@ after_initialize do
|
||||
|
||||
register_editable_user_custom_field [:see_signatures, :signature_url, :signature_raw]
|
||||
|
||||
if SiteSetting.signatures_enabled then
|
||||
add_to_serializer(:post, :user_signature, false) {
|
||||
if SiteSetting.signatures_advanced_mode then
|
||||
object.user.custom_fields['signature_cooked'] if object.user
|
||||
else
|
||||
object.user.custom_fields['signature_url'] if object.user
|
||||
end
|
||||
}
|
||||
add_to_serializer(:post, :user_signature) {
|
||||
if SiteSetting.signatures_advanced_mode then
|
||||
object.user.custom_fields['signature_cooked'] if object.user
|
||||
else
|
||||
object.user.custom_fields['signature_url'] if object.user
|
||||
end
|
||||
}
|
||||
|
||||
# I guess this should be the default @ discourse. PR maybe?
|
||||
add_to_serializer(:user, :custom_fields, false) {
|
||||
if object.custom_fields == nil then
|
||||
{}
|
||||
else
|
||||
object.custom_fields
|
||||
end
|
||||
}
|
||||
end
|
||||
# I guess this should be the default @ discourse. PR maybe?
|
||||
add_to_serializer(:user, :custom_fields) {
|
||||
if object.custom_fields == nil then
|
||||
{}
|
||||
else
|
||||
object.custom_fields
|
||||
end
|
||||
}
|
||||
|
||||
# This is the code responsible for cooking a new advanced mode sig on user update
|
||||
DiscourseEvent.on(:user_updated) do |user|
|
||||
|
||||
Reference in New Issue
Block a user