stfca 1.0.2 → 1.0.4

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 (142) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +45 -2
  3. package/checkUpdate.js +109 -0
  4. package/index.js +460 -1
  5. package/package.json +22 -46
  6. package/src/OldMessage.js +234 -0
  7. package/src/{api/action/addExternalModule.js → addExternalModule.js} +25 -25
  8. package/src/addUserToGroup.js +115 -0
  9. package/src/changeAdminStatus.js +103 -0
  10. package/src/changeArchivedStatus.js +55 -0
  11. package/src/{api/action/changeAvatar.js → changeAvatar.js} +136 -137
  12. package/src/changeAvatarV2.js +86 -0
  13. package/src/changeAvt.js +85 -0
  14. package/src/{api/action/changeBio.js → changeBio.js} +76 -75
  15. package/src/{api/messaging/changeBlockedStatus.js → changeBlockedStatus.js} +49 -48
  16. package/src/changeBlockedStatusMqtt.js +80 -0
  17. package/src/changeCover.js +72 -0
  18. package/src/changeGroupImage.js +135 -0
  19. package/src/changeName.js +79 -0
  20. package/src/changeNickname.js +59 -0
  21. package/src/changeThreadColor.js +65 -0
  22. package/src/changeThreadEmoji.js +55 -0
  23. package/src/changeUsername.js +59 -0
  24. package/src/createCommentPost.js +230 -0
  25. package/src/{api/messaging/createNewGroup.js → createNewGroup.js} +88 -88
  26. package/src/createPoll.js +71 -0
  27. package/src/createPost.js +276 -0
  28. package/src/{api/messaging/deleteMessage.js → deleteMessage.js} +56 -56
  29. package/src/{api/messaging/deleteThread.js → deleteThread.js} +56 -56
  30. package/src/editMessage.js +68 -0
  31. package/src/editMessageOld.js +67 -0
  32. package/src/follow.js +74 -0
  33. package/src/forwardAttachment.js +60 -0
  34. package/src/getAccess.js +112 -0
  35. package/src/getAvatarUser.js +78 -0
  36. package/src/{api/action/getCurrentUserID.js → getCurrentUserID.js} +7 -7
  37. package/src/{api/messaging/getEmojiUrl.js → getEmojiUrl.js} +2 -2
  38. package/src/{api/messaging/getFriendsList.js → getFriendsList.js} +83 -82
  39. package/src/{api/messaging/getMessage.js → getMessage.js} +847 -829
  40. package/src/getRegion.js +7 -0
  41. package/src/{api/threads/getThreadHistory.js → getThreadHistory.js} +680 -664
  42. package/src/getThreadHistoryDeprecated.js +71 -0
  43. package/src/getThreadInfo.js +232 -0
  44. package/src/getThreadInfoDeprecated.js +56 -0
  45. package/src/getThreadList.js +213 -0
  46. package/src/getThreadListDeprecated.js +46 -0
  47. package/src/getThreadPictures.js +59 -0
  48. package/src/getUID.js +119 -0
  49. package/src/{api/users/getUserID.js → getUserID.js} +61 -65
  50. package/src/getUserInfo.js +66 -0
  51. package/src/handleFriendRequest.js +46 -0
  52. package/src/handleMessageRequest.js +47 -0
  53. package/src/httpGet.js +49 -0
  54. package/src/httpPost.js +48 -0
  55. package/src/listenMqtt.js +864 -0
  56. package/src/logout.js +75 -0
  57. package/src/markAsDelivered.js +47 -0
  58. package/src/markAsRead.js +70 -0
  59. package/src/markAsReadAll.js +40 -0
  60. package/src/markAsSeen.js +48 -0
  61. package/src/muteThread.js +45 -0
  62. package/src/refreshFb_dtsg.js +89 -0
  63. package/src/removeUserFromGroup.js +79 -0
  64. package/src/{api/messaging/resolvePhotoUrl.js → resolvePhotoUrl.js} +45 -43
  65. package/src/{api/messaging/searchForThread.js → searchForThread.js} +53 -52
  66. package/src/searchStickers.js +53 -0
  67. package/src/sendMessage.js +234 -0
  68. package/src/{api/messaging/sendMessageMqtt.js → sendMessageMqtt.js} +322 -323
  69. package/src/sendTypingIndicator.js +101 -0
  70. package/src/sendTypingIndicatorV2.js +28 -0
  71. package/src/setMessageReaction.js +122 -0
  72. package/src/setMessageReactionMqtt.js +62 -0
  73. package/src/{api/action/setPostReaction.js → setPostReaction.js} +112 -106
  74. package/src/setStoryReaction.js +64 -0
  75. package/src/setTitle.js +90 -0
  76. package/src/shareContact.js +110 -0
  77. package/src/shareLink.js +59 -0
  78. package/src/stopListenMqtt.js +23 -0
  79. package/src/{api/messaging/threadColors.js → threadColors.js} +131 -128
  80. package/src/{api/action/unfriend.js → unfriend.js} +52 -54
  81. package/src/unsendMessage.js +45 -0
  82. package/src/{api/messaging/uploadAttachment.js → uploadAttachment.js} +93 -95
  83. package/utils.js +2876 -0
  84. package/LICENSE-MIT +0 -4
  85. package/index.d.ts +0 -615
  86. package/module/config.js +0 -33
  87. package/module/login.js +0 -48
  88. package/module/loginHelper.js +0 -722
  89. package/module/options.js +0 -44
  90. package/src/api/action/handleFriendRequest.js +0 -57
  91. package/src/api/action/logout.js +0 -76
  92. package/src/api/action/refreshFb_dtsg.js +0 -71
  93. package/src/api/http/httpGet.js +0 -46
  94. package/src/api/http/httpPost.js +0 -52
  95. package/src/api/http/postFormData.js +0 -47
  96. package/src/api/messaging/addUserToGroup.js +0 -68
  97. package/src/api/messaging/changeAdminStatus.js +0 -122
  98. package/src/api/messaging/changeArchivedStatus.js +0 -55
  99. package/src/api/messaging/changeGroupImage.js +0 -90
  100. package/src/api/messaging/changeNickname.js +0 -70
  101. package/src/api/messaging/changeThreadColor.js +0 -79
  102. package/src/api/messaging/changeThreadEmoji.js +0 -106
  103. package/src/api/messaging/createPoll.js +0 -43
  104. package/src/api/messaging/editMessage.js +0 -68
  105. package/src/api/messaging/forwardAttachment.js +0 -51
  106. package/src/api/messaging/handleMessageRequest.js +0 -65
  107. package/src/api/messaging/markAsDelivered.js +0 -57
  108. package/src/api/messaging/markAsRead.js +0 -88
  109. package/src/api/messaging/markAsReadAll.js +0 -49
  110. package/src/api/messaging/markAsSeen.js +0 -61
  111. package/src/api/messaging/muteThread.js +0 -50
  112. package/src/api/messaging/removeUserFromGroup.js +0 -105
  113. package/src/api/messaging/sendMessage.js +0 -379
  114. package/src/api/messaging/sendTypingIndicator.js +0 -67
  115. package/src/api/messaging/setMessageReaction.js +0 -75
  116. package/src/api/messaging/setTitle.js +0 -119
  117. package/src/api/messaging/shareContact.js +0 -49
  118. package/src/api/messaging/unsendMessage.js +0 -81
  119. package/src/api/socket/core/connectMqtt.js +0 -179
  120. package/src/api/socket/core/getSeqID.js +0 -25
  121. package/src/api/socket/core/getTaskResponseData.js +0 -22
  122. package/src/api/socket/core/markDelivery.js +0 -12
  123. package/src/api/socket/core/parseDelta.js +0 -351
  124. package/src/api/socket/detail/buildStream.js +0 -208
  125. package/src/api/socket/detail/constants.js +0 -24
  126. package/src/api/socket/listenMqtt.js +0 -133
  127. package/src/api/threads/getThreadInfo.js +0 -358
  128. package/src/api/threads/getThreadList.js +0 -248
  129. package/src/api/threads/getThreadPictures.js +0 -78
  130. package/src/api/users/getUserInfo.js +0 -319
  131. package/src/api/users/getUserInfoV2.js +0 -133
  132. package/src/core/sendReqMqtt.js +0 -63
  133. package/src/database/models/index.js +0 -49
  134. package/src/database/models/thread.js +0 -31
  135. package/src/database/models/user.js +0 -32
  136. package/src/database/threadData.js +0 -98
  137. package/src/database/userData.js +0 -89
  138. package/src/utils/client.js +0 -214
  139. package/src/utils/constants.js +0 -23
  140. package/src/utils/format.js +0 -1111
  141. package/src/utils/headers.js +0 -41
  142. package/src/utils/request.js +0 -215
@@ -1,137 +1,136 @@
1
- "use strict";
2
-
3
- const log = require("npmlog");
4
- const { isReadableStream } = require("../../utils/constants");
5
- const { parseAndCheckLogin } = require("../../utils/client");
6
- const { formatID, getType } = require("../../utils/format");
7
- module.exports = function(defaultFuncs, api, ctx) {
8
- function handleUpload(image, callback) {
9
- const uploads = [];
10
-
11
- const form = {
12
- profile_id: ctx.userID,
13
- photo_source: 57,
14
- av: ctx.userID,
15
- file: image
16
- };
17
-
18
- uploads.push(
19
- defaultFuncs
20
- .postFormData(
21
- "https://www.facebook.com/profile/picture/upload/",
22
- ctx.jar,
23
- form,
24
- {}
25
- )
26
- .then(parseAndCheckLogin(ctx, defaultFuncs))
27
- .then(function(resData) {
28
- if (resData.error) {
29
- throw resData;
30
- }
31
- return resData;
32
- })
33
- );
34
-
35
- // resolve all promises
36
- Promise.all(uploads)
37
- .then(function(resData) {
38
- callback(null, resData);
39
- })
40
- .catch(function(err) {
41
- log.error("handleUpload", err);
42
- return callback(err);
43
- });
44
- }
45
-
46
- return function changeAvatar(
47
- image,
48
- caption = "",
49
- timestamp = null,
50
- callback
51
- ) {
52
- let resolveFunc = function() {};
53
- let rejectFunc = function() {};
54
- const returnPromise = new Promise(function(resolve, reject) {
55
- resolveFunc = resolve;
56
- rejectFunc = reject;
57
- });
58
-
59
- if (!timestamp && getType(caption) === "Number") {
60
- timestamp = caption;
61
- caption = "";
62
- }
63
-
64
- if (
65
- !timestamp &&
66
- !callback &&
67
- (getType(caption) == "Function" ||
68
- getType(caption) == "AsyncFunction")
69
- ) {
70
- callback = caption;
71
- caption = "";
72
- timestamp = null;
73
- }
74
-
75
- if (!callback)
76
- callback = function(err, data) {
77
- if (err) {
78
- return rejectFunc(err);
79
- }
80
- resolveFunc(data);
81
- };
82
-
83
- if (!isReadableStream(image))
84
- return callback("Image is not a readable stream");
85
-
86
- handleUpload(image, function(err, payload) {
87
- if (err) {
88
- return callback(err);
89
- }
90
-
91
- const form = {
92
- av: ctx.i_userID || ctx.userID,
93
- fb_api_req_friendly_name: "ProfileCometProfilePictureSetMutation",
94
- fb_api_caller_class: "RelayModern",
95
- doc_id: "5066134240065849",
96
- variables: JSON.stringify({
97
- input: {
98
- caption,
99
- existing_photo_id: payload[0].payload.fbid,
100
- expiration_time: timestamp,
101
- profile_id: ctx.i_userID || ctx.userID,
102
- profile_pic_method: "EXISTING",
103
- profile_pic_source: "TIMELINE",
104
- scaled_crop_rect: {
105
- height: 1,
106
- width: 1,
107
- x: 0,
108
- y: 0
109
- },
110
- skip_cropping: true,
111
- actor_id: ctx.i_userID || ctx.userID,
112
- client_mutation_id: Math.round(Math.random() * 19).toString()
113
- },
114
- isPage: false,
115
- isProfile: true,
116
- scale: 3
117
- })
118
- };
119
-
120
- defaultFuncs
121
- .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
122
- .then(parseAndCheckLogin(ctx, defaultFuncs))
123
- .then(function(resData) {
124
- if (resData.errors) {
125
- throw resData;
126
- }
127
- return callback(null, resData[0].data.profile_picture_set);
128
- })
129
- .catch(function(err) {
130
- log.error("changeAvatar", err);
131
- return callback(err);
132
- });
133
- });
134
-
135
- return returnPromise;
136
- };
137
- };
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+ // @NethWs3Dev
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ function handleUpload(image, callback) {
8
+ const uploads = [];
9
+
10
+ const form = {
11
+ profile_id: ctx.userID,
12
+ photo_source: 57,
13
+ av: ctx.userID,
14
+ file: image,
15
+ };
16
+
17
+ uploads.push(
18
+ defaultFuncs
19
+ .postFormData(
20
+ "https://www.facebook.com/profile/picture/upload/",
21
+ ctx.jar,
22
+ form,
23
+ {},
24
+ )
25
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
26
+ .then(function (resData) {
27
+ if (resData.error) {
28
+ throw resData;
29
+ }
30
+ return resData;
31
+ }),
32
+ );
33
+
34
+ // resolve all promises
35
+ Promise.all(uploads)
36
+ .then(function (resData) {
37
+ callback(null, resData);
38
+ })
39
+ .catch(function (err) {
40
+ console.error("handleUpload", err);
41
+ return callback(err);
42
+ });
43
+ }
44
+
45
+ return function changeAvatar(
46
+ image,
47
+ caption = "",
48
+ timestamp = null,
49
+ callback,
50
+ ) {
51
+ let resolveFunc = function () {};
52
+ let rejectFunc = function () {};
53
+ const returnPromise = new Promise(function (resolve, reject) {
54
+ resolveFunc = resolve;
55
+ rejectFunc = reject;
56
+ });
57
+
58
+ if (!timestamp && utils.getType(caption) === "Number") {
59
+ timestamp = caption;
60
+ caption = "";
61
+ }
62
+
63
+ if (
64
+ !timestamp &&
65
+ !callback &&
66
+ (utils.getType(caption) == "Function" ||
67
+ utils.getType(caption) == "AsyncFunction")
68
+ ) {
69
+ callback = caption;
70
+ caption = "";
71
+ timestamp = null;
72
+ }
73
+
74
+ if (!callback)
75
+ callback = function (err, data) {
76
+ if (err) {
77
+ return rejectFunc(err);
78
+ }
79
+ resolveFunc(data);
80
+ };
81
+
82
+ if (!utils.isReadableStream(image))
83
+ return callback("Image is not a readable stream");
84
+
85
+ handleUpload(image, function (err, payload) {
86
+ if (err) {
87
+ return callback(err);
88
+ }
89
+
90
+ const form = {
91
+ av: ctx.userID,
92
+ fb_api_req_friendly_name: "ProfileCometProfilePictureSetMutation",
93
+ fb_api_caller_class: "RelayModern",
94
+ doc_id: "5066134240065849",
95
+ variables: JSON.stringify({
96
+ input: {
97
+ caption,
98
+ existing_photo_id: payload[0].payload.fbid,
99
+ expiration_time: timestamp,
100
+ profile_id: ctx.userID,
101
+ profile_pic_method: "EXISTING",
102
+ profile_pic_source: "TIMELINE",
103
+ scaled_crop_rect: {
104
+ height: 1,
105
+ width: 1,
106
+ x: 0,
107
+ y: 0,
108
+ },
109
+ skip_cropping: true,
110
+ actor_id: ctx.userID,
111
+ client_mutation_id: Math.round(Math.random() * 19).toString(),
112
+ },
113
+ isPage: false,
114
+ isProfile: true,
115
+ scale: 3,
116
+ }),
117
+ };
118
+
119
+ defaultFuncs
120
+ .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
121
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
122
+ .then(function (resData) {
123
+ if (resData.errors) {
124
+ throw resData;
125
+ }
126
+ return callback(null, resData[0].data.profile_picture_set);
127
+ })
128
+ .catch(function (err) {
129
+ console.error("changeAvatar", err);
130
+ return callback(err);
131
+ });
132
+ });
133
+
134
+ return returnPromise;
135
+ };
136
+ };
@@ -0,0 +1,86 @@
1
+
2
+ "use strict";
3
+
4
+ var utils = require("../utils");
5
+ // @NethWs3Dev
6
+ /**
7
+ * It posts an image to a Facebook profile
8
+ * @param Api - The API object
9
+ * @param BotID - The ID of the bot you want to post the image to.
10
+ * @param form - The form data that you want to send.
11
+ * @returns The JSON.parse(Data.split("for (;;);")[1]); is returning the following:
12
+ * {"__ar":1,"payload":null,"jsmods":{"require":[["ImageUploader","uploadPhoto",[{"__m":"__elem_0"},{"__m":"__elem_1"},{"__m":"__elem_2"},{"__m":"__
13
+ */
14
+ async function postImage(Api, BotID, form) {
15
+ var Data = await Api.httpPostFormData(`https://www.facebook.com/profile/picture/upload/?profile_id=${BotID}&photo_source=57&av=${BotID}`, form);
16
+ return JSON.parse(Data.split("for (;;);")[1]);
17
+ }
18
+
19
+ module.exports = function(defaultFuncs, api, ctx) {
20
+ /* Changing the profile picture of the bot. */
21
+ return function changeAvt(link, caption, callback) {
22
+ var resolveFunc = function() {};
23
+ var rejectFunc = function() {};
24
+ var returnPromise = new Promise(function(resolve, reject) {
25
+ resolveFunc = resolve;
26
+ rejectFunc = reject;
27
+ });
28
+
29
+ if (!callback) {
30
+ callback = function(err, data) {
31
+ if (err) return rejectFunc(err);
32
+ resolveFunc(data);
33
+ };
34
+ }
35
+ try {
36
+ var Fetch = require('axios')
37
+ Fetch.get(link, { responseType: "stream" }).then(data => {
38
+ postImage(api, ctx.userID, { file: data.data }).then(data => {
39
+ if (data.error) throw new Error({ error: data.error, des: data.error.errorDescription });
40
+ var form = {
41
+ av: ctx.userID,
42
+ fb_api_req_friendly_name: "ProfileCometProfilePictureSetMutation",
43
+ fb_api_caller_class: "RelayModern",
44
+ doc_id: "5066134240065849",
45
+ variables: JSON.stringify({
46
+ input: {
47
+ caption: (caption || ""),
48
+ existing_photo_id: data.payload.fbid,
49
+ expiration_time: null,
50
+ profile_id: ctx.userID,
51
+ profile_pic_method: "EXISTING",
52
+ profile_pic_source: "TIMELINE",
53
+ scaled_crop_rect: {
54
+ height: 1,
55
+ width: 1,
56
+ x: 0,
57
+ y: 0
58
+ },
59
+ skip_cropping: true,
60
+ actor_id: ctx.userID,
61
+ client_mutation_id: Math.round(Math.random() * 19).toString()
62
+ },
63
+ isPage: false,
64
+ isProfile: true,
65
+ scale: 3,
66
+ })
67
+ };
68
+ defaultFuncs
69
+ .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
70
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
71
+ .then(function(resData) {
72
+ if (resData.error) throw resData;
73
+ else return callback(null,true)
74
+ })
75
+ .catch(function(err) {
76
+ return callback(err);
77
+ });
78
+ })
79
+ })
80
+ }
81
+ catch (e) {
82
+ throw e;
83
+ }
84
+ return returnPromise;
85
+ };
86
+ };
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+
3
+ var utils = require("../utils");
4
+ var log = require("npmlog");
5
+ /**
6
+ * It posts an image to a Facebook profile
7
+ * @param Api - The API object
8
+ * @param BotID - The ID of the bot you want to post the image to.
9
+ * @param form - The form data that you want to send.
10
+ * @returns The JSON.parse(Data.split("for (;;);")[1]); is returning the following:
11
+ * {"__ar":1,"payload":null,"jsmods":{"require":[["ImageUploader","uploadPhoto",[{"__m":"__elem_0"},{"__m":"__elem_1"},{"__m":"__elem_2"},{"__m":"__
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]);
16
+ }
17
+
18
+ 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
+ });
27
+
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
+ };
@@ -1,75 +1,76 @@
1
- "use strict";
2
-
3
- const log = require("npmlog");
4
- const { parseAndCheckLogin } = require("../../utils/client");
5
- const { getType } = require("../../utils/format");
6
- module.exports = function(defaultFuncs, api, ctx) {
7
- return function changeBio(bio, publish, callback) {
8
- let resolveFunc = function() {};
9
- let rejectFunc = function() {};
10
- const returnPromise = new Promise(function(resolve, reject) {
11
- resolveFunc = resolve;
12
- rejectFunc = reject;
13
- });
14
-
15
- if (!callback) {
16
- if (
17
- getType(publish) == "Function" ||
18
- getType(publish) == "AsyncFunction"
19
- ) {
20
- callback = publish;
21
- } else {
22
- callback = function(err) {
23
- if (err) {
24
- return rejectFunc(err);
25
- }
26
- resolveFunc();
27
- };
28
- }
29
- }
30
-
31
- if (getType(publish) != "Boolean") {
32
- publish = false;
33
- }
34
-
35
- if (getType(bio) != "String") {
36
- bio = "";
37
- publish = false;
38
- }
39
-
40
- const form = {
41
- fb_api_caller_class: "RelayModern",
42
- fb_api_req_friendly_name: "ProfileCometSetBioMutation",
43
- doc_id: "2725043627607610",
44
- variables: JSON.stringify({
45
- input: {
46
- bio: bio,
47
- publish_bio_feed_story: publish,
48
- actor_id: ctx.i_userID || ctx.userID,
49
- client_mutation_id: Math.round(Math.random() * 1024).toString()
50
- },
51
- hasProfileTileViewID: false,
52
- profileTileViewID: null,
53
- scale: 1
54
- }),
55
- av: ctx.i_userID || ctx.userID
56
- };
57
-
58
- defaultFuncs
59
- .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
60
- .then(parseAndCheckLogin(ctx, defaultFuncs))
61
- .then(function(resData) {
62
- if (resData.errors) {
63
- throw resData;
64
- }
65
-
66
- return callback();
67
- })
68
- .catch(function(err) {
69
- log.error("changeBio", err);
70
- return callback(err);
71
- });
72
-
73
- return returnPromise;
74
- };
75
- };
1
+ "use strict";
2
+
3
+ const utils = require("../utils");
4
+ // @NethWs3Dev
5
+
6
+ module.exports = function (defaultFuncs, api, ctx) {
7
+ return function changeBio(bio, publish, callback) {
8
+ let resolveFunc = function () {};
9
+ let rejectFunc = function () {};
10
+ const returnPromise = new Promise(function (resolve, reject) {
11
+ resolveFunc = resolve;
12
+ rejectFunc = reject;
13
+ });
14
+
15
+ if (!callback) {
16
+ if (
17
+ utils.getType(publish) == "Function" ||
18
+ utils.getType(publish) == "AsyncFunction"
19
+ ) {
20
+ callback = publish;
21
+ } else {
22
+ callback = function (err) {
23
+ if (err) {
24
+ return rejectFunc(err);
25
+ }
26
+ resolveFunc();
27
+ };
28
+ }
29
+ }
30
+
31
+ if (utils.getType(publish) != "Boolean") {
32
+ publish = false;
33
+ }
34
+
35
+ if (utils.getType(bio) != "String") {
36
+ bio = "";
37
+ publish = false;
38
+ }
39
+
40
+ const form = {
41
+ fb_api_caller_class: "RelayModern",
42
+ fb_api_req_friendly_name: "ProfileCometSetBioMutation",
43
+ // This doc_is is valid as of May 23, 2020
44
+ doc_id: "2725043627607610",
45
+ variables: JSON.stringify({
46
+ input: {
47
+ bio: bio,
48
+ publish_bio_feed_story: publish,
49
+ actor_id: ctx.userID,
50
+ client_mutation_id: Math.round(Math.random() * 1024).toString(),
51
+ },
52
+ hasProfileTileViewID: false,
53
+ profileTileViewID: null,
54
+ scale: 1,
55
+ }),
56
+ av: ctx.userID,
57
+ };
58
+
59
+ defaultFuncs
60
+ .post("https://www.facebook.com/api/graphql/", ctx.jar, form)
61
+ .then(utils.parseAndCheckLogin(ctx, defaultFuncs))
62
+ .then(function (resData) {
63
+ if (resData.errors) {
64
+ throw resData;
65
+ }
66
+
67
+ return callback();
68
+ })
69
+ .catch(function (err) {
70
+ console.error("changeBio", err);
71
+ return callback(err);
72
+ });
73
+
74
+ return returnPromise;
75
+ };
76
+ };