diaspora/app/presenters/social_relay_presenter.rb
Jason Robinson bdf6c71772 Implement social relay functionality
* .well-known/social-relay - to serve subscription preferences to relays
* Workers.deferred_dispatch relay carbon copy functionality for outbound sending

See discussion here: https://www.loomio.org/d/9vpoe0UR/public-post-federation#comment-730911 and spec here: https://wiki.diasporafoundation.org/Relay_servers_for_public_posts
2015-07-18 21:29:31 +03:00

24 lines
725 B
Ruby

class SocialRelayPresenter
def as_json(*)
{
"subscribe" => AppConfig.relay.inbound.subscribe,
"scope" => AppConfig.relay.inbound.scope,
"tags" => tags
}
end
def tags
return [] unless AppConfig.relay.inbound.scope == "tags"
tags = AppConfig.relay.inbound.pod_tags.present? ? AppConfig.relay.inbound.pod_tags.split(",") : []
add_user_tags(tags)
tags.uniq
end
def add_user_tags(tags)
if AppConfig.relay.inbound.include_user_tags?
user_ids = User.halfyear_actives.pluck(:id)
tag_ids = TagFollowing.where(user: user_ids).select(:tag_id).distinct.pluck(:tag_id)
tags.concat ActsAsTaggableOn::Tag.where(id: tag_ids).pluck(:name)
end
end
end