Newer
Older
# licensed under the Affero General Public License version 3 or later. See
Daniel Vincent Grippi
a validé
maxwell
a validé
require File.join(Rails.root, '/lib/diaspora/parser')
skip_before_filter :set_header_data
skip_before_filter :which_action_and_user
skip_before_filter :set_grammatical_gender
Raphael Sofaer
a validé
before_filter :allow_cross_origin, :only => [:hcard, :host_meta, :webfinger]
respond_to :html
respond_to :xml, :only => :post
Raphael Sofaer
a validé
def allow_cross_origin
headers["Access-Control-Allow-Origin"] = "*"
end
@person = Person.where(:guid => params[:guid]).first
danielvincent
a validé
render 'publics/hcard'
else
render :nothing => true, :status => 404
render 'host_meta', :content_type => 'application/xrd+xml'
@person = Person.local_by_account_identifier(params[:q]) if params[:q]
render 'webfinger', :content_type => 'application/xrd+xml'
render :nothing => true, :status => 404
render :text => params['hub.challenge'], :status => 202, :layout => false
if params[:xml].nil?
render :nothing => true, :status => 422
return
end
Rails.logger.error("Received post for nonexistent person #{params[:guid]}")
Raphael
a validé
end
maxwell
a validé
Resque.enqueue(Job::ReceiveSalmon, @user.id, CGI::unescape(params[:xml]))
Raphael Sofaer
a validé
def post
danielgrippi
a validé
if params[:guid].to_s.length <= 8
@post = Post.where(:id => params[:guid], :public => true).includes(:author, :comments => :author).first
else
@post = Post.where(:guid => params[:guid], :public => true).includes(:author, :comments => :author).first
end
Raphael Sofaer
a validé
if @post
#hax to upgrade logged in users who can comment
Raphael Sofaer
a validé
if user_signed_in? && current_user.find_visible_post_by_id(@post.id)
redirect_to post_path(@post)
else
@landing_page = true
@person = @post.author
if @person.owner_id
I18n.locale = @person.owner.language
respond_to do |format|
format.xml{ render :xml => @post.to_diaspora_xml }
format.any{ render "publics/#{@post.class.to_s.underscore}", :layout => 'application'}
end
else
flash[:error] = I18n.t('posts.show.not_found')
redirect_to root_url
end
Raphael Sofaer
a validé
end
else
flash[:error] = I18n.t('posts.show.not_found')
redirect_to root_url
end
end