diaspora/app/controllers/requests_controller.rb
2010-07-16 21:59:40 -07:00

53 lines
1.2 KiB
Ruby

class RequestsController < ApplicationController
before_filter :authenticate_user!
include RequestsHelper
def index
@remote_requests = Request.for_user( current_user )
@request = Request.new
end
def destroy
if params[:accept]
@friend = current_user.accept_friend_request params[:id]
flash[:notice] = "you are now friends"
redirect_to root_url
else
current_user.ignore_friend_request params[:id]
flash[:notice] = "ignored friend request"
redirect_to requests_url
end
end
def new
@request = Request.new
end
def create
url = find_url(params)
@request = current_user.send_friend_request_to(params[:request][:destination_url])
if @request
flash[:notice] = "a friend request was sent to #{@request.destination_url}"
redirect_to requests_url
else
flash[:error] = "you have already friended this person"
@request = Request.new
render :action => 'new'
end
end
def self.diasproa_url(identifier)
if identifier.include? '@'
f = Redfinger.finger(uri)
identifier = f.each{|x| return x.link if x.rel =='http://joindiaspora.com/seed_location'}
end
identifier
end
private
end