diaspora/app/controllers/publics_controller.rb
MrZYX 98cdee97c0 Merge branch '619-gender-aware-translations' of https://github.com/siefca/diaspora into inflections
Conflicts:
	Gemfile
	app/controllers/application_controller.rb
	app/controllers/posts_controller.rb
	app/controllers/publics_controller.rb
2011-02-24 00:33:34 +01:00

66 lines
1.8 KiB
Ruby

# 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_contacts_notifications_and_status, :except => [:create, :update]
skip_before_filter :count_requests
skip_before_filter :set_invites
skip_before_filter :set_locale
skip_before_filter :which_action_and_user
skip_before_filter :set_grammatical_gender
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
if params['hub.mode'] == 'subscribe' || params['hub.mode'] == 'unsubscribe'
render :text => params['hub.challenge'], :status => 202, :layout => false
end
end
def receive
if params[:xml].nil?
render :nothing => true, :status => 422
return
end
person = Person.where(:guid => params[:guid]).first
if 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 => 200
end
end