node-ainzfb-new 1.6.2823-test → 1.6.2909-test

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. package/package.json +4 -4
  2. package/src/addExternalModule.js +13 -6
  3. package/src/addUserToGroup.js +35 -12
  4. package/src/changeAdminStatus.js +32 -16
  5. package/src/changeArchivedStatus.js +15 -9
  6. package/src/changeAvt.js +75 -69
  7. package/src/changeBio.js +12 -8
  8. package/src/changeBlockedStatus.js +14 -8
  9. package/src/changeGroupImage.js +27 -13
  10. package/src/changeNickname.js +19 -10
  11. package/src/changeThreadColor.js +15 -10
  12. package/src/changeThreadEmoji.js +17 -9
  13. package/src/createNewGroup.js +18 -10
  14. package/src/createPoll.js +16 -11
  15. package/src/deleteMessage.js +16 -10
  16. package/src/deleteThread.js +16 -10
  17. package/src/forwardAttachment.js +14 -9
  18. package/src/getAccessToken.js +21 -21
  19. package/src/getCurrentUserID.js +1 -1
  20. package/src/getEmojiUrl.js +3 -2
  21. package/src/getFriendsList.js +18 -10
  22. package/src/getMessage.js +52 -48
  23. package/src/getThreadHistory.js +156 -59
  24. package/src/getThreadHistoryDeprecated.js +26 -15
  25. package/src/getThreadInfo.js +3423 -18
  26. package/src/getThreadInfoDeprecated.js +25 -13
  27. package/src/getThreadList.js +112 -53
  28. package/src/getThreadListDeprecated.js +30 -12
  29. package/src/getThreadPictures.js +25 -13
  30. package/src/getUserID.js +7 -7
  31. package/src/getUserInfo.js +12 -9
  32. package/src/getUserInfoV2.js +19 -22
  33. package/src/handleFriendRequest.js +10 -9
  34. package/src/handleMessageRequest.js +16 -10
  35. package/src/httpGet.js +18 -13
  36. package/src/httpPost.js +18 -13
  37. package/src/httpPostFormData.js +14 -9
  38. package/src/listenMqtt.js +1218 -571
  39. package/src/logout.js +18 -13
  40. package/src/markAsDelivered.js +16 -10
  41. package/src/markAsRead.js +36 -24
  42. package/src/markAsReadAll.js +14 -10
  43. package/src/markAsSeen.js +18 -11
  44. package/src/muteThread.js +12 -8
  45. package/src/removeUserFromGroup.js +33 -10
  46. package/src/resolvePhotoUrl.js +8 -6
  47. package/src/searchForThread.js +13 -8
  48. package/src/sendMessage.js +172 -78
  49. package/src/sendTypingIndicator.js +29 -14
  50. package/src/setMessageReaction.js +13 -8
  51. package/src/setPostReaction.js +97 -95
  52. package/src/setTitle.js +18 -12
  53. package/src/threadColors.js +17 -17
  54. package/src/unfriend.js +14 -9
  55. package/src/unsendMessage.js +7 -7
  56. package/utils.js +2273 -1066
@@ -3,16 +3,16 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function changeNickname(nickname, threadID, participantID, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
8
+ var resolveFunc = function() {};
9
+ var rejectFunc = function() {};
10
+ var returnPromise = new Promise(function(resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
13
13
  });
14
14
  if (!callback) {
15
- callback = function (err) {
15
+ callback = function(err) {
16
16
  if (err) return rejectFunc(err);
17
17
  resolveFunc();
18
18
  };
@@ -25,17 +25,26 @@ module.exports = function (defaultFuncs, api, ctx) {
25
25
  };
26
26
 
27
27
  defaultFuncs
28
- .post("https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1", ctx.jar, form)
28
+ .post(
29
+ "https://www.facebook.com/messaging/save_thread_nickname/?source=thread_settings&dpr=1",
30
+ ctx.jar,
31
+ form
32
+ )
29
33
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
30
- .then(function (resData) {
31
- if (resData.error === 1545014) throw { error: "Trying to change nickname of user isn't in thread" };
32
- if (resData.error === 1357031) throw { error: "Trying to change user nickname of a thread that doesn't exist. Have at least one message in the thread before trying to change the user nickname." };
34
+ .then(function(resData) {
35
+ if (resData.error === 1545014)
36
+ throw { error: "Trying to change nickname of user isn't in thread" };
37
+ if (resData.error === 1357031)
38
+ throw {
39
+ error:
40
+ "Trying to change user nickname of a thread that doesn't exist. Have at least one message in the thread before trying to change the user nickname."
41
+ };
33
42
 
34
43
  if (resData.error) throw resData;
35
44
 
36
45
  return callback();
37
46
  })
38
- .catch(function (err) {
47
+ .catch(function(err) {
39
48
  log.error("changeNickname", err);
40
49
  return callback(err);
41
50
  });
@@ -3,27 +3,31 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function changeThreadColor(color, threadID, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
8
+ var resolveFunc = function() {};
9
+ var rejectFunc = function() {};
10
+ var returnPromise = new Promise(function(resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
13
13
  });
14
14
 
15
15
  if (!callback) {
16
- callback = function (err) {
16
+ callback = function(err) {
17
17
  if (err) return rejectFunc(err);
18
18
  resolveFunc(err);
19
19
  };
20
20
  }
21
21
 
22
22
  var validatedColor = color !== null ? color.toLowerCase() : color; // API only accepts lowercase letters in hex string
23
- var colorList = Object.keys(api.threadColors).map(function (name) {
23
+ var colorList = Object.keys(api.threadColors).map(function(name) {
24
24
  return api.threadColors[name];
25
25
  });
26
- if (!colorList.includes(validatedColor)) throw { error: "The color you are trying to use is not a valid thread color. Use api.threadColors to find acceptable values." };
26
+ if (!colorList.includes(validatedColor))
27
+ throw {
28
+ error:
29
+ "The color you are trying to use is not a valid thread color. Use api.threadColors to find acceptable values."
30
+ };
27
31
 
28
32
  var form = {
29
33
  dpr: 1,
@@ -47,12 +51,13 @@ module.exports = function (defaultFuncs, api, ctx) {
47
51
  defaultFuncs
48
52
  .post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
49
53
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
50
- .then(function (resData) {
51
- if (resData[resData.length - 1].error_results > 0) throw resData[0].o0.errors;
54
+ .then(function(resData) {
55
+ if (resData[resData.length - 1].error_results > 0)
56
+ throw resData[0].o0.errors;
52
57
 
53
58
  return callback();
54
59
  })
55
- .catch(function (err) {
60
+ .catch(function(err) {
56
61
  log.error("changeThreadColor", err);
57
62
  return callback(err);
58
63
  });
@@ -3,17 +3,17 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function changeThreadEmoji(emoji, threadID, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
8
+ var resolveFunc = function() {};
9
+ var rejectFunc = function() {};
10
+ var returnPromise = new Promise(function(resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
13
13
  });
14
14
 
15
15
  if (!callback) {
16
- callback = function (err) {
16
+ callback = function(err) {
17
17
  if (err) return rejectFunc(err);
18
18
  resolveFunc();
19
19
  };
@@ -24,15 +24,23 @@ module.exports = function (defaultFuncs, api, ctx) {
24
24
  };
25
25
 
26
26
  defaultFuncs
27
- .post("https://www.facebook.com/messaging/save_thread_emoji/?source=thread_settings&__pc=EXP1%3Amessengerdotcom_pkg", ctx.jar, form)
27
+ .post(
28
+ "https://www.facebook.com/messaging/save_thread_emoji/?source=thread_settings&__pc=EXP1%3Amessengerdotcom_pkg",
29
+ ctx.jar,
30
+ form
31
+ )
28
32
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
29
- .then(function (resData) {
30
- if (resData.error === 1357031) throw { error: "Trying to change emoji of a chat that doesn't exist. Have at least one message in the thread before trying to change the emoji." };
33
+ .then(function(resData) {
34
+ if (resData.error === 1357031)
35
+ throw {
36
+ error:
37
+ "Trying to change emoji of a chat that doesn't exist. Have at least one message in the thread before trying to change the emoji."
38
+ };
31
39
  if (resData.error) throw resData;
32
40
 
33
41
  return callback();
34
42
  })
35
- .catch(function (err) {
43
+ .catch(function(err) {
36
44
  log.error("changeThreadEmoji", err);
37
45
  return callback(err);
38
46
  });
@@ -3,26 +3,30 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function createNewGroup(participantIDs, groupTitle, callback) {
8
8
  if (utils.getType(groupTitle) == "Function") {
9
9
  callback = groupTitle;
10
10
  groupTitle = null;
11
11
  }
12
12
 
13
- if (utils.getType(participantIDs) !== "Array") throw { error: "createNewGroup: participantIDs should be an array." };
13
+ if (utils.getType(participantIDs) !== "Array")
14
+ throw { error: "createNewGroup: participantIDs should be an array." };
14
15
 
15
- if (participantIDs.length < 2) throw { error: "createNewGroup: participantIDs should have at least 2 IDs." };
16
+ if (participantIDs.length < 2)
17
+ throw {
18
+ error: "createNewGroup: participantIDs should have at least 2 IDs."
19
+ };
16
20
 
17
- var resolveFunc = function () { };
18
- var rejectFunc = function () { };
19
- var returnPromise = new Promise(function (resolve, reject) {
21
+ var resolveFunc = function() {};
22
+ var rejectFunc = function() {};
23
+ var returnPromise = new Promise(function(resolve, reject) {
20
24
  resolveFunc = resolve;
21
25
  rejectFunc = reject;
22
26
  });
23
27
 
24
28
  if (!callback) {
25
- callback = function (err, threadID) {
29
+ callback = function(err, threadID) {
26
30
  if (err) return rejectFunc(err);
27
31
  resolveFunc(threadID);
28
32
  };
@@ -56,11 +60,15 @@ module.exports = function (defaultFuncs, api, ctx) {
56
60
  defaultFuncs
57
61
  .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
58
62
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
59
- .then(function (resData) {
63
+ .then(function(resData) {
60
64
  if (resData.errors) throw resData;
61
- return callback(null, resData.data.messenger_group_thread_create.thread.thread_key.thread_fbid);
65
+ return callback(
66
+ null,
67
+ resData.data.messenger_group_thread_create.thread.thread_key
68
+ .thread_fbid
69
+ );
62
70
  })
63
- .catch(function (err) {
71
+ .catch(function(err) {
64
72
  log.error("createNewGroup", err);
65
73
  return callback(err);
66
74
  });
package/src/createPoll.js CHANGED
@@ -3,11 +3,11 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function createPoll(title, threadID, options, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
8
+ var resolveFunc = function() {};
9
+ var rejectFunc = function() {};
10
+ var returnPromise = new Promise(function(resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
13
13
  });
@@ -16,9 +16,8 @@ module.exports = function (defaultFuncs, api, ctx) {
16
16
  if (utils.getType(options) == "Function") {
17
17
  callback = options;
18
18
  options = null;
19
- }
20
- else {
21
- callback = function (err) {
19
+ } else {
20
+ callback = function(err) {
22
21
  if (err) return rejectFunc(err);
23
22
  resolveFunc();
24
23
  };
@@ -37,20 +36,26 @@ module.exports = function (defaultFuncs, api, ctx) {
37
36
  // eslint-disable-next-line no-prototype-builtins
38
37
  if (options.hasOwnProperty(opt)) {
39
38
  form["option_text_array[" + ind + "]"] = opt;
40
- form["option_is_selected_array[" + ind + "]"] = options[opt] ? "1" : "0";
39
+ form["option_is_selected_array[" + ind + "]"] = options[opt]
40
+ ? "1"
41
+ : "0";
41
42
  ind++;
42
43
  }
43
44
  }
44
45
 
45
46
  defaultFuncs
46
- .post("https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1", ctx.jar, form)
47
+ .post(
48
+ "https://www.facebook.com/messaging/group_polling/create_poll/?dpr=1",
49
+ ctx.jar,
50
+ form
51
+ )
47
52
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
48
- .then(function (resData) {
53
+ .then(function(resData) {
49
54
  if (resData.payload.status != "success") throw resData;
50
55
 
51
56
  return callback();
52
57
  })
53
- .catch(function (err) {
58
+ .catch(function(err) {
54
59
  log.error("createPoll", err);
55
60
  return callback(err);
56
61
  });
@@ -3,16 +3,16 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function deleteMessage(messageOrMessages, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
8
+ var resolveFunc = function() {};
9
+ var rejectFunc = function() {};
10
+ var returnPromise = new Promise(function(resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
13
13
  });
14
14
  if (!callback) {
15
- callback = function (err) {
15
+ callback = function(err) {
16
16
  if (err) return rejectFunc(err);
17
17
 
18
18
  resolveFunc();
@@ -23,19 +23,25 @@ module.exports = function (defaultFuncs, api, ctx) {
23
23
  client: "mercury"
24
24
  };
25
25
 
26
- if (utils.getType(messageOrMessages) !== "Array") messageOrMessages = [messageOrMessages];
26
+ if (utils.getType(messageOrMessages) !== "Array")
27
+ messageOrMessages = [messageOrMessages];
27
28
 
28
- for (var i = 0; i < messageOrMessages.length; i++) form["message_ids[" + i + "]"] = messageOrMessages[i];
29
+ for (var i = 0; i < messageOrMessages.length; i++)
30
+ form["message_ids[" + i + "]"] = messageOrMessages[i];
29
31
 
30
32
  defaultFuncs
31
- .post("https://www.facebook.com/ajax/mercury/delete_messages.php", ctx.jar, form)
33
+ .post(
34
+ "https://www.facebook.com/ajax/mercury/delete_messages.php",
35
+ ctx.jar,
36
+ form
37
+ )
32
38
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
33
- .then(function (resData) {
39
+ .then(function(resData) {
34
40
  if (resData.error) throw resData;
35
41
 
36
42
  return callback();
37
43
  })
38
- .catch(function (err) {
44
+ .catch(function(err) {
39
45
  log.error("deleteMessage", err);
40
46
  return callback(err);
41
47
  });
@@ -3,16 +3,16 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function deleteThread(threadOrThreads, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
8
+ var resolveFunc = function() {};
9
+ var rejectFunc = function() {};
10
+ var returnPromise = new Promise(function(resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
13
13
  });
14
14
  if (!callback) {
15
- callback = function (err) {
15
+ callback = function(err) {
16
16
  if (err) return rejectFunc(err);
17
17
  resolveFunc();
18
18
  };
@@ -22,18 +22,24 @@ module.exports = function (defaultFuncs, api, ctx) {
22
22
  client: "mercury"
23
23
  };
24
24
 
25
- if (utils.getType(threadOrThreads) !== "Array") threadOrThreads = [threadOrThreads];
26
- for (var i = 0; i < threadOrThreads.length; i++) form["ids[" + i + "]"] = threadOrThreads[i];
25
+ if (utils.getType(threadOrThreads) !== "Array")
26
+ threadOrThreads = [threadOrThreads];
27
+ for (var i = 0; i < threadOrThreads.length; i++)
28
+ form["ids[" + i + "]"] = threadOrThreads[i];
27
29
 
28
30
  defaultFuncs
29
- .post("https://www.facebook.com/ajax/mercury/delete_thread.php", ctx.jar, form)
31
+ .post(
32
+ "https://www.facebook.com/ajax/mercury/delete_thread.php",
33
+ ctx.jar,
34
+ form
35
+ )
30
36
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
31
- .then(function (resData) {
37
+ .then(function(resData) {
32
38
  if (resData.error) throw resData;
33
39
 
34
40
  return callback();
35
41
  })
36
- .catch(function (err) {
42
+ .catch(function(err) {
37
43
  log.error("deleteThread", err);
38
44
  return callback(err);
39
45
  });
@@ -3,16 +3,16 @@
3
3
  var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
 
6
- module.exports = function (defaultFuncs, api, ctx) {
6
+ module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function forwardAttachment(attachmentID, userOrUsers, callback) {
8
- var resolveFunc = function () { };
9
- var rejectFunc = function () { };
10
- var returnPromise = new Promise(function (resolve, reject) {
8
+ var resolveFunc = function() {};
9
+ var rejectFunc = function() {};
10
+ var returnPromise = new Promise(function(resolve, reject) {
11
11
  resolveFunc = resolve;
12
12
  rejectFunc = reject;
13
13
  });
14
14
  if (!callback) {
15
- callback = function (err) {
15
+ callback = function(err) {
16
16
  if (err) return rejectFunc(err);
17
17
  resolveFunc();
18
18
  };
@@ -28,17 +28,22 @@ module.exports = function (defaultFuncs, api, ctx) {
28
28
 
29
29
  //That's good, the key of the array is really timestmap in seconds + index
30
30
  //Probably time when the attachment will be sent?
31
- for (var i = 0; i < userOrUsers.length; i++) form["recipient_map[" + (timestamp + i) + "]"] = userOrUsers[i];
31
+ for (var i = 0; i < userOrUsers.length; i++)
32
+ form["recipient_map[" + (timestamp + i) + "]"] = userOrUsers[i];
32
33
 
33
34
  defaultFuncs
34
- .post("https://www.facebook.com/mercury/attachments/forward/", ctx.jar, form)
35
+ .post(
36
+ "https://www.facebook.com/mercury/attachments/forward/",
37
+ ctx.jar,
38
+ form
39
+ )
35
40
  .then(utils.parseAndCheckLogin(ctx.jar, defaultFuncs))
36
- .then(function (resData) {
41
+ .then(function(resData) {
37
42
  if (resData.error) throw resData;
38
43
 
39
44
  return callback();
40
45
  })
41
- .catch(function (err) {
46
+ .catch(function(err) {
42
47
  log.error("forwardAttachment", err);
43
48
  return callback(err);
44
49
  });
@@ -4,29 +4,29 @@
4
4
  var utils = require("../utils");
5
5
  var log = require("npmlog");
6
6
 
7
+ module.exports = function(defaultFuncs, api, ctx) {
8
+ return function getAccessToken(callback) {
9
+ var resolveFunc = function() {};
10
+ var rejectFunc = function() {};
11
+ var returnPromise = new Promise(function(resolve, reject) {
12
+ resolveFunc = resolve;
13
+ rejectFunc = reject;
14
+ });
7
15
 
8
- module.exports = function (defaultFuncs, api, ctx) {
9
- return function getAccessToken(callback) {
10
- var resolveFunc = function () { };
11
- var rejectFunc = function () { };
12
- var returnPromise = new Promise(function (resolve, reject) {
13
- resolveFunc = resolve;
14
- rejectFunc = reject;
15
- });
16
-
17
- if (!callback) {
18
- callback = function (err, userInfo) {
19
- if (err) return rejectFunc(err);
20
- resolveFunc(userInfo);
21
- };
22
- }
23
- try {
24
- var { getAccessToken } = require('../Extra/ExtraAddons');
25
- getAccessToken(ctx.jar,ctx,defaultFuncs).then(data => callback(null,data));
16
+ if (!callback) {
17
+ callback = function(err, userInfo) {
18
+ if (err) return rejectFunc(err);
19
+ resolveFunc(userInfo);
20
+ };
26
21
  }
27
- catch (e) {
22
+ try {
23
+ var { getAccessToken } = require("../Extra/ExtraAddons");
24
+ getAccessToken(ctx.jar, ctx, defaultFuncs).then(data =>
25
+ callback(null, data)
26
+ );
27
+ } catch (e) {
28
28
  callback(null, e);
29
29
  }
30
30
  return returnPromise;
31
- };
32
- };
31
+ };
32
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- module.exports = function (defaultFuncs, api, ctx) {
3
+ module.exports = function(defaultFuncs, api, ctx) {
4
4
  return function getCurrentUserID() {
5
5
  return ctx.userID;
6
6
  };
@@ -2,7 +2,7 @@
2
2
 
3
3
  const util = require("util");
4
4
 
5
- module.exports = function () {
5
+ module.exports = function() {
6
6
  return function getEmojiUrl(c, size, pixelRatio) {
7
7
  /*
8
8
  Resolves Facebook Messenger emoji image asset URL for an emoji character.
@@ -19,7 +19,8 @@ module.exports = function () {
19
19
  c.codePointAt(0).toString(16)
20
20
  );
21
21
  let base = 317426846;
22
- for (let i = 0; i < ending.length; i++) base = (base << 5) - base + ending.charCodeAt(i);
22
+ for (let i = 0; i < ending.length; i++)
23
+ base = (base << 5) - base + ending.charCodeAt(i);
23
24
 
24
25
  let hashed = (base & 255).toString(16);
25
26
  return util.format(baseUrl, hashed, ending);
@@ -21,7 +21,7 @@ var GENDERS = {
21
21
  };
22
22
 
23
23
  function formatData(obj) {
24
- return Object.keys(obj).map(function (key) {
24
+ return Object.keys(obj).map(function(key) {
25
25
  var user = obj[key];
26
26
  return {
27
27
  alternateName: user.alternateName,
@@ -39,32 +39,40 @@ function formatData(obj) {
39
39
  });
40
40
  }
41
41
 
42
- module.exports = function (defaultFuncs, api, ctx) {
42
+ module.exports = function(defaultFuncs, api, ctx) {
43
43
  return function getFriendsList(callback) {
44
- var resolveFunc = function () { };
45
- var rejectFunc = function () { };
46
- var returnPromise = new Promise(function (resolve, reject) {
44
+ var resolveFunc = function() {};
45
+ var rejectFunc = function() {};
46
+ var returnPromise = new Promise(function(resolve, reject) {
47
47
  resolveFunc = resolve;
48
48
  rejectFunc = reject;
49
49
  });
50
50
 
51
51
  if (!callback) {
52
- callback = function (err, friendList) {
52
+ callback = function(err, friendList) {
53
53
  if (err) return rejectFunc(err);
54
54
  resolveFunc(friendList);
55
55
  };
56
56
  }
57
57
 
58
58
  defaultFuncs
59
- .postFormData("https://www.facebook.com/chat/user_info_all", ctx.jar, {}, { viewer: ctx.userID })
59
+ .postFormData(
60
+ "https://www.facebook.com/chat/user_info_all",
61
+ ctx.jar,
62
+ {},
63
+ { viewer: ctx.userID }
64
+ )
60
65
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
61
- .then(function (resData) {
66
+ .then(function(resData) {
62
67
  if (!resData) throw { error: "getFriendsList returned empty object." };
63
68
  if (resData.error) throw resData;
64
69
  callback(null, formatData(resData.payload));
65
70
  })
66
- .catch(function (err) {
67
- log.error("getFriendsList", "Lỗi getFriendsList Có Thể Do Bạn Spam Quá Nhiều ! Hãy Hạn Chế !");
71
+ .catch(function(err) {
72
+ log.error(
73
+ "getFriendsList",
74
+ "Lỗi getFriendsList Có Thể Do Bạn Spam Quá Nhiều ! Hãy Hạn Chế !"
75
+ );
68
76
  return callback(err);
69
77
  });
70
78