Class: PublicsController

Inherits:
ApplicationController show all
Includes:
Diaspora::Parser
Defined in:
app/controllers/publics_controller.rb

Overview

Copyright © 2010-2011, Diaspora Inc. This file is

licensed under the Affero General Public License version 3 or later.  See
the COPYRIGHT file.

Instance Method Summary (collapse)

Methods included from Diaspora::Parser

from_xml

Instance Method Details

- (Object) hcard



20
21
22
23
24
25
26
27
28
# File 'app/controllers/publics_controller.rb', line 20

def hcard
  @person = Person.(params[:guid], false)

  if @person.present? && @person.local?
    render 'publics/hcard'
  else
    render :nothing => true, :status => 404
  end
end

- (Object) host_meta



30
31
32
# File 'app/controllers/publics_controller.rb', line 30

def host_meta
  render 'host_meta', :content_type => 'application/xrd+xml'
end

- (Object) hub



46
47
48
# File 'app/controllers/publics_controller.rb', line 46

def hub
  render :text => params['hub.challenge'], :status => 202, :layout => false
end

- (Object) receive



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'app/controllers/publics_controller.rb', line 56

def receive
  person = Person.find_by_guid(params[:guid])

  if person.nil? || person.owner_id.nil?
    Rails.logger.error("Received post for nonexistent person #{params[:guid]}")
    render :nothing => true, :status => 404
    return
  end

  @user = person.owner

  FEDERATION_LOGGER.info("recieved a private message for user:#{@user.id}")
  Workers::ReceiveEncryptedSalmon.perform_async(@user.id, CGI::unescape(params[:xml]))

  render :nothing => true, :status => 202
end

- (Object) receive_public



50
51
52
53
54
# File 'app/controllers/publics_controller.rb', line 50

def receive_public
  FEDERATION_LOGGER.info("recieved a public message")
  Workers::ReceiveUnencryptedSalmon.perform_async(CGI::unescape(params[:xml]))
  render :nothing => true, :status => :ok
end

- (Object) webfinger



34
35
36
37
38
39
40
41
42
43
44
# File 'app/controllers/publics_controller.rb', line 34

def webfinger
  @person = Person.(params[:q]) if params[:q]

  if @person.nil? || @person.closed_account?
    render :nothing => true, :status => 404
    return
  end

  FEDERATION_LOGGER.info("webfinger profile request for :#{@person.id}")
  render 'webfinger', :content_type => 'application/xrd+xml'
end