Skip to content
This repository was archived by the owner on Sep 25, 2024. It is now read-only.

Commit cbc07ae

Browse files
committed
add new api: handleFriendRequest
1 parent b084718 commit cbc07ae

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

fb-chat-api/src/handleFriendRequest.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,37 @@ module.exports = function (defaultFuncs, api, ctx) {
2828
}
2929

3030
const form = {
31-
viewer_id: ctx.i_userID || ctx.userID,
32-
"frefs[0]": "jwl",
33-
floc: "friend_center_requests",
34-
ref: "/reqs.php",
35-
action: (accept ? "confirm" : "reject")
31+
fb_api_caller_class: "RelayModern",
32+
fb_api_req_friendly_name: "FriendingCometFriendRequestConfirmMutation",
33+
doc_id: "7303313029748461",
34+
variables: JSON.stringify({
35+
input: {
36+
friend_requester_id: String(userID),
37+
source: "friends_tab",
38+
actor_id: ctx.i_userID || ctx.userID,
39+
client_mutation_id: Math.round(Math.random() * 1024).toString()
40+
},
41+
scale: 1,
42+
refresh_num: 0
43+
}),
44+
av: ctx.i_userID || ctx.userID
3645
};
3746

3847
defaultFuncs
3948
.post(
40-
"https://www.facebook.com/requests/friends/ajax/",
49+
"https://www.facebook.com/api/graphql/",
4150
ctx.jar,
4251
form
4352
)
4453
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
4554
.then(function (resData) {
46-
if (resData.payload.err) {
55+
if (resData.error || resData.errors) {
4756
throw {
4857
err: resData.payload.err
4958
};
5059
}
5160

52-
return callback();
61+
return callback(null, resData);
5362
})
5463
.catch(function (err) {
5564
log.error("handleFriendRequest", err);

0 commit comments

Comments
 (0)