1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
class PublicsController < ApplicationController
require File.join(Rails.root, '/lib/diaspora/parser')
include Diaspora::Parser
skip_before_filter :set_header_data
skip_before_filter :set_invites
skip_before_filter :which_action_and_user
skip_before_filter :set_grammatical_gender
before_filter :allow_cross_origin, :only => [:hcard, :host_meta, :webfinger]
def allow_cross_origin
headers["Access-Control-Allow-Origin"] = "*"
end
layout false
caches_page :host_meta
def hcard
@person = Person.where(:guid => params[:guid]).first
unless @person.nil? || @person.owner.nil?
render 'publics/hcard'
else
render :nothing => true, :status => 404
end
end
def host_meta
render 'host_meta', :content_type => 'application/xrd+xml'
end
def webfinger
@person = Person.local_by_account_identifier(params[:q]) if params[:q]
unless @person.nil?
render 'webfinger', :content_type => 'application/xrd+xml'
else
render :nothing => true, :status => 404
end
end
def hub
render :text => params['hub.challenge'], :status => 202, :layout => false
end
def receive
if params[:xml].nil?
render :nothing => true, :status => 422
return
end
person = Person.where(:guid => params[:guid]).first
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
Resque.enqueue(Job::ReceiveSalmon, @user.id, CGI::unescape(params[:xml]))
render :nothing => true, :status => 202
end
end
|