node-ainzfb-new 1.6.2902-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 +7 -7
  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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-ainzfb-new",
3
- "version": "1.6.2902-test",
3
+ "version": "1.6.2909-test",
4
4
  "description": "A Facebook chat API that doesn't rely on XMPP. Will NOT be deprecated after April 30th 2015.",
5
5
  "scripts": {
6
6
  "test": "mocha",
@@ -26,24 +26,24 @@
26
26
  "aes-js": "latest",
27
27
  "assert": "latest",
28
28
  "better-sqlite3": "latest",
29
- "bluebird": "^2.11.0",
29
+ "bluebird": "latest",
30
30
  "chalk": "^4.1.2",
31
- "cheerio": "^0.22.0",
31
+ "cheerio": "latest",
32
32
  "crypto": "latest",
33
33
  "gettext.js": "^1.1.1",
34
34
  "got": "^11.8.3",
35
- "https-proxy-agent": "^4.0.0",
35
+ "https-proxy-agent": "latest",
36
36
  "is-hexcolor": "^1.0.0",
37
37
  "lodash": "",
38
38
  "mqtt": "^4.3.7",
39
39
  "node-superfetch": "^0.2.3",
40
- "npmlog": "^1.2.0",
40
+ "npmlog": "latest",
41
41
  "path": "latest",
42
42
  "pretty-ms": "latest",
43
- "request": "^2.53.0",
43
+ "request": "latest",
44
44
  "semver": "latest",
45
45
  "sus-support": "git+https://github.com/amogusdevlol/sus-support.git",
46
- "websocket-stream": "^5.5.0"
46
+ "websocket-stream": "latest"
47
47
  },
48
48
  "engines": {
49
49
  "node": ">=10.x"
@@ -2,15 +2,22 @@
2
2
 
3
3
  const utils = require("../utils");
4
4
 
5
- module.exports = function (defaultFuncs, api, ctx) {
5
+ module.exports = function(defaultFuncs, api, ctx) {
6
6
  return function addExternalModule(moduleObj) {
7
7
  if (utils.getType(moduleObj) == "Object") {
8
8
  for (let apiName in moduleObj) {
9
- if (utils.getType(moduleObj[apiName]) == "Function") api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
10
- else throw new Error(`Item "${apiName}" in moduleObj must be a function, not ${utils.getType(moduleObj[apiName])}!`);
11
-
9
+ if (utils.getType(moduleObj[apiName]) == "Function")
10
+ api[apiName] = moduleObj[apiName](defaultFuncs, api, ctx);
11
+ else
12
+ throw new Error(
13
+ `Item "${apiName}" in moduleObj must be a function, not ${utils.getType(
14
+ moduleObj[apiName]
15
+ )}!`
16
+ );
12
17
  }
13
- }
14
- else throw new Error(`moduleObj must be an object, not ${utils.getType(moduleObj)}!`);
18
+ } else
19
+ throw new Error(
20
+ `moduleObj must be an object, not ${utils.getType(moduleObj)}!`
21
+ );
15
22
  };
16
23
  };
@@ -3,25 +3,39 @@
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 addUserToGroup(userID, 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
- if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
15
+ if (
16
+ !callback &&
17
+ (utils.getType(threadID) === "Function" ||
18
+ utils.getType(threadID) === "AsyncFunction")
19
+ )
20
+ throw { error: "please pass a threadID as a second argument." };
16
21
 
17
22
  if (!callback) {
18
- callback = function (err) {
23
+ callback = function(err) {
19
24
  if (err) return rejectFunc(err);
20
25
  resolveFunc();
21
26
  };
22
27
  }
23
28
 
24
- if (utils.getType(threadID) !== "Number" && utils.getType(threadID) !== "String") throw { error: "ThreadID should be of type Number or String and not " + utils.getType(threadID) + "." };
29
+ if (
30
+ utils.getType(threadID) !== "Number" &&
31
+ utils.getType(threadID) !== "String"
32
+ )
33
+ throw {
34
+ error:
35
+ "ThreadID should be of type Number or String and not " +
36
+ utils.getType(threadID) +
37
+ "."
38
+ };
25
39
 
26
40
  if (utils.getType(userID) !== "Array") userID = [userID];
27
41
 
@@ -54,21 +68,30 @@ module.exports = function (defaultFuncs, api, ctx) {
54
68
  };
55
69
 
56
70
  for (var i = 0; i < userID.length; i++) {
57
- if (utils.getType(userID[i]) !== "Number" && utils.getType(userID[i]) !== "String") throw { error: "Elements of userID should be of type Number or String and not " + utils.getType(userID[i]) + "." };
58
- form["log_message_data[added_participants][" + i + "]"] = "fbid:" + userID[i];
71
+ if (
72
+ utils.getType(userID[i]) !== "Number" &&
73
+ utils.getType(userID[i]) !== "String"
74
+ )
75
+ throw {
76
+ error:
77
+ "Elements of userID should be of type Number or String and not " +
78
+ utils.getType(userID[i]) +
79
+ "."
80
+ };
81
+ form["log_message_data[added_participants][" + i + "]"] =
82
+ "fbid:" + userID[i];
59
83
  }
60
84
 
61
85
  defaultFuncs
62
86
  .post("https://www.facebook.com/messaging/send/", ctx.jar, form)
63
87
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
64
- .then(function (resData) {
88
+ .then(function(resData) {
65
89
  if (!resData) throw { error: "Add to group failed." };
66
90
  if (resData.error) throw resData;
67
91
 
68
-
69
92
  return callback();
70
93
  })
71
- .catch(function (err) {
94
+ .catch(function(err) {
72
95
  log.error("addUserToGroup", err);
73
96
  return callback(err);
74
97
  });
@@ -6,7 +6,7 @@ const log = require("npmlog");
6
6
  module.exports = function(defaultFuncs, api, ctx) {
7
7
  return function changeAdminStatus(threadID, adminIDs, adminStatus, callback) {
8
8
  if (utils.getType(threadID) !== "String") {
9
- throw {error: "changeAdminStatus: threadID must be a string"};
9
+ throw { error: "changeAdminStatus: threadID must be a string" };
10
10
  }
11
11
 
12
12
  if (utils.getType(adminIDs) === "String") {
@@ -14,22 +14,22 @@ module.exports = function(defaultFuncs, api, ctx) {
14
14
  }
15
15
 
16
16
  if (utils.getType(adminIDs) !== "Array") {
17
- throw {error: "changeAdminStatus: adminIDs must be an array or string"};
17
+ throw { error: "changeAdminStatus: adminIDs must be an array or string" };
18
18
  }
19
19
 
20
20
  if (utils.getType(adminStatus) !== "Boolean") {
21
- throw {error: "changeAdminStatus: adminStatus must be a string"};
21
+ throw { error: "changeAdminStatus: adminStatus must be a string" };
22
22
  }
23
23
 
24
- var resolveFunc = function(){};
25
- var rejectFunc = function(){};
26
- var returnPromise = new Promise(function (resolve, reject) {
24
+ var resolveFunc = function() {};
25
+ var rejectFunc = function() {};
26
+ var returnPromise = new Promise(function(resolve, reject) {
27
27
  resolveFunc = resolve;
28
28
  rejectFunc = reject;
29
29
  });
30
30
 
31
31
  if (!callback) {
32
- callback = function (err) {
32
+ callback = function(err) {
33
33
  if (err) {
34
34
  return rejectFunc(err);
35
35
  }
@@ -37,12 +37,15 @@ module.exports = function(defaultFuncs, api, ctx) {
37
37
  };
38
38
  }
39
39
 
40
- if (utils.getType(callback) !== "Function" && utils.getType(callback) !== "AsyncFunction") {
41
- throw {error: "changeAdminStatus: callback is not a function"};
40
+ if (
41
+ utils.getType(callback) !== "Function" &&
42
+ utils.getType(callback) !== "AsyncFunction"
43
+ ) {
44
+ throw { error: "changeAdminStatus: callback is not a function" };
42
45
  }
43
46
 
44
47
  let form = {
45
- "thread_fbid": threadID,
48
+ thread_fbid: threadID
46
49
  };
47
50
 
48
51
  let i = 0;
@@ -52,17 +55,31 @@ module.exports = function(defaultFuncs, api, ctx) {
52
55
  form["add"] = adminStatus;
53
56
 
54
57
  defaultFuncs
55
- .post("https://www.facebook.com/messaging/save_admins/?dpr=1", ctx.jar, form)
58
+ .post(
59
+ "https://www.facebook.com/messaging/save_admins/?dpr=1",
60
+ ctx.jar,
61
+ form
62
+ )
56
63
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
57
64
  .then(function(resData) {
58
65
  if (resData.error) {
59
66
  switch (resData.error) {
60
67
  case 1976004:
61
- throw { error: "Cannot alter admin status: you are not an admin.", rawResponse: resData };
68
+ throw {
69
+ error: "Cannot alter admin status: you are not an admin.",
70
+ rawResponse: resData
71
+ };
62
72
  case 1357031:
63
- throw { error: "Cannot alter admin status: this thread is not a group chat.", rawResponse: resData };
73
+ throw {
74
+ error:
75
+ "Cannot alter admin status: this thread is not a group chat.",
76
+ rawResponse: resData
77
+ };
64
78
  default:
65
- throw { error: "Cannot alter admin status: unknown error.", rawResponse: resData };
79
+ throw {
80
+ error: "Cannot alter admin status: unknown error.",
81
+ rawResponse: resData
82
+ };
66
83
  }
67
84
  }
68
85
 
@@ -72,8 +89,7 @@ module.exports = function(defaultFuncs, api, ctx) {
72
89
  log.error("changeAdminStatus", err);
73
90
  return callback(err);
74
91
  });
75
-
92
+
76
93
  return returnPromise;
77
94
  };
78
95
  };
79
-
@@ -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 changeArchivedStatus(threadOrThreads, archive, 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
  };
@@ -21,17 +21,23 @@ module.exports = function (defaultFuncs, api, ctx) {
21
21
 
22
22
  var form = {};
23
23
 
24
- if (utils.getType(threadOrThreads) === "Array") for (var i = 0; i < threadOrThreads.length; i++) form["ids[" + threadOrThreads[i] + "]"] = archive;
24
+ if (utils.getType(threadOrThreads) === "Array")
25
+ for (var i = 0; i < threadOrThreads.length; i++)
26
+ form["ids[" + threadOrThreads[i] + "]"] = archive;
25
27
  else form["ids[" + threadOrThreads + "]"] = archive;
26
28
 
27
29
  defaultFuncs
28
- .post("https://www.facebook.com/ajax/mercury/change_archived_status.php", ctx.jar, form)
30
+ .post(
31
+ "https://www.facebook.com/ajax/mercury/change_archived_status.php",
32
+ ctx.jar,
33
+ form
34
+ )
29
35
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
30
- .then(function (resData) {
36
+ .then(function(resData) {
31
37
  if (resData.error) throw resData;
32
38
  return callback();
33
39
  })
34
- .catch(function (err) {
40
+ .catch(function(err) {
35
41
  log.error("changeArchivedStatus", err);
36
42
  return callback(err);
37
43
  });
package/src/changeAvt.js CHANGED
@@ -10,76 +10,82 @@ var log = require("npmlog");
10
10
  * @returns The JSON.parse(Data.split("for (;;);")[1]); is returning the following:
11
11
  * {"__ar":1,"payload":null,"jsmods":{"require":[["ImageUploader","uploadPhoto",[{"__m":"__elem_0"},{"__m":"__elem_1"},{"__m":"__elem_2"},{"__m":"__
12
12
  */
13
- async function postImage(Api,BotID,form) {
14
- var Data = await Api.httpPostFormData(`https://www.facebook.com/profile/picture/upload/?profile_id=${BotID}&photo_source=57&av=${BotID}`, form);
15
- return JSON.parse(Data.split("for (;;);")[1]);
13
+ async function postImage(Api, BotID, form) {
14
+ var Data = await Api.httpPostFormData(
15
+ `https://www.facebook.com/profile/picture/upload/?profile_id=${BotID}&photo_source=57&av=${BotID}`,
16
+ form
17
+ );
18
+ return JSON.parse(Data.split("for (;;);")[1]);
16
19
  }
17
20
 
18
21
  module.exports = function(defaultFuncs, api, ctx) {
19
- /* Changing the profile picture of the bot. */
20
- return function changeAvt(link, caption, callback) {
21
- var resolveFunc = function() {};
22
- var rejectFunc = function() {};
23
- var returnPromise = new Promise(function(resolve, reject) {
24
- resolveFunc = resolve;
25
- rejectFunc = reject;
26
- });
22
+ /* Changing the profile picture of the bot. */
23
+ return function changeAvt(link, caption, callback) {
24
+ var resolveFunc = function() {};
25
+ var rejectFunc = function() {};
26
+ var returnPromise = new Promise(function(resolve, reject) {
27
+ resolveFunc = resolve;
28
+ rejectFunc = reject;
29
+ });
27
30
 
28
- if (!callback) {
29
- callback = function(err, data) {
30
- if (err) return rejectFunc(err);
31
- resolveFunc(data);
32
- };
33
- }
34
- try {
35
- var Fetch = require('axios')
36
- Fetch.get(link, { responseType: "stream" }).then(data => {
37
- postImage(api, ctx.userID, { file: data.data }).then(data => {
38
- if (data.error) throw new Error({ error: data.error, des: data.error.errorDescription });
39
- var form = {
40
- av: ctx.userID,
41
- fb_api_req_friendly_name: "ProfileCometProfilePictureSetMutation",
42
- fb_api_caller_class: "RelayModern",
43
- doc_id: "5066134240065849",
44
- variables: JSON.stringify({
45
- input: {
46
- caption: (caption || ""),
47
- existing_photo_id: data.payload.fbid,
48
- expiration_time: null,
49
- profile_id: ctx.userID,
50
- profile_pic_method: "EXISTING",
51
- profile_pic_source: "TIMELINE",
52
- scaled_crop_rect: {
53
- height: 1,
54
- width: 1,
55
- x: 0,
56
- y: 0
57
- },
58
- skip_cropping: true,
59
- actor_id: ctx.userID,
60
- client_mutation_id: Math.round(Math.random() * 19).toString()
61
- },
62
- isPage: false,
63
- isProfile: true,
64
- scale: 3,
65
- })
66
- };
67
- defaultFuncs
68
- .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
69
- .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
70
- .then(function(resData) {
71
- if (resData.error) throw resData;
72
- else return callback(null,true)
73
- })
74
- .catch(function(err) {
75
- return callback(err);
76
- });
77
- })
78
- })
79
- }
80
- catch (e) {
81
- throw e;
82
- }
83
- return returnPromise;
84
- };
85
- };
31
+ if (!callback) {
32
+ callback = function(err, data) {
33
+ if (err) return rejectFunc(err);
34
+ resolveFunc(data);
35
+ };
36
+ }
37
+ try {
38
+ var Fetch = require("axios");
39
+ Fetch.get(link, { responseType: "stream" }).then(data => {
40
+ postImage(api, ctx.userID, { file: data.data }).then(data => {
41
+ if (data.error)
42
+ throw new Error({
43
+ error: data.error,
44
+ des: data.error.errorDescription
45
+ });
46
+ var form = {
47
+ av: ctx.userID,
48
+ fb_api_req_friendly_name: "ProfileCometProfilePictureSetMutation",
49
+ fb_api_caller_class: "RelayModern",
50
+ doc_id: "5066134240065849",
51
+ variables: JSON.stringify({
52
+ input: {
53
+ caption: caption || "",
54
+ existing_photo_id: data.payload.fbid,
55
+ expiration_time: null,
56
+ profile_id: ctx.userID,
57
+ profile_pic_method: "EXISTING",
58
+ profile_pic_source: "TIMELINE",
59
+ scaled_crop_rect: {
60
+ height: 1,
61
+ width: 1,
62
+ x: 0,
63
+ y: 0
64
+ },
65
+ skip_cropping: true,
66
+ actor_id: ctx.userID,
67
+ client_mutation_id: Math.round(Math.random() * 19).toString()
68
+ },
69
+ isPage: false,
70
+ isProfile: true,
71
+ scale: 3
72
+ })
73
+ };
74
+ defaultFuncs
75
+ .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
76
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
77
+ .then(function(resData) {
78
+ if (resData.error) throw resData;
79
+ else return callback(null, true);
80
+ })
81
+ .catch(function(err) {
82
+ return callback(err);
83
+ });
84
+ });
85
+ });
86
+ } catch (e) {
87
+ throw e;
88
+ }
89
+ return returnPromise;
90
+ };
91
+ };
package/src/changeBio.js CHANGED
@@ -3,19 +3,23 @@
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 changeBio(bio, publish, 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
- if (utils.getType(publish) == "Function" || utils.getType(publish) == "AsyncFunction") callback = publish;
16
+ if (
17
+ utils.getType(publish) == "Function" ||
18
+ utils.getType(publish) == "AsyncFunction"
19
+ )
20
+ callback = publish;
17
21
  else {
18
- callback = function (err) {
22
+ callback = function(err) {
19
23
  if (err) return rejectFunc(err);
20
24
  resolveFunc();
21
25
  };
@@ -50,12 +54,12 @@ module.exports = function (defaultFuncs, api, ctx) {
50
54
  defaultFuncs
51
55
  .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
52
56
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
53
- .then(function (resData) {
57
+ .then(function(resData) {
54
58
  if (resData.errors) throw resData;
55
59
 
56
60
  return callback();
57
61
  })
58
- .catch(function (err) {
62
+ .catch(function(err) {
59
63
  log.error("changeBio", err);
60
64
  return callback(err);
61
65
  });
@@ -3,31 +3,37 @@
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 changeBlockedStatus(userID, block, 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
  };
20
20
  }
21
21
 
22
22
  defaultFuncs
23
- .post(`https://www.facebook.com/messaging/${block ? "" : "un"}block_messages/`, ctx.jar, { fbid: userID })
23
+ .post(
24
+ `https://www.facebook.com/messaging/${
25
+ block ? "" : "un"
26
+ }block_messages/`,
27
+ ctx.jar,
28
+ { fbid: userID }
29
+ )
24
30
  .then(utils.saveCookies(ctx.jar))
25
31
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
26
- .then(function (resData) {
32
+ .then(function(resData) {
27
33
  if (resData.error) throw resData;
28
34
  return callback();
29
35
  })
30
- .catch(function (err) {
36
+ .catch(function(err) {
31
37
  log.error("changeBlockedStatus", err);
32
38
  return callback(err);
33
39
  });
@@ -4,7 +4,7 @@ var utils = require("../utils");
4
4
  var log = require("npmlog");
5
5
  var bluebird = require("bluebird");
6
6
 
7
- module.exports = function (defaultFuncs, api, ctx) {
7
+ module.exports = function(defaultFuncs, api, ctx) {
8
8
  function handleUpload(image, callback) {
9
9
  var uploads = [];
10
10
 
@@ -15,9 +15,14 @@ module.exports = function (defaultFuncs, api, ctx) {
15
15
 
16
16
  uploads.push(
17
17
  defaultFuncs
18
- .postFormData("https://upload.facebook.com/ajax/mercury/upload.php", ctx.jar, form, {})
18
+ .postFormData(
19
+ "https://upload.facebook.com/ajax/mercury/upload.php",
20
+ ctx.jar,
21
+ form,
22
+ {}
23
+ )
19
24
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
20
- .then(function (resData) {
25
+ .then(function(resData) {
21
26
  if (resData.error) throw resData;
22
27
 
23
28
  return resData.payload.metadata[0];
@@ -28,24 +33,29 @@ module.exports = function (defaultFuncs, api, ctx) {
28
33
  bluebird
29
34
  .all(uploads)
30
35
  .then(resData => callback(null, resData))
31
- .catch(function (err) {
36
+ .catch(function(err) {
32
37
  log.error("handleUpload", err);
33
38
  return callback(err);
34
39
  });
35
40
  }
36
41
 
37
42
  return function changeGroupImage(image, threadID, callback) {
38
- if (!callback && (utils.getType(threadID) === "Function" || utils.getType(threadID) === "AsyncFunction")) throw { error: "please pass a threadID as a second argument." };
43
+ if (
44
+ !callback &&
45
+ (utils.getType(threadID) === "Function" ||
46
+ utils.getType(threadID) === "AsyncFunction")
47
+ )
48
+ throw { error: "please pass a threadID as a second argument." };
39
49
 
40
- var resolveFunc = function () { };
41
- var rejectFunc = function () { };
42
- var returnPromise = new Promise(function (resolve, reject) {
50
+ var resolveFunc = function() {};
51
+ var rejectFunc = function() {};
52
+ var returnPromise = new Promise(function(resolve, reject) {
43
53
  resolveFunc = resolve;
44
54
  rejectFunc = reject;
45
55
  });
46
56
 
47
57
  if (!callback) {
48
- callback = function (err) {
58
+ callback = function(err) {
49
59
  if (err) return rejectFunc(err);
50
60
  resolveFunc();
51
61
  };
@@ -81,21 +91,25 @@ module.exports = function (defaultFuncs, api, ctx) {
81
91
  timestamp_time_passed: "0"
82
92
  };
83
93
 
84
- handleUpload(image, function (err, payload) {
94
+ handleUpload(image, function(err, payload) {
85
95
  if (err) return callback(err);
86
96
 
87
97
  form["thread_image_id"] = payload[0]["image_id"];
88
98
  form["thread_id"] = threadID;
89
99
 
90
100
  defaultFuncs
91
- .post("https://www.facebook.com/messaging/set_thread_image/", ctx.jar, form)
101
+ .post(
102
+ "https://www.facebook.com/messaging/set_thread_image/",
103
+ ctx.jar,
104
+ form
105
+ )
92
106
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
93
- .then(function (resData) {
107
+ .then(function(resData) {
94
108
  // check for errors here
95
109
  if (resData.error) throw resData;
96
110
  return callback();
97
111
  })
98
- .catch(function (err) {
112
+ .catch(function(err) {
99
113
  log.error("changeGroupImage", err);
100
114
  return callback(err);
101
115
  });