@dongdev/fca-unofficial 3.0.7 → 3.0.8
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.
- package/CHANGELOG.md +3 -0
- package/package.json +1 -1
- package/src/api/threads/getThreadList.js +49 -4
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -226,14 +226,59 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
|
226
226
|
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
|
227
227
|
.then(parseAndCheckLogin(ctx, defaultFuncs))
|
|
228
228
|
.then(resData => {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
229
|
+
// Validate resData is an array and has elements
|
|
230
|
+
if (!resData || !Array.isArray(resData) || resData.length === 0) {
|
|
231
|
+
throw {
|
|
232
|
+
error: "getThreadList: Invalid response data - resData is not a valid array",
|
|
233
|
+
res: resData
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
// Validate last element exists and has required properties
|
|
238
|
+
const lastElement = resData[resData.length - 1];
|
|
239
|
+
if (!lastElement || typeof lastElement !== "object") {
|
|
240
|
+
throw {
|
|
241
|
+
error: "getThreadList: Invalid response data - last element is missing or invalid",
|
|
242
|
+
res: resData
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
if (lastElement.error_results > 0) {
|
|
247
|
+
// Check if first element and o0 exist before accessing errors
|
|
248
|
+
if (resData[0] && resData[0].o0 && resData[0].o0.errors) {
|
|
249
|
+
throw resData[0].o0.errors;
|
|
250
|
+
} else {
|
|
251
|
+
throw {
|
|
252
|
+
error: "getThreadList: Error results > 0 but error details not available",
|
|
253
|
+
res: resData
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
if (lastElement.successful_results === 0) {
|
|
232
259
|
throw {
|
|
233
260
|
error: "getThreadList: there was no successful_results",
|
|
234
261
|
res: resData
|
|
235
262
|
};
|
|
236
|
-
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// Validate first element and nested data structure
|
|
266
|
+
if (!resData[0] || !resData[0].o0 || !resData[0].o0.data ||
|
|
267
|
+
!resData[0].o0.data.viewer || !resData[0].o0.data.viewer.message_threads ||
|
|
268
|
+
!Array.isArray(resData[0].o0.data.viewer.message_threads.nodes)) {
|
|
269
|
+
throw {
|
|
270
|
+
error: "getThreadList: Invalid response data structure - missing required fields",
|
|
271
|
+
res: resData
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (timestamp) {
|
|
276
|
+
const nodes = resData[0].o0.data.viewer.message_threads.nodes;
|
|
277
|
+
if (Array.isArray(nodes) && nodes.length > 0) {
|
|
278
|
+
nodes.shift();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
237
282
|
callback(
|
|
238
283
|
null,
|
|
239
284
|
formatThreadList(resData[0].o0.data.viewer.message_threads.nodes)
|