From 14bd46946d25186044485aa101dd2da976b61181 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 30 Nov 2016 21:32:11 +0100 Subject: [PATCH] Per-status control for unlisted mode, also federation for unlisted mode Fix #233, fix #268 --- Gemfile.lock | 12 ++--- .../components/actions/compose.jsx | 11 +++- .../compose/components/compose_form.jsx | 15 +++++- .../containers/compose_form_container.jsx | 8 ++- .../javascripts/components/locales/de.jsx | 2 + .../javascripts/components/locales/en.jsx | 1 + .../javascripts/components/locales/es.jsx | 2 + .../javascripts/components/locales/fr.jsx | 3 +- .../javascripts/components/locales/hu.jsx | 1 + .../javascripts/components/locales/pt.jsx | 2 + .../components/reducers/compose.jsx | 6 ++- app/controllers/api/v1/statuses_controller.rb | 4 +- .../concerns/obfuscate_filename.rb | 3 +- .../settings/profiles_controller.rb | 2 +- app/helpers/atom_builder_helper.rb | 38 +++++++++---- app/lib/tag_manager.rb | 31 +++++++++++ app/models/status.rb | 4 ++ app/services/fan_out_on_write_service.rb | 2 +- app/services/post_status_service.rb | 2 +- app/services/process_feed_service.rb | 54 ++++++++++--------- app/services/process_interaction_service.rb | 19 ++++--- app/services/update_remote_profile_service.rb | 13 ++--- app/views/settings/profiles/show.html.haml | 1 - config/locales/simple_form.de.yml | 1 - config/locales/simple_form.en.yml | 1 - config/locales/simple_form.es.yml | 1 - config/locales/simple_form.fr.yml | 1 - config/locales/simple_form.hu.yml | 1 - ...161130185319_add_visibility_to_statuses.rb | 5 ++ db/schema.rb | 3 +- spec/helpers/atom_builder_helper_spec.rb | 8 +-- 31 files changed, 175 insertions(+), 82 deletions(-) rename app/{models => controllers}/concerns/obfuscate_filename.rb (75%) create mode 100644 db/migrate/20161130185319_add_visibility_to_statuses.rb diff --git a/Gemfile.lock b/Gemfile.lock index aa9f59da8..cc7751ae1 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: https://github.com/rails/rails.git - revision: ecb394a31420f6fd1d0ab692c79f2dd44176e2c9 + revision: c7a716aa5a692cae301d56b345faa5d79cbfc320 branch: 5-0-stable specs: actioncable (5.0.0.1) @@ -110,7 +110,7 @@ GEM coffee-script-source (1.10.0) colorize (0.8.1) concurrent-ruby (1.0.2) - connection_pool (2.2.0) + connection_pool (2.2.1) crack (0.4.3) safe_yaml (~> 1.0.0) debug_inspector (0.0.2) @@ -287,7 +287,7 @@ GEM execjs railties (>= 3.2) tilt - redis (3.3.1) + redis (3.3.2) redis-actionpack (5.0.0) actionpack (>= 4.0.0, < 6) redis-rack (~> 2.0.0.pre) @@ -348,10 +348,10 @@ GEM sdoc (0.4.1) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) - sidekiq (4.2.1) + sidekiq (4.2.7) concurrent-ruby (~> 1.0) connection_pool (~> 2.2, >= 2.2.0) - rack-protection (~> 1.5) + rack-protection (>= 1.5.0) redis (~> 3.2, >= 3.2.1) simple_form (3.2.1) actionpack (> 4, < 5.1) @@ -374,7 +374,7 @@ GEM tins (~> 1.0) terminal-table (1.7.0) unicode-display_width (~> 1.1) - thor (0.19.1) + thor (0.19.4) thread (0.2.2) thread_safe (0.3.5) tilt (2.0.5) diff --git a/app/assets/javascripts/components/actions/compose.jsx b/app/assets/javascripts/components/actions/compose.jsx index b97cb7b12..c2a7909f6 100644 --- a/app/assets/javascripts/components/actions/compose.jsx +++ b/app/assets/javascripts/components/actions/compose.jsx @@ -23,6 +23,7 @@ export const COMPOSE_MOUNT = 'COMPOSE_MOUNT'; export const COMPOSE_UNMOUNT = 'COMPOSE_UNMOUNT'; export const COMPOSE_SENSITIVITY_CHANGE = 'COMPOSE_SENSITIVITY_CHANGE'; +export const COMPOSE_VISIBILITY_CHANGE = 'COMPOSE_VISIBILITY_CHANGE'; export function changeCompose(text) { return { @@ -65,7 +66,8 @@ export function submitCompose() { status: getState().getIn(['compose', 'text'], ''), in_reply_to_id: getState().getIn(['compose', 'in_reply_to'], null), media_ids: getState().getIn(['compose', 'media_attachments']).map(item => item.get('id')), - sensitive: getState().getIn(['compose', 'sensitive']) + sensitive: getState().getIn(['compose', 'sensitive']), + unlisted: getState().getIn(['compose', 'unlisted']) }).then(function (response) { dispatch(submitComposeSuccess(response.data)); dispatch(updateTimeline('home', response.data)); @@ -207,3 +209,10 @@ export function changeComposeSensitivity(checked) { checked }; }; + +export function changeComposeVisibility(checked) { + return { + type: COMPOSE_VISIBILITY_CHANGE, + checked + }; +}; diff --git a/app/assets/javascripts/components/features/compose/components/compose_form.jsx b/app/assets/javascripts/components/features/compose/components/compose_form.jsx index b16731c05..4688f39d3 100644 --- a/app/assets/javascripts/components/features/compose/components/compose_form.jsx +++ b/app/assets/javascripts/components/features/compose/components/compose_form.jsx @@ -70,6 +70,7 @@ const ComposeForm = React.createClass({ suggestion_token: React.PropTypes.string, suggestions: React.PropTypes.array, sensitive: React.PropTypes.bool, + unlisted: React.PropTypes.bool, is_submitting: React.PropTypes.bool, is_uploading: React.PropTypes.bool, in_reply_to: ImmutablePropTypes.map, @@ -79,7 +80,8 @@ const ComposeForm = React.createClass({ onClearSuggestions: React.PropTypes.func.isRequired, onFetchSuggestions: React.PropTypes.func.isRequired, onSuggestionSelected: React.PropTypes.func.isRequired, - onChangeSensitivity: React.PropTypes.func.isRequired + onChangeSensitivity: React.PropTypes.func.isRequired, + onChangeVisibility: React.PropTypes.func.isRequired }, mixins: [PureRenderMixin], @@ -147,6 +149,10 @@ const ComposeForm = React.createClass({ this.props.onChangeSensitivity(e.target.checked); }, + handleChangeVisibility (e) { + this.props.onChangeVisibility(e.target.checked); + }, + render () { const { intl } = this.props; let replyArea = ''; @@ -187,7 +193,12 @@ const ComposeForm = React.createClass({ -