mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Add visibility parameter in share page (#13023)
* Add visibility parameter in share page * Restrict to default privacy
This commit is contained in:
parent
e0f55f374c
commit
13f065da05
3 changed files with 7 additions and 2 deletions
|
@ -136,6 +136,11 @@ module ApplicationHelper
|
||||||
text: [params[:title], params[:text], params[:url]].compact.join(' '),
|
text: [params[:title], params[:text], params[:url]].compact.join(' '),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
permit_visibilities = %w(public unlisted private direct)
|
||||||
|
default_privacy = current_account&.user&.setting_default_privacy
|
||||||
|
permit_visibilities.shift(permit_visibilities.index(default_privacy) + 1) if default_privacy.present?
|
||||||
|
state_params[:visibility] = params[:visibility] if permit_visibilities.include? params[:visibility]
|
||||||
|
|
||||||
if user_signed_in?
|
if user_signed_in?
|
||||||
state_params[:settings] = state_params[:settings].merge(Web::Setting.find_by(user: current_user)&.data || {})
|
state_params[:settings] = state_params[:settings].merge(Web::Setting.find_by(user: current_user)&.data || {})
|
||||||
state_params[:push_subscription] = current_account.user.web_push_subscription(current_session)
|
state_params[:push_subscription] = current_account.user.web_push_subscription(current_session)
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
|
|
||||||
class InitialStatePresenter < ActiveModelSerializers::Model
|
class InitialStatePresenter < ActiveModelSerializers::Model
|
||||||
attributes :settings, :push_subscription, :token,
|
attributes :settings, :push_subscription, :token,
|
||||||
:current_account, :admin, :text
|
:current_account, :admin, :text, :visibility
|
||||||
end
|
end
|
||||||
|
|
|
@ -55,7 +55,7 @@ class InitialStateSerializer < ActiveModel::Serializer
|
||||||
|
|
||||||
if object.current_account
|
if object.current_account
|
||||||
store[:me] = object.current_account.id.to_s
|
store[:me] = object.current_account.id.to_s
|
||||||
store[:default_privacy] = object.current_account.user.setting_default_privacy
|
store[:default_privacy] = object.visibility || object.current_account.user.setting_default_privacy
|
||||||
store[:default_sensitive] = object.current_account.user.setting_default_sensitive
|
store[:default_sensitive] = object.current_account.user.setting_default_sensitive
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue