rapido-fca 0.0.6 → 0.0.10

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 (55) hide show
  1. package/index.js +24 -17
  2. package/package.json +1 -1
  3. package/src/addExternalModule.js +23 -19
  4. package/src/addUserToGroup.js +97 -99
  5. package/src/changeAdminStatus.js +62 -86
  6. package/src/changeArchivedStatus.js +49 -49
  7. package/src/changeAvatar.js +108 -118
  8. package/src/changeBio.js +64 -63
  9. package/src/changeBlockedStatus.js +38 -40
  10. package/src/changeGroupImage.js +126 -129
  11. package/src/changeNickname.js +49 -49
  12. package/src/changeThreadColor.js +53 -53
  13. package/src/changeThreadEmoji.js +45 -45
  14. package/src/createNewGroup.js +72 -74
  15. package/src/createPoll.js +59 -59
  16. package/src/deleteMessage.js +50 -50
  17. package/src/deleteThread.js +50 -50
  18. package/src/editMessage.js +49 -51
  19. package/src/forwardAttachment.js +54 -54
  20. package/src/getCurrentUserID.js +3 -3
  21. package/src/getEmojiUrl.js +17 -17
  22. package/src/getFriendsList.js +67 -67
  23. package/src/getMessage.js +767 -806
  24. package/src/getThreadHistory.js +642 -656
  25. package/src/getThreadInfo.js +1 -1
  26. package/src/getThreadList.js +227 -199
  27. package/src/getThreadPictures.js +71 -51
  28. package/src/getUserID.js +58 -53
  29. package/src/getUserInfo.js +60 -52
  30. package/src/handleFriendRequest.js +65 -41
  31. package/src/handleMessageRequest.js +60 -42
  32. package/src/httpGet.js +57 -49
  33. package/src/httpPost.js +57 -48
  34. package/src/httpPostFormData.js +63 -0
  35. package/src/listenMqtt.js +827 -827
  36. package/src/logout.js +61 -61
  37. package/src/markAsDelivered.js +53 -42
  38. package/src/markAsRead.js +69 -59
  39. package/src/markAsReadAll.js +42 -32
  40. package/src/markAsSeen.js +54 -43
  41. package/src/muteThread.js +47 -40
  42. package/src/refreshFb_dtsg.js +69 -77
  43. package/src/removeUserFromGroup.js +67 -67
  44. package/src/resolvePhotoUrl.js +34 -34
  45. package/src/searchForThread.js +43 -43
  46. package/src/sendMessage.js +228 -80
  47. package/src/sendTypingIndicator.js +88 -86
  48. package/src/setEmojiReaction.js +59 -0
  49. package/src/setPostReaction.js +87 -90
  50. package/src/setTitle.js +72 -76
  51. package/src/threadColors.js +121 -121
  52. package/src/unfriend.js +43 -43
  53. package/src/unsendMessage.js +38 -34
  54. package/src/uploadAttachment.js +81 -79
  55. package/src/videoAttachment.js +76 -0
@@ -0,0 +1,76 @@
1
+
2
+ const utils = require("../utils");
3
+ const log = require("npmlog");
4
+
5
+ module.exports = function(defaultFuncs, api, ctx) {
6
+ return function sendVideoAttachment(videoStream, threadID, callback) {
7
+ const messageAndOTID = utils.generateOfflineThreadingID();
8
+
9
+ const form = {
10
+ client: "mercury",
11
+ upload_1024: videoStream,
12
+ voice_clip: "false",
13
+ attempt: "1"
14
+ };
15
+
16
+ defaultFuncs
17
+ .postFormData("https://upload.facebook.com/ajax/mercury/upload.php", ctx.jar, form, {})
18
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
19
+ .then(function(resData) {
20
+ if (resData.error) {
21
+ throw resData;
22
+ }
23
+
24
+ if (!resData.payload) {
25
+ throw { error: "Upload failed" };
26
+ }
27
+
28
+ const messageForm = {
29
+ client: "mercury",
30
+ action_type: "ma-type:user-generated-message",
31
+ author: "fbid:" + (ctx.i_userID || ctx.userID),
32
+ timestamp: Date.now(),
33
+ timestamp_absolute: "Today",
34
+ timestamp_relative: utils.generateTimestampRelative(),
35
+ timestamp_time_passed: "0",
36
+ is_unread: false,
37
+ is_forward: false,
38
+ is_filtered_content: false,
39
+ is_spoof_warning: false,
40
+ source: "source:chat:web",
41
+ "source_tags[0]": "source:chat",
42
+ body: "",
43
+ html_body: false,
44
+ ui_push_phase: "V3",
45
+ status: "0",
46
+ offline_threading_id: messageAndOTID,
47
+ message_id: messageAndOTID,
48
+ threading_id: utils.generateThreadingID(ctx.clientID),
49
+ manual_retry_cnt: "0",
50
+ thread_fbid: threadID,
51
+ video_ids: [resData.payload.metadata[0].video_id]
52
+ };
53
+
54
+ defaultFuncs
55
+ .post("https://www.facebook.com/messaging/send/", ctx.jar, messageForm)
56
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
57
+ .then(function(resData) {
58
+ if (!resData) {
59
+ throw { error: "Send message failed." };
60
+ }
61
+ if (resData.error) {
62
+ throw resData;
63
+ }
64
+ callback(null, resData.payload);
65
+ })
66
+ .catch(function(err) {
67
+ log.error("sendVideoAttachment", err);
68
+ callback(err);
69
+ });
70
+ })
71
+ .catch(function(err) {
72
+ log.error("uploadVideoAttachment", err);
73
+ callback(err);
74
+ });
75
+ };
76
+ };