Titanium JIRA Archive
Appcelerator Community (AC)

[AC-963] ACS - FB logged Users: addFriend / friendRequests throws an internal Error

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionCannot Reproduce
Resolution Date2014-09-24T01:33:56.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAppcelerator Modules, Titanium SDK & CLI
LabelsTCSupportTriage
ReporterJoseph Sachs
AssigneeMauro Parra-Miranda
Created2014-08-28T15:18:32.000+0000
Updated2016-03-08T07:37:17.000+0000

Description

User that have been logged in via Facebook, cannot Add Friend nor get FriendRequests from ACS. Sample Code:
var Cloud = require('ti.cloud');
var self = Ti.UI.createWindow({});

var faceBookLoginBtn = Ti.UI.createButton({ title : 'facebook login',  });
faceBookLoginBtn.addEventListener('click', function() { fb.authorize(); });
self.add(faceBookLoginBtn);

fb.addEventListener('login', function(e) {
        if (e.success) {
            // Cloud.SocialIntegrations.externalAccountLogin({
            //    type: 'facebook',
            //    token: fb.getAccessToken(),
            // update their account on ACS (for custom reasons)
            // logs them in.
            // These work, as I do see them logged in & their info updated on ACS web Console
 });

// after login to add friends or friends requests: **Node ACS** code:
// Briefly, this works like Tinder, one user swipes right to sent a friend request to another user, 
// or if they already have a request from that user, they confirm the request to be Friends.

function addFriend(req, res) {
    var results = {};
	// 1- Query currentUser Friend Requests
	Cloud.Friends.requests({
	    session_id: req.body.session_id
    },function (e) {
        if (e.success) {
            results.gotFriendRequests =  true;
            var userHadRequest = _score.find(e.friend_requests, function(friendRequest){ return friendRequest.user.id === req.body.toBeFriend_id; });
            if (userHadRequest) {
                results.match = true;
                Cloud.Friends.approve({
                    user_ids: req.body.toBeFriend_id,
                    session_id: req.body.session_id
                }, function (_e) {
                    if (_e.success) {
                        results.approvedMatch = true;
                        return res.send({results: results, matchedUser: userHadRequest.user.username, matchedUserId: userHadRequest.user.id});
                    } else {
                        results.approvedMatch = false;
                        results.approvedMatchFailedReason = JSON.stringify(_e);
                        return res.send(results);
                    }
                });
            } else {
                // Didn't have a User request for this user
                Cloud.Friends.add({
                    user_ids: req.body.toBeFriend_id,
                    session_id: req.body.session_id
                }, function (e) {
                    if (e.success) {
                        results.friendRequestSent = true;
                        return res.send(results);
                    } else {
                        results.friendRequestSent = false;
                        results.friendRequestFailedReason = JSON.stringify(e);
                        return res.send(results);
                    }
                });
            }
        } else {
            results.gotFriendRequests = false;
            results.gotFriendRequestsFailedReason = JSON.stringify(e);
            return res.send(results);
        }
    });
};
The Above works with regular users (those that created an account on ACS with their username/email & password), but Does Not work with Facebook Logged in Users that want to add friends with any other ACS User. To Recap: Only Facebook Logged-in Users cannot Add Friends, nor get Friend Requests, and returns: *Error code 500: Internal server error. The Appcelerator Cloud Services Team has just been notified of this problem.* _However, normal logged in Users (created account directly), Add Friend & Getting FriendRequests works normally._

Comments

  1. Mostafizur Rahman 2014-08-30

    Hello, We have tested this issue with above codes. The Above codes does not work with regular users (those that created an account on ACS) and also not works with Facebook Logged in Users. Please provides some workable test case. *Testing Environment:* Titanium SDK: 3.3.0.GA and 3.2.3.GA Titanium CLI: 3.3.0 OS X Version: 10.9.3 Android version: 4.3 Android API Level: 17 and 19 *Steps To Reproduce:* a) Create a simple project. b) Update this code in app.js c) Add ti.cloud module in tiapp.xml d) Run this with testing environment Thanks
  2. Joseph Sachs 2014-09-20

    Can we bump this issue :)
  3. Joseph Sachs 2014-09-23

    This issue has been fixed automatically, did not edit the code, but started working :) You may close this ticket.
  4. Mauro Parra-Miranda 2014-09-24

    Temporal glitch in the cloud.

JSON Source