From 6ab6b6dd29c1f8fd9cd2d4371f664ed4432b1d19 Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Sat, 11 Jan 2020 03:15:56 -0600 Subject: expose `local` visibility flag only when monsterfork api exposure is set to `full` (inital state serializer) --- app/serializers/initial_state_serializer.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'app/serializers') diff --git a/app/serializers/initial_state_serializer.rb b/app/serializers/initial_state_serializer.rb index cb5b0017e..e22ebfd4d 100644 --- a/app/serializers/initial_state_serializer.rb +++ b/app/serializers/initial_state_serializer.rb @@ -61,8 +61,14 @@ class InitialStateSerializer < ActiveModel::Serializer if object.current_account store[:me] = object.current_account.id.to_s - store[:default_privacy] = object.current_account.user_default_visibility store[:default_sensitive] = object.current_account.user_defaults_to_sensitive? + + default_visibility = object.current_account.user_default_visibility + if monsterfork_api != :full && default_visibility == 'local' + default_visibility = 'unlisted' + end + + store[:default_privacy] = default_visibility end store[:text] = object.text if object.text @@ -86,4 +92,10 @@ class InitialStateSerializer < ActiveModel::Serializer def instance_presenter @instance_presenter ||= InstancePresenter.new end + + private + + def monsterfork_api + instance_options[:monsterfork_api] || object.current_account && object.current_account&.user&.monsterfork_api&.to_sym + end end -- cgit