app/controllers/users_controller.rb
# do friend actions (add/remove api/app friend etc)
# see users.friend_status_actions for full list
do friend actions (add/remove api/app friend etc)
see users.friend_status_actions for full list
do friend actions ( add / remove api / app friend etc ) see users . friend_status_actions for full list
def friend_actions
    return_to = params[:return_to]
    return_to = return_to.gsub(/&last_row_id=\d+/,'')
    return_to = return_to.gsub(/(last_row_id=\d+&)/,'')
    id2 = params[:friend_id]
    user2 = User.find_by_id(id2)
    if !user2
      logger.debug2  "invalid request. Friend with id #{id2} was not found"
      save_flash_key '.invalid_request'
      redirect_to return_to
      return
    end
    friend_action = params[:friend_action]
    login_user = @users.find { |user| user.provider == user2.provider }
    if !login_user or login_user.dummy_user?
      logger.debug2  "invalid request. Friend action #{friend_action} not allowed. not logged in with a #{user2.provider} account"
      save_flash_key '.invalid_request'
      redirect_to return_to
      return
    end
    allowed_friend_actions = user2.friend_status_actions(login_user).collect { |fa| fa.downcase }
    if !allowed_friend_actions.index(friend_action)
      logger.debug2  "invalid request. Friend action #{friend_action} not allowed."
      logger.debug2  "allowed friend actions are " + allowed_friend_actions.join(', ')
      save_flash_key '.invalid_request'
      redirect_to return_to
      return
    end
    if %w(add_api_friend remove_api_friend).index(friend_action)
      redirect_to api_profile_url(user2)
      return
    end
    postfix = user2.send(friend_action, login_user) ? "_ok" : "_error"
    save_flash_key ".#{friend_action}#{postfix}", :appname => APP_NAME, :username => user2.short_user_name
    redirect_to return_to
  end
def friend_actions return_to = params [ :return_to ] return_to = return_to . gsub ( / &last_row_id= \d + / , '' ) return_to = return_to . gsub ( / (last_row_id= \d +&) / , '' ) id2 = params [ :friend_id ] user2 = User . find_by_id ( id2 ) if ! user2 logger . debug2 "invalid request. Friend with id #{id2} was not found" save_flash_key '.invalid_request' redirect_to return_to return end friend_action = params [ :friend_action ] login_user = @users . find { | user | user . provider == user2 . provider } if ! login_user or login_user . dummy_user? logger . debug2 "invalid request. Friend action #{friend_action} not allowed. not logged in with a #{user2.provider} account" save_flash_key '.invalid_request' redirect_to return_to return end allowed_friend_actions = user2 . friend_status_actions ( login_user ) . collect { | fa | fa . downcase } if ! allowed_friend_actions . index ( friend_action ) logger . debug2 "invalid request. Friend action #{friend_action} not allowed." logger . debug2 "allowed friend actions are " + allowed_friend_actions . join ( ', ' ) save_flash_key '.invalid_request' redirect_to return_to return end if %w( add_api_friend remove_api_friend ) . index ( friend_action ) redirect_to api_profile_url ( user2 ) return end postfix = user2 . send ( friend_action , login_user ) ? "_ok" : "_error" save_flash_key ".#{friend_action}#{postfix}" , :appname => APP_NAME , :username => user2 . short_user_name redirect_to return_to end
do friend actions (add/remove api/app friend etc)
see users.friend_status_actions for full list
do friend actions ( add / remove api / app friend etc ) see users . friend_status_actions for full list
# next page is not ajax - remove last_row_id from return_to url to prevent ajax response # check param # friend actions: add_api_friend, remove_api_friend, send_app_friend_request, accept_app_friend_request, ignore_app_friend_request, remove_app_friend, block_app_user, unblock_app_user # api friend actions # no facebook api dialogs to add and remove facebook friends - just redirect to users profile page at facebook # do app friend action # for example send_app_friend_request with ok response send_app_friend_request_ok and error response send_app_friend_request_error