Class: DiasporaFederation::FetchController

Inherits:
ApplicationController show all
Defined in:
app/controllers/diaspora_federation/fetch_controller.rb

Overview

This controller processes fetch requests.

Instance Method Summary collapse

Methods inherited from ApplicationController

#set_locale

Instance Method Details

#fetchObject

Returns the fetched entity or a redirect

GET /fetch/:type/:guid



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/diaspora_federation/fetch_controller.rb', line 11

def fetch
  entity = fetch_public_entity
  if entity
    magic_env = create_magic_envelope(entity)
    if magic_env
      render xml: magic_env, content_type: "application/magic-envelope+xml"
    else
      redirect_url = DiasporaFederation.callbacks.trigger(:fetch_person_url_to,
                                                          entity.author, "/fetch/#{params[:type]}/#{params[:guid]}")
      redirect_to redirect_url, allow_other_host: true
    end
  else
    head :not_found
  end
end