Newer
Older
# licensed under the Affero General Public License version 3 or later. See
Daniel Vincent Grippi
a validé
require File.join(Rails.root, 'lib/webfinger')
maxwell
a validé
class RequestsController < ApplicationController
before_filter :authenticate_user!
respond_to :html
maxwell
a validé
def destroy
if notification = Notification.where(:recipient_id => current_user.id, :target_id=> params[:id]).first
notification.update_attributes(:unread=>false)
end
if params[:accept]
@contact = current_user.accept_and_respond( params[:id], params[:aspect_id])
flash[:notice] = I18n.t 'requests.destroy.success'
respond_with @contact, :location => requests_url
flash[:error] = I18n.t 'requests.destroy.error'
respond_with @contact, :location => requests_url
current_user.ignore_contact_request params[:id]
flash[:notice] = I18n.t 'requests.destroy.ignore'
Sarah Mei
a validé
head :ok
maxwell
a validé
end
aspect = current_user.aspects.where(:id => params[:request][:into]).first
person = Person.by_account_identifier(account)
existing_request = Request.where(:sender_id => person.id, :recipient_id => current_user.person.id).first if person
if existing_request
current_user.accept_and_respond(existing_request.id, aspect.id)
redirect_to :back
else
danielvincent
a validé
@contact = Contact.new(:user => current_user,
:person => person,
:aspect_ids => [aspect.id],
:pending => true)
if @contact.save
@contact.dispatch_request
flash.now[:notice] = I18n.t('requests.create.sent')
redirect_to :back
else
danielvincent
a validé
flash.now[:error] = @contact.errors.full_messages.join(', ')
redirect_to :back
end
end
maxwell
a validé
end