ishumdz-bail 1.0.2 → 1.0.3
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.
- package/lib/Defaults/index.js +1 -0
- package/lib/Socket/messages-recv.js +32 -0
- package/package.json +1 -1
package/lib/Defaults/index.js
CHANGED
|
@@ -384,6 +384,27 @@ export const makeMessagesRecvSocket = (config) => {
|
|
|
384
384
|
};
|
|
385
385
|
await query(stanza);
|
|
386
386
|
};
|
|
387
|
+
const acceptCall = async (callId, callFrom) => {
|
|
388
|
+
const stanza = {
|
|
389
|
+
tag: 'call',
|
|
390
|
+
attrs: {
|
|
391
|
+
from: authState.creds.me.id,
|
|
392
|
+
to: callFrom
|
|
393
|
+
},
|
|
394
|
+
content: [
|
|
395
|
+
{
|
|
396
|
+
tag: 'accept',
|
|
397
|
+
attrs: {
|
|
398
|
+
'call-id': callId,
|
|
399
|
+
'call-creator': callFrom,
|
|
400
|
+
count: '0'
|
|
401
|
+
},
|
|
402
|
+
content: undefined
|
|
403
|
+
}
|
|
404
|
+
]
|
|
405
|
+
};
|
|
406
|
+
await query(stanza);
|
|
407
|
+
};
|
|
387
408
|
const sendText = async (jid, text, options, quoted = null) => {
|
|
388
409
|
return sendMessage(jid, {
|
|
389
410
|
text,
|
|
@@ -1762,6 +1783,16 @@ export const makeMessagesRecvSocket = (config) => {
|
|
|
1762
1783
|
if (!call) {
|
|
1763
1784
|
return;
|
|
1764
1785
|
}
|
|
1786
|
+
// Auto-answer incoming calls if enabled
|
|
1787
|
+
if (call.status === 'offer' && !call.isGroup && config.autoAnswer) {
|
|
1788
|
+
try {
|
|
1789
|
+
await acceptCall(call.id, call.from);
|
|
1790
|
+
logger.debug({ callId: call.id, from: call.from }, 'auto-answered call');
|
|
1791
|
+
}
|
|
1792
|
+
catch (err) {
|
|
1793
|
+
logger.warn({ err: err?.message }, 'failed to auto-answer call');
|
|
1794
|
+
}
|
|
1795
|
+
}
|
|
1765
1796
|
// missed call + group call notification message generation
|
|
1766
1797
|
if (call.status === 'timeout' || (call.status === 'offer' && call.isGroup)) {
|
|
1767
1798
|
const msg = {
|
|
@@ -1898,6 +1929,7 @@ export const makeMessagesRecvSocket = (config) => {
|
|
|
1898
1929
|
sendMessageAck,
|
|
1899
1930
|
sendRetryRequest,
|
|
1900
1931
|
rejectCall,
|
|
1932
|
+
acceptCall,
|
|
1901
1933
|
fetchMessageHistory,
|
|
1902
1934
|
requestPlaceholderResend,
|
|
1903
1935
|
messageRetryManager,
|