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

Commit b084718

Browse files
committed
Update editMessage.js
1 parent 58355fb commit b084718

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

fb-chat-api/src/editMessage.js

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
const generateOfflineThreadingId = require('../utils');
77

88
function canBeCalled(func) {
9-
try {
10-
Reflect.apply(func, null, []);
11-
return true;
12-
} catch (error) {
13-
return false;
14-
}
9+
try {
10+
Reflect.apply(func, null, []);
11+
return true;
12+
} catch (error) {
13+
return false;
14+
}
1515
}
1616

1717
/**
@@ -21,46 +21,46 @@ function canBeCalled(func) {
2121
* @param {Object} callback - Callback for the function.
2222
*/
2323

24-
module.exports = function(defaultFuncs, api, ctx) {
25-
return function editMessage(text, messageID, callback) {
26-
if (!ctx.mqttClient) {
27-
throw new Error('Not connected to MQTT');
28-
}
24+
module.exports = function (defaultFuncs, api, ctx) {
25+
return function editMessage(text, messageID, callback) {
26+
if (!ctx.mqttClient) {
27+
throw new Error('Not connected to MQTT');
28+
}
2929

30-
ctx.wsReqNumber += 1;
31-
ctx.wsTaskNumber += 1;
30+
ctx.wsReqNumber += 1;
31+
ctx.wsTaskNumber += 1;
3232

33-
const queryPayload = {
34-
message_id: messageID,
35-
text: text,
36-
};
33+
const queryPayload = {
34+
message_id: messageID,
35+
text: text
36+
};
3737

38-
const query = {
39-
failure_count: null,
40-
label: '742',
41-
payload: JSON.stringify(queryPayload),
42-
queue_name: 'edit_message',
43-
task_id: ctx.wsTaskNumber,
44-
};
38+
const query = {
39+
failure_count: null,
40+
label: '742',
41+
payload: JSON.stringify(queryPayload),
42+
queue_name: 'edit_message',
43+
task_id: ctx.wsTaskNumber
44+
};
4545

46-
const context = {
47-
app_id: '2220391788200892',
48-
payload: {
49-
data_trace_id: null,
50-
epoch_id: parseInt(generateOfflineThreadingId),
51-
tasks: [query],
52-
version_id: '6903494529735864',
53-
},
54-
request_id: ctx.wsReqNumber,
55-
type: 3,
56-
};
46+
const context = {
47+
app_id: '2220391788200892',
48+
payload: {
49+
data_trace_id: null,
50+
epoch_id: parseInt(generateOfflineThreadingId),
51+
tasks: [query],
52+
version_id: '6903494529735864'
53+
},
54+
request_id: ctx.wsReqNumber,
55+
type: 3
56+
};
5757

58-
context.payload = JSON.stringify(context.payload);
58+
context.payload = JSON.stringify(context.payload);
5959

60-
if (canBeCalled(callback)) {
61-
ctx.reqCallbacks[ctx.wsReqNumber] = callback;
62-
}
60+
// if (canBeCalled(callback)) {
61+
// ctx.reqCallbacks[ctx.wsReqNumber] = callback;
62+
// }
6363

64-
ctx.mqttClient.publish('/ls_req', JSON.stringify(context), { qos: 1, retain: false });
65-
}
66-
}
64+
ctx.mqttClient.publish('/ls_req', JSON.stringify(context), { qos: 1, retain: false });
65+
};
66+
};

0 commit comments

Comments
 (0)