alicezetion 1.3.6 → 1.3.8
Sign up to get free protection for your applications and to get access to all the features.
- package/.cache/replit/__replit_disk_meta.json +1 -1
- package/.cache/replit/nix/env.json +1 -1
- package/Extra/Database/index.js +469 -0
- package/Extra/ExtraAddons.js +82 -0
- package/Extra/ExtraFindUID.js +62 -0
- package/Extra/ExtraGetThread.js +340 -0
- package/Extra/ExtraScreenShot.js +430 -0
- package/Extra/ExtraUptimeRobot.js +38 -0
- package/Extra/Html/Classic/script.js +119 -0
- package/Extra/Html/Classic/style.css +8 -0
- package/Extra/Security/AES_256_GCM/index.js +0 -0
- package/Extra/Security/Base/Step_1.js +6 -0
- package/Extra/Security/Base/Step_2.js +22 -0
- package/Extra/Security/Base/Step_3.js +22 -0
- package/Extra/Security/Base/index.js +173 -0
- package/Extra/Security/Index.js +5 -0
- package/Extra/Security/Step_1.js +6 -0
- package/Extra/Security/Step_2.js +22 -0
- package/Extra/Security/Step_3.js +22 -0
- package/Extra/Src/Change_Environment.js +24 -0
- package/Extra/Src/Check_Update.js +67 -0
- package/Extra/Src/History.js +115 -0
- package/Extra/Src/Instant_Update.js +65 -0
- package/Extra/Src/Last-Run.js +65 -0
- package/Extra/Src/Premium.js +81 -0
- package/Extra/Src/Release_Memory.js +41 -0
- package/Extra/Src/Websocket.js +213 -0
- package/Extra/Src/image/checkmate.jpg +0 -0
- package/Extra/Src/uuid.js +137 -0
- package/Func/AcceptAgreement.js +31 -0
- package/Func/ClearCache.js +64 -0
- package/Func/ReportV1.js +54 -0
- package/Language/index.json +217 -0
- package/Main.js +1211 -0
- package/broadcast.js +40 -0
- package/index.js +367 -522
- package/leiamnash/Dev_Horizon_Data.js +125 -0
- package/leiamnash/Premium.js +25 -0
- package/leiamnash/Screenshot.js +83 -0
- package/leiamnash/addExternalModule.js +7 -10
- package/leiamnash/addUserToGroup.js +17 -51
- package/leiamnash/changeAdminStatus.js +0 -0
- package/leiamnash/changeArchivedStatus.js +12 -26
- package/leiamnash/changeAvt.js +85 -0
- package/leiamnash/changeBio.js +6 -18
- package/leiamnash/changeBlockedStatus.js +3 -14
- package/leiamnash/changeGroupImage.js +16 -39
- package/leiamnash/changeNickname.js +11 -25
- package/leiamnash/changeThreadColor.js +10 -19
- package/leiamnash/changeThreadEmoji.js +10 -23
- package/leiamnash/chat.js +111 -196
- package/leiamnash/createNewGroup.js +12 -28
- package/leiamnash/createPoll.js +13 -24
- package/leiamnash/deleteMessage.js +12 -23
- package/leiamnash/deleteThread.js +11 -24
- package/leiamnash/forwardAttachment.js +13 -25
- package/leiamnash/getAccessToken.js +28 -0
- package/leiamnash/getCurrentUserID.js +1 -1
- package/leiamnash/getEmojiUrl.js +2 -4
- package/leiamnash/getFriendsList.js +11 -22
- package/leiamnash/getMessage.js +80 -0
- package/leiamnash/getThreadHistory.js +59 -167
- package/leiamnash/getThreadInfo.js +247 -28
- package/leiamnash/getThreadList.js +41 -66
- package/leiamnash/getThreadMain.js +220 -0
- package/leiamnash/getThreadPictures.js +17 -37
- package/leiamnash/getUID.js +59 -0
- package/leiamnash/getUserID.js +9 -13
- package/leiamnash/getUserInfo.js +67 -26
- package/leiamnash/getUserInfoMain.js +65 -0
- package/leiamnash/getUserInfoV2.js +32 -0
- package/leiamnash/getUserInfoV3.js +63 -0
- package/leiamnash/getUserInfoV4.js +55 -0
- package/leiamnash/getUserInfoV5.js +61 -0
- package/leiamnash/handleFriendRequest.js +12 -27
- package/leiamnash/handleMessageRequest.js +15 -31
- package/leiamnash/httpGet.js +13 -16
- package/leiamnash/httpPost.js +12 -16
- package/leiamnash/httpPostFormData.js +41 -0
- package/leiamnash/listenMqtt.js +301 -200
- package/leiamnash/logout.js +13 -20
- package/leiamnash/markAsDelivered.js +11 -21
- package/leiamnash/markAsRead.js +11 -21
- package/leiamnash/markAsReadAll.js +11 -18
- package/leiamnash/markAsSeen.js +9 -17
- package/leiamnash/muteThread.js +10 -15
- package/leiamnash/removeUserFromGroup.js +15 -45
- package/leiamnash/resolvePhotoUrl.js +8 -16
- package/leiamnash/searchForThread.js +10 -20
- package/leiamnash/sendMessage.js +379 -0
- package/leiamnash/sendTypingIndicator.js +9 -32
- package/leiamnash/setMessageReaction.js +12 -20
- package/leiamnash/setPostReaction.js +100 -74
- package/leiamnash/setTitle.js +13 -25
- package/leiamnash/threadColors.js +18 -36
- package/leiamnash/unfriend.js +9 -18
- package/leiamnash/unsendMessage.js +8 -17
- package/logger.js +66 -0
- package/package.json +49 -34
- package/replit.nix +1 -3
- package/utils.js +593 -108
- package/leiamnash/getThreadHistoryDeprecated.js +0 -93
- package/leiamnash/getThreadInfoDeprecated.js +0 -80
- package/leiamnash/getThreadListDeprecated.js +0 -75
@@ -0,0 +1,63 @@
|
|
1
|
+
/* eslint-disable linebreak-style */
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
var utils = require("../utils");
|
5
|
+
var log = require("npmlog");
|
6
|
+
|
7
|
+
|
8
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
9
|
+
return function getUserInfoV3(id,full, callback) {
|
10
|
+
if (utils.getType(full) !== "Boolean") {
|
11
|
+
throw {error: "getUserInfoV3: full must be a boolean"};
|
12
|
+
}
|
13
|
+
var resolveFunc = function () { };
|
14
|
+
var rejectFunc = function () { };
|
15
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
16
|
+
resolveFunc = resolve;
|
17
|
+
rejectFunc = reject;
|
18
|
+
});
|
19
|
+
|
20
|
+
if (!callback) {
|
21
|
+
callback = function (err, userInfo) {
|
22
|
+
if (err) return rejectFunc(err);
|
23
|
+
resolveFunc(userInfo);
|
24
|
+
};
|
25
|
+
}
|
26
|
+
|
27
|
+
var form = {
|
28
|
+
"av": ctx.userID,
|
29
|
+
"fb_api_caller_class": "RelayModern",
|
30
|
+
"fb_api_req_friendly_name": "ProfileCometTimelineFeedRefetchQuery",
|
31
|
+
"variables": JSON.stringify({
|
32
|
+
"id": String(id)
|
33
|
+
}),
|
34
|
+
"doc_id": 5092283120862795
|
35
|
+
};
|
36
|
+
try {
|
37
|
+
defaultFuncs
|
38
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
39
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
40
|
+
.then(function (resData) {
|
41
|
+
if (resData.error) throw resData;
|
42
|
+
switch (full) {
|
43
|
+
case true:
|
44
|
+
callback(null, resData[0].data.node.timeline_list_feed_units.edges[0].node);
|
45
|
+
break;
|
46
|
+
case false:
|
47
|
+
callback(null, resData[0].data.node.timeline_list_feed_units.edges[0].node.comet_sections.context_layout.story.comet_sections.actor_photo.story.actors[0]);
|
48
|
+
break;
|
49
|
+
default:
|
50
|
+
throw {error: "getUserInfoV3: full must be a boolean"};
|
51
|
+
}
|
52
|
+
})
|
53
|
+
.catch(function (err) {
|
54
|
+
log.error("getUserInfo", "Lỗi: getUserInfo Có Thể Do Bạn Spam Quá Nhiều !,Hãy Thử Lại !");
|
55
|
+
return callback(err);
|
56
|
+
});
|
57
|
+
}
|
58
|
+
catch (e) {
|
59
|
+
return callback(null, e);
|
60
|
+
}
|
61
|
+
return returnPromise;
|
62
|
+
};
|
63
|
+
};
|
@@ -0,0 +1,55 @@
|
|
1
|
+
/* eslint-disable linebreak-style */
|
2
|
+
"use strict";
|
3
|
+
|
4
|
+
var utils = require("../utils");
|
5
|
+
var log = require("npmlog");
|
6
|
+
|
7
|
+
|
8
|
+
module.exports = function (defaultFuncs, api, ctx) {
|
9
|
+
return function getUserInfoV4(id, callback) {
|
10
|
+
var resolveFunc = function () { };
|
11
|
+
var rejectFunc = function () { };
|
12
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
13
|
+
resolveFunc = resolve;
|
14
|
+
rejectFunc = reject;
|
15
|
+
});
|
16
|
+
|
17
|
+
if (!callback) {
|
18
|
+
callback = function (err, userInfo) {
|
19
|
+
if (err) return rejectFunc(err);
|
20
|
+
resolveFunc(userInfo);
|
21
|
+
};
|
22
|
+
}
|
23
|
+
|
24
|
+
if (utils.getType(id) !== "Array") id = [id];
|
25
|
+
|
26
|
+
var form = {
|
27
|
+
av: ctx.userID,
|
28
|
+
fb_api_caller_class: "RelayModern",
|
29
|
+
fb_api_req_friendly_name: "PresenceStatusProviderSubscription_ContactProfilesQuery",
|
30
|
+
variables: JSON.stringify({
|
31
|
+
ids: id
|
32
|
+
}),
|
33
|
+
doc_id: 7188178894556645
|
34
|
+
};
|
35
|
+
console.log(form);
|
36
|
+
try {
|
37
|
+
defaultFuncs
|
38
|
+
.post("https://www.facebook.com/api/graphql/", ctx.jar, form)
|
39
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
40
|
+
.then(function (resData) {
|
41
|
+
if (resData.error) throw resData;
|
42
|
+
callback(null,resData.data.viewer.chat_sidebar_contact_nodes[0]);
|
43
|
+
})
|
44
|
+
.catch(function (err) {
|
45
|
+
console.log(err);
|
46
|
+
log.error("getUserInfo", "Lỗi: getUserInfo Có Thể Do Bạn Spam Quá Nhiều !,Hãy Thử Lại !");
|
47
|
+
return callback(err);
|
48
|
+
});
|
49
|
+
}
|
50
|
+
catch (e) {
|
51
|
+
return callback(null, e);
|
52
|
+
}
|
53
|
+
return returnPromise;
|
54
|
+
};
|
55
|
+
};
|
@@ -0,0 +1,61 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
|
6
|
+
|
7
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
8
|
+
|
9
|
+
return function getUserInfoV5GraphQL(id, callback) {
|
10
|
+
var resolveFunc = function(){};
|
11
|
+
var rejectFunc = function(){};
|
12
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
13
|
+
resolveFunc = resolve;
|
14
|
+
rejectFunc = reject;
|
15
|
+
});
|
16
|
+
|
17
|
+
if (utils.getType(callback) != "Function" && utils.getType(callback) != "AsyncFunction") {
|
18
|
+
callback = function (err, data) {
|
19
|
+
if (err) {
|
20
|
+
return rejectFunc(err);
|
21
|
+
}
|
22
|
+
resolveFunc(data);
|
23
|
+
};
|
24
|
+
}
|
25
|
+
|
26
|
+
// `queries` has to be a string. I couldn't tell from the dev console. This
|
27
|
+
// took me a really long time to figure out. I deserve a cookie for this.
|
28
|
+
var form = {
|
29
|
+
queries: JSON.stringify({
|
30
|
+
o0: {
|
31
|
+
// This doc_id is valid as of July 20th, 2020
|
32
|
+
doc_id: "5009315269112105",
|
33
|
+
query_params: {
|
34
|
+
ids: [id]
|
35
|
+
}
|
36
|
+
}
|
37
|
+
}),
|
38
|
+
batch_name: "MessengerParticipantsFetcher"
|
39
|
+
};
|
40
|
+
defaultFuncs
|
41
|
+
.post("https://www.facebook.com/api/graphqlbatch/", ctx.jar, form)
|
42
|
+
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
43
|
+
.then(function(resData) {
|
44
|
+
if (resData.error) {
|
45
|
+
throw resData;
|
46
|
+
}
|
47
|
+
// This returns us an array of things. The last one is the success /
|
48
|
+
// failure one.
|
49
|
+
// @TODO What do we do in this case?
|
50
|
+
if (resData[resData.length - 1].error_results !== 0) {
|
51
|
+
console.error("GetThreadInfo", "Bạn Đang Bị Ăn Get Vì Sử Dụng Quá Nhiều !");
|
52
|
+
}
|
53
|
+
callback(null, resData);
|
54
|
+
})
|
55
|
+
.catch(function(err) {
|
56
|
+
log.error("getThreadInfoGraphQL", "Lỗi: getThreadInfoGraphQL Có Thể Do Bạn Spam Quá Nhiều, Hãy Thử Lại !");
|
57
|
+
return callback(err);
|
58
|
+
});
|
59
|
+
return returnPromise;
|
60
|
+
};
|
61
|
+
};
|
@@ -3,32 +3,26 @@
|
|
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 handleFriendRequest(userID, accept, callback) {
|
8
|
-
if (utils.getType(accept) !== "Boolean") {
|
9
|
-
throw {
|
10
|
-
error: "Please pass a boolean as a second argument."
|
11
|
-
};
|
12
|
-
}
|
8
|
+
if (utils.getType(accept) !== "Boolean") throw { error: "Please pass a boolean as a second argument." };
|
13
9
|
|
14
|
-
var resolveFunc = function(){};
|
15
|
-
var rejectFunc = function(){};
|
10
|
+
var resolveFunc = function () { };
|
11
|
+
var rejectFunc = function () { };
|
16
12
|
var returnPromise = new Promise(function (resolve, reject) {
|
17
13
|
resolveFunc = resolve;
|
18
14
|
rejectFunc = reject;
|
19
15
|
});
|
20
16
|
|
21
17
|
if (!callback) {
|
22
|
-
callback = function (err,
|
23
|
-
if (err)
|
24
|
-
|
25
|
-
}
|
26
|
-
resolveFunc(friendList);
|
18
|
+
callback = function (err, data) {
|
19
|
+
if (err) return rejectFunc(err);
|
20
|
+
resolveFunc(data);
|
27
21
|
};
|
28
22
|
}
|
29
23
|
|
30
24
|
var form = {
|
31
|
-
viewer_id:
|
25
|
+
viewer_id: userID,
|
32
26
|
"frefs[0]": "jwl",
|
33
27
|
floc: "friend_center_requests",
|
34
28
|
ref: "/reqs.php",
|
@@ -36,22 +30,13 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
36
30
|
};
|
37
31
|
|
38
32
|
defaultFuncs
|
39
|
-
.post(
|
40
|
-
"https://www.facebook.com/requests/friends/ajax/",
|
41
|
-
ctx.jar,
|
42
|
-
form
|
43
|
-
)
|
33
|
+
.post("https://www.facebook.com/requests/friends/ajax/", ctx.jar, form)
|
44
34
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
45
|
-
.then(function(resData) {
|
46
|
-
if (resData.payload.err) {
|
47
|
-
throw {
|
48
|
-
err: resData.payload.err
|
49
|
-
};
|
50
|
-
}
|
51
|
-
|
35
|
+
.then(function (resData) {
|
36
|
+
if (resData.payload.err) throw { err: resData.payload.err };
|
52
37
|
return callback();
|
53
38
|
})
|
54
|
-
.catch(function(err) {
|
39
|
+
.catch(function (err) {
|
55
40
|
log.error("handleFriendRequest", err);
|
56
41
|
return callback(err);
|
57
42
|
});
|
@@ -3,27 +3,21 @@
|
|
3
3
|
var utils = require("../utils");
|
4
4
|
var log = require("npmlog");
|
5
5
|
|
6
|
-
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
-
return function handleMessageRequest(threadID, accept, callback) {
|
8
|
-
if (utils.getType(accept) !== "Boolean") {
|
9
|
-
throw {
|
10
|
-
error: "Please pass a boolean as a second argument."
|
11
|
-
};
|
12
|
-
}
|
6
|
+
module.exports = function (/** @type {{ post: any; postFormData?: (arg0: string, arg1: any, arg2: any, arg3: {}) => any; get?: (arg0: any, arg1: any) => Promise<any>; }} */ defaultFuncs, /** @type {any} */ api, /** @type {{ jar: any; fb_dtsg?: string; ttstamp?: string; }} */ ctx) {
|
7
|
+
return function handleMessageRequest(/** @type {string | any[]} */ threadID, /** @type {any} */ accept, /** @type {((err: any, data: any) => void) | ((arg0: undefined) => any)} */ callback) {
|
8
|
+
if (utils.getType(accept) !== "Boolean") throw { error: "Please pass a boolean as a second argument." };
|
13
9
|
|
14
|
-
var resolveFunc = function(){};
|
15
|
-
var rejectFunc = function(){};
|
10
|
+
var resolveFunc = function () { };
|
11
|
+
var rejectFunc = function () { };
|
16
12
|
var returnPromise = new Promise(function (resolve, reject) {
|
17
13
|
resolveFunc = resolve;
|
18
14
|
rejectFunc = reject;
|
19
15
|
});
|
20
16
|
|
21
17
|
if (!callback) {
|
22
|
-
callback = function (err,
|
23
|
-
if (err)
|
24
|
-
|
25
|
-
}
|
26
|
-
resolveFunc(friendList);
|
18
|
+
callback = function (/** @type {any} */ err, /** @type {any} */ data) {
|
19
|
+
if (err) return rejectFunc(err);
|
20
|
+
resolveFunc(data);
|
27
21
|
};
|
28
22
|
}
|
29
23
|
|
@@ -31,35 +25,25 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
31
25
|
client: "mercury"
|
32
26
|
};
|
33
27
|
|
34
|
-
if (utils.getType(threadID) !== "Array")
|
35
|
-
threadID = [threadID];
|
36
|
-
}
|
28
|
+
if (utils.getType(threadID) !== "Array") threadID = [threadID];
|
37
29
|
|
38
30
|
var messageBox = accept ? "inbox" : "other";
|
39
31
|
|
40
|
-
for (var i = 0; i < threadID.length; i++)
|
41
|
-
form[messageBox + "[" + i + "]"] = threadID[i];
|
42
|
-
}
|
32
|
+
for (var i = 0; i < threadID.length; i++) form[messageBox + "[" + i + "]"] = threadID[i];
|
43
33
|
|
44
34
|
defaultFuncs
|
45
|
-
.post(
|
46
|
-
"https://www.facebook.com/ajax/mercury/move_thread.php",
|
47
|
-
ctx.jar,
|
48
|
-
form
|
49
|
-
)
|
35
|
+
.post("https://www.facebook.com/ajax/mercury/move_thread.php", ctx.jar, form)
|
50
36
|
.then(utils.parseAndCheckLogin(ctx, defaultFuncs))
|
51
|
-
.then(function(resData) {
|
52
|
-
if (resData.error)
|
53
|
-
throw resData;
|
54
|
-
}
|
37
|
+
.then(function (/** @type {{ error: any; }} */ resData) {
|
38
|
+
if (resData.error) throw resData;
|
55
39
|
|
56
40
|
return callback();
|
57
41
|
})
|
58
|
-
.catch(function(err) {
|
42
|
+
.catch(function (/** @type {string} */ err) {
|
59
43
|
log.error("handleMessageRequest", err);
|
60
44
|
return callback(err);
|
61
45
|
});
|
62
|
-
|
46
|
+
|
63
47
|
return returnPromise;
|
64
48
|
};
|
65
49
|
};
|
package/leiamnash/httpGet.js
CHANGED
@@ -3,10 +3,10 @@
|
|
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 httpGet(url, form, callback, notAPI) {
|
8
|
-
var resolveFunc = function(){};
|
9
|
-
var rejectFunc = function(){};
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
10
|
|
11
11
|
var returnPromise = new Promise(function (resolve, reject) {
|
12
12
|
resolveFunc = resolve;
|
@@ -17,31 +17,28 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
17
17
|
callback = form;
|
18
18
|
form = {};
|
19
19
|
}
|
20
|
-
|
20
|
+
|
21
21
|
form = form || {};
|
22
22
|
|
23
|
-
callback = callback || function(err, data) {
|
24
|
-
|
25
|
-
|
23
|
+
callback = callback || function (err, data) {
|
24
|
+
if (err) return rejectFunc(err);
|
25
|
+
resolveFunc(data);
|
26
26
|
};
|
27
27
|
|
28
28
|
if (notAPI) {
|
29
29
|
utils
|
30
30
|
.get(url, ctx.jar, form, ctx.globalOptions)
|
31
|
-
.then(
|
32
|
-
|
33
|
-
})
|
34
|
-
.catch(function(err) {
|
31
|
+
.then(resData => callback(null, resData.body.toString()))
|
32
|
+
.catch(function (err) {
|
35
33
|
log.error("httpGet", err);
|
36
34
|
return callback(err);
|
37
35
|
});
|
38
|
-
}
|
36
|
+
}
|
37
|
+
else {
|
39
38
|
defaultFuncs
|
40
39
|
.get(url, ctx.jar, form)
|
41
|
-
.then(
|
42
|
-
|
43
|
-
})
|
44
|
-
.catch(function(err) {
|
40
|
+
.then(resData => callback(null, resData.body.toString()))
|
41
|
+
.catch(function (err) {
|
45
42
|
log.error("httpGet", err);
|
46
43
|
return callback(err);
|
47
44
|
});
|
package/leiamnash/httpPost.js
CHANGED
@@ -3,10 +3,10 @@
|
|
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 httpGet(url, form, callback, notAPI) {
|
8
|
-
var resolveFunc = function(){};
|
9
|
-
var rejectFunc = function(){};
|
8
|
+
var resolveFunc = function () { };
|
9
|
+
var rejectFunc = function () { };
|
10
10
|
|
11
11
|
var returnPromise = new Promise(function (resolve, reject) {
|
12
12
|
resolveFunc = resolve;
|
@@ -20,33 +20,29 @@ module.exports = function(defaultFuncs, api, ctx) {
|
|
20
20
|
|
21
21
|
form = form || {};
|
22
22
|
|
23
|
-
callback = callback || function(err, data) {
|
24
|
-
|
25
|
-
|
23
|
+
callback = callback || function (err, data) {
|
24
|
+
if (err) return rejectFunc(err);
|
25
|
+
resolveFunc(data);
|
26
26
|
};
|
27
27
|
|
28
28
|
if (notAPI) {
|
29
29
|
utils
|
30
30
|
.post(url, ctx.jar, form, ctx.globalOptions)
|
31
|
-
.then(
|
32
|
-
|
33
|
-
})
|
34
|
-
.catch(function(err) {
|
31
|
+
.then(resData => callback(null, resData.body.toString()))
|
32
|
+
.catch(function (err) {
|
35
33
|
log.error("httpPost", err);
|
36
34
|
return callback(err);
|
37
35
|
});
|
38
|
-
}
|
36
|
+
}
|
37
|
+
else {
|
39
38
|
defaultFuncs
|
40
39
|
.post(url, ctx.jar, form, {})
|
41
|
-
.then(
|
42
|
-
|
43
|
-
})
|
44
|
-
.catch(function(err) {
|
40
|
+
.then(resData => callback(null, resData.body.toString()))
|
41
|
+
.catch(function (err) {
|
45
42
|
log.error("httpPost", err);
|
46
43
|
return callback(err);
|
47
44
|
});
|
48
45
|
}
|
49
|
-
|
50
46
|
return returnPromise;
|
51
47
|
};
|
52
48
|
};
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var utils = require("../utils");
|
4
|
+
var log = require("npmlog");
|
5
|
+
|
6
|
+
module.exports = function(defaultFuncs, api, ctx) {
|
7
|
+
return function httpPostFormData(url, form, callback) {
|
8
|
+
var resolveFunc = function(){};
|
9
|
+
var rejectFunc = function(){};
|
10
|
+
|
11
|
+
var returnPromise = new Promise(function (resolve, reject) {
|
12
|
+
resolveFunc = resolve;
|
13
|
+
rejectFunc = reject;
|
14
|
+
});
|
15
|
+
|
16
|
+
if (!callback && (utils.getType(form) == "Function" || utils.getType(form) == "AsyncFunction")) {
|
17
|
+
callback = form;
|
18
|
+
form = {};
|
19
|
+
}
|
20
|
+
|
21
|
+
form = form || {};
|
22
|
+
|
23
|
+
|
24
|
+
callback = callback || function(err, data) {
|
25
|
+
if (err) return rejectFunc(err);
|
26
|
+
resolveFunc(data);
|
27
|
+
};
|
28
|
+
|
29
|
+
defaultFuncs
|
30
|
+
.postFormData(url, ctx.jar, form)
|
31
|
+
.then(function(resData) {
|
32
|
+
callback(null, resData.body.toString());
|
33
|
+
})
|
34
|
+
.catch(function(err) {
|
35
|
+
log.error("httpPostFormData", err);
|
36
|
+
return callback(err);
|
37
|
+
});
|
38
|
+
|
39
|
+
return returnPromise;
|
40
|
+
};
|
41
|
+
};
|