@lazyneoaz/metachat 1.0.11 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/package.json +1 -1
  2. package/src/apis/changeAdminStatus.js +39 -50
  3. package/src/apis/changeArchivedStatus.js +16 -8
  4. package/src/apis/changeAvatar.js +2 -2
  5. package/src/apis/changeBio.js +1 -1
  6. package/src/apis/changeBlockedStatus.js +1 -1
  7. package/src/apis/changeGroupImage.js +22 -14
  8. package/src/apis/changeThreadEmoji.js +14 -8
  9. package/src/apis/createNewGroup.js +1 -1
  10. package/src/apis/createPoll.js +9 -3
  11. package/src/apis/deleteMessage.js +11 -8
  12. package/src/apis/deleteThread.js +1 -1
  13. package/src/apis/follow.js +27 -31
  14. package/src/apis/forwardMessage.js +1 -1
  15. package/src/apis/gcname.js +1 -1
  16. package/src/apis/getFriendsList.js +2 -2
  17. package/src/apis/getThreadInfo.js +1 -1
  18. package/src/apis/getThreadPictures.js +1 -1
  19. package/src/apis/handleMessageRequest.js +1 -1
  20. package/src/apis/listenMqtt.js +88 -3
  21. package/src/apis/markAsRead.js +15 -9
  22. package/src/apis/muteThread.js +1 -1
  23. package/src/apis/nickname.js +1 -1
  24. package/src/apis/pinMessage.js +110 -130
  25. package/src/apis/removeUserFromGroup.js +2 -2
  26. package/src/apis/resolvePhotoUrl.js +1 -1
  27. package/src/apis/searchForThread.js +1 -1
  28. package/src/apis/sendMessage.js +7 -0
  29. package/src/apis/setMessageReaction.js +3 -3
  30. package/src/apis/setMessageReactionMqtt.js +2 -2
  31. package/src/apis/setThreadThemeMqtt.js +70 -77
  32. package/src/apis/unfriend.js +1 -1
  33. package/src/apis/unsendMessage.js +71 -9
  34. package/src/app/state.js +1 -1
  35. package/src/types/index.d.ts +40 -1
  36. package/src/utils/antiSuspension.js +4 -4
  37. package/src/utils/auth-helpers.js +1 -1
  38. package/src/utils/lsRequest.js +2 -3
  39. package/src/utils/tokenRefresh.js +10 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazyneoaz/metachat",
3
- "version": "1.0.11",
3
+ "version": "1.1.0",
4
4
  "type": "commonjs",
5
5
  "types": "src/types/index.d.ts",
6
6
  "description": "Advanced Facebook Chat API client for building Messenger bots — real-time messaging, thread management, MQTT, and session stability.",
@@ -20,56 +20,54 @@ module.exports = function (defaultFuncs, api, ctx) {
20
20
  if (err) return rejectFunc(err);
21
21
  resolveFunc(data);
22
22
  };
23
+ } else {
24
+ const _userCb = callback;
25
+ callback = function(err, data) {
26
+ if (err) { _userCb(err); return rejectFunc(err); }
27
+ _userCb(null, data);
28
+ resolveFunc(data);
29
+ };
23
30
  }
24
31
 
25
32
  if (getType(threadID) !== "String") {
26
- return callback({ error: "changeAdminStatus: threadID must be a string" });
33
+ callback(new Error("changeAdminStatus: threadID must be a string"));
34
+ return returnPromise;
27
35
  }
28
36
  if (getType(adminID) !== "String" && getType(adminID) !== "Array") {
29
- return callback({ error: "changeAdminStatus: adminID must be a string or an array" });
37
+ callback(new Error("changeAdminStatus: adminID must be a string or an array"));
38
+ return returnPromise;
30
39
  }
31
40
  if (getType(adminStatus) !== "Boolean") {
32
- return callback({ error: "changeAdminStatus: adminStatus must be true or false" });
41
+ callback(new Error("changeAdminStatus: adminStatus must be true or false"));
42
+ return returnPromise;
33
43
  }
34
44
 
35
- if (ctx.mqttClient) {
45
+ const isAdmin = adminStatus ? 1 : 0;
46
+
47
+ if (ctx.mqttClient && ctx.mqttClient.connected) {
36
48
  const tasks = [];
37
- const isAdmin = adminStatus ? 1 : 0;
38
49
  const epochID = utils.generateOfflineThreadingID();
39
50
 
40
51
  if (typeof ctx.wsReqNumber !== "number") ctx.wsReqNumber = 0;
41
52
  if (typeof ctx.wsTaskNumber !== "number") ctx.wsTaskNumber = 0;
42
53
 
43
- if (getType(adminID) === "Array") {
44
- adminID.forEach((id) => {
45
- tasks.push({
46
- failure_count: null,
47
- label: "25",
48
- payload: JSON.stringify({
49
- thread_key: threadID,
50
- contact_id: id,
51
- is_admin: isAdmin
52
- }),
53
- queue_name: "admin_status",
54
- task_id: ++ctx.wsTaskNumber
55
- });
56
- });
57
- } else {
54
+ const adminIDs = getType(adminID) === "Array" ? adminID : [adminID];
55
+ adminIDs.forEach((id) => {
58
56
  tasks.push({
59
57
  failure_count: null,
60
58
  label: "25",
61
59
  payload: JSON.stringify({
62
60
  thread_key: threadID,
63
- contact_id: adminID,
61
+ contact_id: id,
64
62
  is_admin: isAdmin
65
63
  }),
66
64
  queue_name: "admin_status",
67
65
  task_id: ++ctx.wsTaskNumber
68
66
  });
69
- }
67
+ });
70
68
 
71
69
  const form = JSON.stringify({
72
- app_id: "2220391788200892",
70
+ app_id: String(ctx.appID || ctx.mqttAppID || "2220391788200892"),
73
71
  payload: JSON.stringify({
74
72
  epoch_id: epochID,
75
73
  tasks: tasks,
@@ -79,55 +77,46 @@ module.exports = function (defaultFuncs, api, ctx) {
79
77
  type: 3
80
78
  });
81
79
 
82
- ctx.mqttClient.publish("/ls_req", form, {}, (err, _packet) => {
80
+ ctx.mqttClient.publish("/ls_req", form, { qos: 1, retain: false }, (err) => {
83
81
  if (err) {
84
82
  utils.error("changeAdminStatus (MQTT)", err);
85
- return callback(err);
86
- } else {
87
- utils.log("Admin status changed successfully via MQTT");
88
- return callback(null, { success: true });
83
+ return callback(err instanceof Error ? err : new Error(String(err)));
89
84
  }
85
+ utils.log("Admin status changed successfully via MQTT");
86
+ return callback(null, { success: true });
90
87
  });
91
88
  } else {
92
89
  utils.warn("MQTT client not available, using HTTP fallback for changeAdminStatus");
93
90
  const tasks = [];
94
91
  const epochID = utils.generateOfflineThreadingID();
95
92
 
96
- if (getType(adminID) === "Array") {
97
- adminID.forEach((id) => {
98
- tasks.push({
99
- label: '25',
100
- payload: JSON.stringify({ thread_key: threadID, contact_id: id, is_admin: adminStatus }),
101
- queue_name: 'admin_status',
102
- task_id: ++ctx.wsTaskNumber,
103
- failure_count: null
104
- });
105
- });
106
- } else {
93
+ if (typeof ctx.wsReqNumber !== "number") ctx.wsReqNumber = 0;
94
+ if (typeof ctx.wsTaskNumber !== "number") ctx.wsTaskNumber = 0;
95
+
96
+ const adminIDs = getType(adminID) === "Array" ? adminID : [adminID];
97
+ adminIDs.forEach((id) => {
107
98
  tasks.push({
108
- label: '25',
109
- payload: JSON.stringify({ thread_key: threadID, contact_id: adminID, is_admin: adminStatus }),
110
- queue_name: 'admin_status',
99
+ label: "25",
100
+ payload: JSON.stringify({ thread_key: threadID, contact_id: id, is_admin: isAdmin }),
101
+ queue_name: "admin_status",
111
102
  task_id: ++ctx.wsTaskNumber,
112
103
  failure_count: null
113
104
  });
114
- }
105
+ });
115
106
 
116
107
  const form = {
117
108
  fb_dtsg: ctx.fb_dtsg,
118
109
  request_id: ++ctx.wsReqNumber,
119
110
  type: 3,
120
- payload: {
121
- version_id: '3816854585040595',
111
+ payload: JSON.stringify({
112
+ version_id: "8798795233522156",
122
113
  tasks: tasks,
123
114
  epoch_id: epochID,
124
115
  data_trace_id: null
125
- },
126
- app_id: '772021112871879'
116
+ }),
117
+ app_id: String(ctx.appID || ctx.mqttAppID || "772021112871879")
127
118
  };
128
119
 
129
- form.payload = JSON.stringify(form.payload);
130
-
131
120
  defaultFuncs
132
121
  .post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
133
122
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
@@ -137,7 +126,7 @@ module.exports = function (defaultFuncs, api, ctx) {
137
126
  })
138
127
  .catch(err => {
139
128
  utils.error("changeAdminStatus (HTTP)", err);
140
- callback(err);
129
+ callback(err instanceof Error ? err : new Error(String(err && err.message ? err.message : err)));
141
130
  });
142
131
  }
143
132
 
@@ -11,19 +11,27 @@ module.exports = (defaultFuncs, api, ctx) => {
11
11
  rejectFunc = reject;
12
12
  });
13
13
 
14
+ // Detect (threadIDs, callback) — archive omitted
15
+ if (utils.getType(archive) === "Function") {
16
+ callback = archive;
17
+ archive = true;
18
+ }
19
+
14
20
  if (!callback) {
15
21
  callback = (err, result) => {
16
22
  if (err) return rejectFunc(err);
17
23
  resolveFunc(result);
18
24
  };
25
+ } else {
26
+ const _userCb = callback;
27
+ callback = (err, result) => {
28
+ if (err) { _userCb(err); return rejectFunc(err); }
29
+ _userCb(null, result);
30
+ resolveFunc(result);
31
+ };
19
32
  }
20
33
 
21
34
  try {
22
- if (utils.getType(archive) === "Function") {
23
- callback = archive;
24
- archive = true;
25
- }
26
-
27
35
  if (utils.getType(archive) !== "Boolean") {
28
36
  throw new Error("archive parameter must be a boolean");
29
37
  }
@@ -35,7 +43,7 @@ module.exports = (defaultFuncs, api, ctx) => {
35
43
  const form = {
36
44
  should_archive: archive
37
45
  };
38
-
46
+
39
47
  threadIDs.forEach(id => {
40
48
  form[`thread_fbids[${id}]`] = true;
41
49
  });
@@ -47,13 +55,13 @@ module.exports = (defaultFuncs, api, ctx) => {
47
55
  ).then(utils.parseAndCheckLogin(ctx, defaultFuncs));
48
56
 
49
57
  if (res && res.error) {
50
- throw res;
58
+ throw new Error(String(res.error_msg || res.error || "changeArchivedStatus failed"));
51
59
  }
52
60
 
53
61
  callback(null, { success: true });
54
62
  } catch (err) {
55
63
  utils.error("changeArchivedStatus", err);
56
- callback(err);
64
+ callback(err instanceof Error ? err : new Error(String(err && err.message ? err.message : err)));
57
65
  }
58
66
 
59
67
  return returnPromise;
@@ -18,7 +18,7 @@ module.exports = (defaultFuncs, api, ctx) => {
18
18
  {}
19
19
  ).then(utils.parseAndCheckLogin(ctx, defaultFuncs))
20
20
  .then(resData => {
21
- if (resData.error) throw resData;
21
+ if (resData.error) throw new Error(resData.error_msg || resData.errorSummary || String(resData.error));
22
22
  return resData;
23
23
  });
24
24
  }
@@ -89,7 +89,7 @@ module.exports = (defaultFuncs, api, ctx) => {
89
89
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs));
90
90
 
91
91
  if (res.errors) {
92
- throw res;
92
+ throw new Error(JSON.stringify(res.errors));
93
93
  }
94
94
 
95
95
  callback(null, res[0].data.profile_picture_set);
@@ -55,7 +55,7 @@ module.exports = (defaultFuncs, api, ctx) => {
55
55
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs));
56
56
 
57
57
  if (res.errors) {
58
- throw res;
58
+ throw new Error(JSON.stringify(res.errors));
59
59
  }
60
60
 
61
61
  callback(null, { success: true });
@@ -40,7 +40,7 @@ module.exports = (defaultFuncs, api, ctx) => {
40
40
  ).then(utils.parseAndCheckLogin(ctx, defaultFuncs));
41
41
 
42
42
  if (res && res.error) {
43
- throw res;
43
+ throw new Error(res.error_msg || res.errorSummary || String(res.error));
44
44
  }
45
45
 
46
46
  return callback(null, { success: true, blocked: block });
@@ -30,8 +30,20 @@ module.exports = (defaultFuncs, api, ctx) => {
30
30
  if (err) return rejectFunc(err);
31
31
  resolveFunc(result);
32
32
  };
33
+ } else {
34
+ const _userCb = callback;
35
+ callback = (err, result) => {
36
+ if (err) { _userCb(err); return rejectFunc(err); }
37
+ _userCb(null, result);
38
+ resolveFunc(result);
39
+ };
33
40
  }
34
41
 
42
+ // Hoist these before the try so they are accessible in the catch block
43
+ let responseHandled = false;
44
+ let timeout = null;
45
+ let onResponse = null;
46
+
35
47
  try {
36
48
  if (!ctx.mqttClient || !ctx.mqttClient.connected) {
37
49
  throw new Error("Not connected to MQTT. Please use listenMqtt first.");
@@ -48,8 +60,7 @@ module.exports = (defaultFuncs, api, ctx) => {
48
60
  const reqID = ++ctx.wsReqNumber;
49
61
  const taskID = ++ctx.wsTaskNumber;
50
62
 
51
- let responseHandled = false;
52
- const onResponse = (topic, message) => {
63
+ onResponse = (topic, message) => {
53
64
  if (topic !== "/ls_resp" || responseHandled) return;
54
65
  let jsonMsg;
55
66
  try {
@@ -63,16 +74,13 @@ module.exports = (defaultFuncs, api, ctx) => {
63
74
  clearTimeout(timeout);
64
75
  ctx.mqttClient.removeListener("message", onResponse);
65
76
  callback(null, { success: true, response: jsonMsg.payload });
66
- resolveFunc({ success: true, response: jsonMsg.payload });
67
77
  };
68
78
 
69
- const timeout = setTimeout(() => {
79
+ timeout = setTimeout(() => {
70
80
  if (!responseHandled) {
71
81
  responseHandled = true;
72
82
  ctx.mqttClient.removeListener("message", onResponse);
73
- const err = new Error("MQTT request timeout");
74
- callback(err);
75
- rejectFunc(err);
83
+ callback(new Error("MQTT request timeout"));
76
84
  }
77
85
  }, 30000);
78
86
 
@@ -102,7 +110,7 @@ module.exports = (defaultFuncs, api, ctx) => {
102
110
  };
103
111
 
104
112
  const request = {
105
- app_id: "2220391788200892",
113
+ app_id: String(ctx.appID || ctx.mqttAppID || "2220391788200892"),
106
114
  payload: JSON.stringify(mqttPayload),
107
115
  request_id: reqID,
108
116
  type: 3
@@ -116,18 +124,18 @@ module.exports = (defaultFuncs, api, ctx) => {
116
124
  responseHandled = true;
117
125
  clearTimeout(timeout);
118
126
  ctx.mqttClient.removeListener("message", onResponse);
119
- callback(err);
120
- rejectFunc(err);
127
+ callback(err instanceof Error ? err : new Error(String(err)));
121
128
  }
122
129
  });
123
130
  } catch (err) {
124
131
  if (!responseHandled) {
125
132
  responseHandled = true;
126
- clearTimeout(timeout);
127
- ctx.mqttClient.removeListener("message", onResponse);
133
+ if (timeout) clearTimeout(timeout);
134
+ if (onResponse && ctx.mqttClient) {
135
+ try { ctx.mqttClient.removeListener("message", onResponse); } catch (_) {}
136
+ }
128
137
  utils.error("changeGroupImage", err);
129
- callback(err);
130
- rejectFunc(err);
138
+ callback(err instanceof Error ? err : new Error(String(err && err.message ? err.message : err)));
131
139
  }
132
140
  }
133
141
 
@@ -17,7 +17,15 @@ module.exports = function (defaultFuncs, api, ctx) {
17
17
  }
18
18
  resolveFunc();
19
19
  };
20
+ } else {
21
+ const _userCb = callback;
22
+ callback = function(err) {
23
+ if (err) { _userCb(err); return rejectFunc(err); }
24
+ _userCb(null);
25
+ resolveFunc();
26
+ };
20
27
  }
28
+
21
29
  const form = {
22
30
  emoji_choice: emoji,
23
31
  thread_or_other_fbid: threadID,
@@ -32,20 +40,18 @@ module.exports = function (defaultFuncs, api, ctx) {
32
40
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
33
41
  .then(function (resData) {
34
42
  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
- };
43
+ throw new Error(
44
+ "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."
45
+ );
39
46
  }
40
47
  if (resData.error) {
41
- throw resData;
48
+ throw new Error(String(resData.error_msg || resData.error || "changeThreadEmoji failed"));
42
49
  }
43
-
44
- return callback();
50
+ return callback(null);
45
51
  })
46
52
  .catch(function (err) {
47
53
  utils.error("changeThreadEmoji", err);
48
- return callback(err);
54
+ return callback(err instanceof Error ? err : new Error(String(err && err.message ? err.message : err)));
49
55
  });
50
56
 
51
57
  return returnPromise;
@@ -72,7 +72,7 @@ module.exports = (defaultFuncs, api, ctx) => {
72
72
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs));
73
73
 
74
74
  if (res.errors) {
75
- throw res;
75
+ throw new Error(JSON.stringify(res.errors));
76
76
  }
77
77
 
78
78
  const threadID = res.data.messenger_group_thread_create.thread.thread_key.thread_fbid;
@@ -54,7 +54,7 @@ module.exports = (defaultFuncs, api, ctx) => {
54
54
  task_id: ++ctx.wsTaskNumber
55
55
  }
56
56
  ],
57
- version_id: "8768858626531631"
57
+ version_id: "34195258046739157"
58
58
  };
59
59
 
60
60
  const form = JSON.stringify({
@@ -64,8 +64,14 @@ module.exports = (defaultFuncs, api, ctx) => {
64
64
  type: 3
65
65
  });
66
66
 
67
- ctx.mqttClient.publish("/ls_req", form, { qos: 1, retain: false });
68
- callback(null, { success: true });
67
+ ctx.mqttClient.publish("/ls_req", form, { qos: 1, retain: false }, (pubErr) => {
68
+ if (pubErr) {
69
+ utils.error("createPoll", pubErr);
70
+ callback(pubErr instanceof Error ? pubErr : new Error(String(pubErr)));
71
+ } else {
72
+ callback(null, { success: true });
73
+ }
74
+ });
69
75
  } catch (err) {
70
76
  utils.error("createPoll", err);
71
77
  callback(err);
@@ -16,27 +16,30 @@ module.exports = (defaultFuncs, api, ctx) => {
16
16
  if (err) return rejectFunc(err);
17
17
  resolveFunc(result);
18
18
  };
19
+ } else {
20
+ const _userCb = callback;
21
+ callback = (err, result) => {
22
+ if (err) { _userCb(err); return rejectFunc(err); }
23
+ _userCb(null, result);
24
+ resolveFunc(result);
25
+ };
19
26
  }
20
27
 
21
28
  try {
22
- const form = {
23
- message_id: messageID
24
- };
25
-
26
29
  const res = await defaultFuncs.post(
27
30
  "https://www.facebook.com/ajax/mercury/delete_messages.php",
28
31
  ctx.jar,
29
- form
32
+ { message_id: messageID }
30
33
  ).then(utils.parseAndCheckLogin(ctx, defaultFuncs));
31
34
 
32
35
  if (res && res.error) {
33
- throw res;
36
+ throw new Error(String(res.error_msg || res.error || "deleteMessage failed"));
34
37
  }
35
38
 
36
- return callback(null, { success: true });
39
+ callback(null, { success: true });
37
40
  } catch (err) {
38
41
  utils.error("deleteMessage", err);
39
- callback(err);
42
+ callback(err instanceof Error ? err : new Error(String(err && err.message ? err.message : err)));
40
43
  }
41
44
 
42
45
  return returnPromise;
@@ -38,7 +38,7 @@ module.exports = (defaultFuncs, api, ctx) => {
38
38
  ).then(utils.parseAndCheckLogin(ctx, defaultFuncs));
39
39
 
40
40
  if (res && res.error) {
41
- throw res;
41
+ throw new Error(res.error_msg || res.errorSummary || String(res.error));
42
42
  }
43
43
 
44
44
  callback(null, { success: true });
@@ -1,27 +1,28 @@
1
1
  "use strict";
2
2
 
3
- /**
4
- * Author @YanMaglinte
5
- * https://github.com/YANDEVA
6
- * * Example:
7
- * api.follow("100090794779367", true);
8
- * jsdocs @ChoruOfficial
9
- */
10
-
11
- /**
12
- * @param {object} defaultFuncs The default functions for making API requests.
13
- * @param {object} api The full API object.
14
- * @param {object} ctx The context object.
15
- * @returns {function(senderID: string, boolean: boolean, callback?: (err: any, data?: any) => void): void} The follow function.
16
- */
17
3
  module.exports = function (defaultFuncs, api, ctx) {
18
- /**
19
- * Follows or unfollows a user on Facebook.
20
- * @param {string} senderID The ID of the user to follow or unfollow.
21
- * @param {boolean} boolean Set to `true` to follow the user, `false` to unfollow.
22
- * @param {(err: any, data?: any) => void} [callback] An optional callback function.
23
- */
24
4
  return function follow(senderID, boolean, callback) {
5
+ let resolveFunc = () => {};
6
+ let rejectFunc = () => {};
7
+ const returnPromise = new Promise((resolve, reject) => {
8
+ resolveFunc = resolve;
9
+ rejectFunc = reject;
10
+ });
11
+
12
+ if (!callback) {
13
+ callback = (err, data) => {
14
+ if (err) return rejectFunc(err);
15
+ resolveFunc(data);
16
+ };
17
+ } else {
18
+ const _userCb = callback;
19
+ callback = (err, data) => {
20
+ if (err) { _userCb(err); return rejectFunc(err); }
21
+ _userCb(null, data);
22
+ resolveFunc(data);
23
+ };
24
+ }
25
+
25
26
  let form;
26
27
  if (boolean) {
27
28
  form = {
@@ -48,7 +49,7 @@ module.exports = function (defaultFuncs, api, ctx) {
48
49
  av: ctx.userID,
49
50
  fb_api_req_friendly_name: "CometUserUnfollowMutation",
50
51
  fb_api_caller_class: "RelayModern",
51
- doc_id: "7033020913412778",
52
+ doc_id: "25472099855769847",
52
53
  variables: JSON.stringify({
53
54
  action_render_location: "WWW_COMET_FRIEND_MENU",
54
55
  input: {
@@ -67,15 +68,10 @@ module.exports = function (defaultFuncs, api, ctx) {
67
68
  }
68
69
 
69
70
  api.httpPost("https://www.facebook.com/api/graphql/", form, (err, data) => {
70
- if (err) {
71
- if (typeof callback === "function") {
72
- callback(err);
73
- }
74
- } else {
75
- if (typeof callback === "function") {
76
- callback(null, data);
77
- }
78
- }
71
+ if (err) return callback(err instanceof Error ? err : new Error(String(err && err.message ? err.message : err)));
72
+ callback(null, data);
79
73
  });
74
+
75
+ return returnPromise;
80
76
  };
81
- };
77
+ };
@@ -38,7 +38,7 @@ module.exports = (defaultFuncs, api, ctx) => {
38
38
  ).then(utils.parseAndCheckLogin(ctx, defaultFuncs));
39
39
 
40
40
  if (res && res.error) {
41
- throw res;
41
+ throw new Error(res.error_msg || res.errorSummary || String(res.error));
42
42
  }
43
43
 
44
44
  callback(null, { success: true, forwardedTo: threadIDs });
@@ -95,7 +95,7 @@ module.exports = function (defaultFuncs, api, ctx) {
95
95
  payload: {
96
96
  epoch_id: parseInt(utils.generateOfflineThreadingID()),
97
97
  tasks: [query],
98
- version_id: '24631415369801570',
98
+ version_id: '8798795233522156',
99
99
  },
100
100
  request_id: ctx.wsReqNumber,
101
101
  type: 3,
@@ -61,11 +61,11 @@ module.exports = (defaultFuncs, api, ctx) => {
61
61
  ).then(utils.parseAndCheckLogin(ctx, defaultFuncs));
62
62
 
63
63
  if (!res) {
64
- throw { error: "getFriendsList returned empty object." };
64
+ throw new Error("getFriendsList returned empty object.");
65
65
  }
66
66
 
67
67
  if (res.error) {
68
- throw res;
68
+ throw new Error(res.error_msg || res.errorSummary || String(res.error));
69
69
  }
70
70
 
71
71
  callback(null, formatData(res.payload));
@@ -225,7 +225,7 @@ module.exports = function (defaultFuncs, api, ctx) {
225
225
  .then(utils.parseAndCheckLogin(ctx, defaultFuncs));
226
226
 
227
227
  if (resData.error) {
228
- throw resData;
228
+ throw new Error(resData.error_msg || resData.errorSummary || String(resData.error));
229
229
  }
230
230
 
231
231
  const threadInfos = {};
@@ -44,7 +44,7 @@ module.exports = (defaultFuncs, api, ctx) => {
44
44
  ).then(utils.parseAndCheckLogin(ctx, defaultFuncs));
45
45
 
46
46
  if (res && res.error) {
47
- throw res;
47
+ throw new Error(res.error_msg || res.errorSummary || String(res.error));
48
48
  }
49
49
 
50
50
  return callback(null, res?.payload || res);
@@ -36,7 +36,7 @@ module.exports = (defaultFuncs, api, ctx) => {
36
36
  ).then(utils.parseAndCheckLogin(ctx, defaultFuncs));
37
37
 
38
38
  if (res && res.error) {
39
- throw res;
39
+ throw new Error(res.error_msg || res.errorSummary || String(res.error));
40
40
  }
41
41
 
42
42
  return callback(null, { success: true, accepted: accept });