From 14bd46946d25186044485aa101dd2da976b61181 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 30 Nov 2016 21:32:11 +0100 Subject: Per-status control for unlisted mode, also federation for unlisted mode Fix #233, fix #268 --- app/helpers/atom_builder_helper.rb | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'app/helpers/atom_builder_helper.rb') diff --git a/app/helpers/atom_builder_helper.rb b/app/helpers/atom_builder_helper.rb index 13faaa261..40bbe0491 100644 --- a/app/helpers/atom_builder_helper.rb +++ b/app/helpers/atom_builder_helper.rb @@ -38,7 +38,7 @@ module AtomBuilderHelper end def verb(xml, verb) - xml['activity'].send('verb', "http://activitystrea.ms/schema/1.0/#{verb}") + xml['activity'].send('verb', TagManager::VERBS[verb]) end def content(xml, content) @@ -62,7 +62,7 @@ module AtomBuilderHelper end def object_type(xml, type) - xml['activity'].send('object-type', "http://activitystrea.ms/schema/1.0/#{type}") + xml['activity'].send('object-type', TagManager::TYPES[type]) end def uri(xml, uri) @@ -108,7 +108,7 @@ module AtomBuilderHelper end def link_mention(xml, account) - xml.link(rel: 'mentioned', href: TagManager.instance.uri_for(account)) + xml.link(:rel => 'mentioned', :href => TagManager.instance.uri_for(account), 'ostatus:object-type' => TagManager::TYPES[:person]) end def link_enclosure(xml, media) @@ -139,6 +139,11 @@ module AtomBuilderHelper end end + def link_visibility(xml, item) + return unless item.respond_to?(:visibility) && item.public_visibility? + xml.link(:rel => 'mentioned', :href => TagManager::COLLECTIONS[:public], 'ostatus:object-type' => TagManager::TYPES[:collection]) + end + def include_author(xml, account) object_type xml, :person uri xml, TagManager.instance.uri_for(account) @@ -189,6 +194,8 @@ module AtomBuilderHelper include_author xml, stream_entry.target.account end + link_visibility xml, stream_entry.target + stream_entry.target.mentions.each do |mention| link_mention xml, mention.account end @@ -204,25 +211,34 @@ module AtomBuilderHelper end end + link_visibility xml, stream_entry.activity + stream_entry.mentions.each do |mentioned| link_mention xml, mentioned end - if stream_entry.activity.is_a?(Status) - stream_entry.activity.media_attachments.each do |media| - link_enclosure xml, media - end + return unless stream_entry.activity.is_a?(Status) - stream_entry.activity.tags.each do |tag| - category xml, tag - end + stream_entry.activity.media_attachments.each do |media| + link_enclosure xml, media + end + + stream_entry.activity.tags.each do |tag| + category xml, tag end end private def root_tag(xml, tag, &block) - xml.send(tag, { :xmlns => 'http://www.w3.org/2005/Atom', 'xmlns:thr' => 'http://purl.org/syndication/thread/1.0', 'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/', 'xmlns:poco' => 'http://portablecontacts.net/spec/1.0', 'xmlns:media' => 'http://purl.org/syndication/atommedia' }, &block) + xml.send(tag, { + 'xmlns' => TagManager::XMLNS, + 'xmlns:thr' => TagManager::THR_XMLNS, + 'xmlns:activity' => TagManager::AS_XMLNS, + 'xmlns:poco' => TagManager::POCO_XMLNS, + 'xmlns:media' => TagManager::MEDIA_XMLNS, + 'xmlns:ostatus' => TagManager::OS_XMLNS, + }, &block) end def single_link_avatar(xml, account, size, px) -- cgit