Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Update fca #87

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions fb-chat-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ function buildAPI(globalOptions, html, jar) {
'unsendMessage',
'unfriend',
'editMessage',
'shareContact',

// HTTP
'httpGet',
Expand Down
55 changes: 55 additions & 0 deletions fb-chat-api/src/shareContact.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"use strict";


var utils = require("../utils");

var log = require("npmlog");


module.exports = function (defaultFuncs, api, ctx) {
return async function shareContact(text, senderID, threadID, callback) {
await utils.parseAndCheckLogin(ctx, defaultFuncs);
const mqttClient = ctx.mqttClient;

if (!mqttClient) {
throw new Error("Not connected to MQTT");
}
var resolveFunc = function () { };
var rejectFunc = function () { };
var returnPromise = new Promise(function (resolve, reject) {
resolveFunc = resolve;
rejectFunc = reject;
});
if (!callback) {
callback = function (err, data) {
if (err) return rejectFunc(err);
resolveFunc(data);
data };
}
let count_req = 0
var form = JSON.stringify({
"app_id": "2220391788200892",
"payload": JSON.stringify({
tasks: [{
label: '359',
payload: JSON.stringify({
"contact_id": senderID,
"sync_group": 1,
"text": text || "",
"thread_id": threadID
}),
queue_name: 'messenger_contact_sharing',
task_id: Math.random() * 1001 << 0,
failure_count: null,
}],
epoch_id: utils.generateOfflineThreadingID(),
version_id: '7214102258676893',
}),
"request_id": ++count_req,
"type": 3
});
mqttClient.publish('/ls_req',form)

return returnPromise;
};
};
Loading