From e9e11b0ff5d660721834fef0ca9e2893b6bc5167 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Sun, 11 Dec 2016 22:49:25 +0100 Subject: [PATCH] Sensitive content federates using the "nsfw" hashtag --- .../components/components/status_action_bar.jsx | 9 ++++++++- app/helpers/atom_builder_helper.rb | 12 ++++++++---- app/services/process_hashtags_service.rb | 2 ++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/components/components/status_action_bar.jsx b/app/assets/javascripts/components/components/status_action_bar.jsx index 35feda88b2..9c6d13bdfc 100644 --- a/app/assets/javascripts/components/components/status_action_bar.jsx +++ b/app/assets/javascripts/components/components/status_action_bar.jsx @@ -10,7 +10,8 @@ const messages = defineMessages({ block: { id: 'account.block', defaultMessage: 'Block' }, reply: { id: 'status.reply', defaultMessage: 'Reply' }, reblog: { id: 'status.reblog', defaultMessage: 'Reblog' }, - favourite: { id: 'status.favourite', defaultMessage: 'Favourite' } + favourite: { id: 'status.favourite', defaultMessage: 'Favourite' }, + open: { id: 'status.open', defaultMessage: 'Expand' } }); const StatusActionBar = React.createClass({ @@ -55,10 +56,16 @@ const StatusActionBar = React.createClass({ this.props.onBlock(this.props.status.get('account')); }, + handleOpen () { + this.context.router.push(`/statuses/${this.props.status.get('id')}`); + }, + render () { const { status, me, intl } = this.props; let menu = []; + menu.push({ text: intl.formatMessage(messages.open), action: this.handleOpen }); + if (status.getIn(['account', 'id']) === me) { menu.push({ text: intl.formatMessage(messages.delete), action: this.handleDeleteClick }); } else { diff --git a/app/helpers/atom_builder_helper.rb b/app/helpers/atom_builder_helper.rb index 953ccd4388..02876d5ad7 100644 --- a/app/helpers/atom_builder_helper.rb +++ b/app/helpers/atom_builder_helper.rb @@ -53,8 +53,8 @@ module AtomBuilderHelper xml.author(&block) end - def category(xml, tag) - xml.category(term: tag.name) + def category(xml, term) + xml.category(term: term) end def target(xml, &block) @@ -203,8 +203,10 @@ module AtomBuilderHelper end stream_entry.target.tags.each do |tag| - category xml, tag + category xml, tag.name end + + category(xml, 'nsfw') if stream_entry.target.sensitive? end end end @@ -222,8 +224,10 @@ module AtomBuilderHelper end stream_entry.activity.tags.each do |tag| - category xml, tag + category xml, tag.name end + + category(xml, 'nsfw') if stream_entry.activity.sensitive? end private diff --git a/app/services/process_hashtags_service.rb b/app/services/process_hashtags_service.rb index fa14c44da5..ddcc64aa59 100644 --- a/app/services/process_hashtags_service.rb +++ b/app/services/process_hashtags_service.rb @@ -7,5 +7,7 @@ class ProcessHashtagsService < BaseService tags.map { |str| str.mb_chars.downcase }.uniq.each do |tag| status.tags << Tag.where(name: tag).first_or_initialize(name: tag) end + + status.update(sensitive: true) if tags.include?('nsfw') end end