@badzz88/baileys 8.5.7 → 8.5.8
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/README.md +337 -1055
- package/WAProto/WAProto.proto +284 -264
- package/WAProto/index.js +5 -5
- package/engine-requirements.js +7 -15
- package/lib/Defaults/index.js +130 -187
- package/lib/Signal/Group/ciphertext-message.js +11 -14
- package/lib/Signal/Group/group-session-builder.js +29 -91
- package/lib/Signal/Group/group_cipher.js +81 -88
- package/lib/Signal/Group/index.js +12 -136
- package/lib/Signal/Group/keyhelper.js +15 -70
- package/lib/Signal/Group/sender-chain-key.js +25 -31
- package/lib/Signal/Group/sender-key-distribution-message.js +62 -65
- package/lib/Signal/Group/sender-key-message.js +65 -68
- package/lib/Signal/Group/sender-key-name.js +41 -43
- package/lib/Signal/Group/sender-key-record.js +40 -43
- package/lib/Signal/Group/sender-key-state.js +83 -96
- package/lib/Signal/Group/sender-message-key.js +25 -29
- package/lib/Signal/libsignal.js +425 -453
- package/lib/Signal/lid-mapping.js +276 -259
- package/lib/Socket/Client/index.js +3 -30
- package/lib/Socket/Client/types.js +10 -12
- package/lib/Socket/Client/websocket.js +53 -61
- package/lib/Socket/business.js +379 -422
- package/lib/Socket/chats.js +1193 -1816
- package/lib/Socket/communities.js +431 -549
- package/lib/Socket/graphql.js +672 -612
- package/lib/Socket/groups.js +374 -764
- package/lib/Socket/index.js +17 -38
- package/lib/Socket/interop.js +417 -503
- package/lib/Socket/messages-recv.js +1915 -2441
- package/lib/Socket/messages-send.js +1213 -1630
- package/lib/Socket/mex.js +9 -15
- package/lib/Socket/newsletter.js +747 -808
- package/lib/Socket/privacy.js +310 -441
- package/lib/Socket/socket.js +1025 -1022
- package/lib/Socket/username.js +8 -15
- package/lib/Store/index.js +10 -36
- package/lib/Store/make-cache-manager-store.js +80 -85
- package/lib/Store/make-in-memory-store.js +231 -591
- package/lib/Store/make-ordered-dictionary.js +72 -78
- package/lib/Store/object-repository.js +28 -25
- package/lib/Types/Auth.js +2 -38
- package/lib/Types/Bussines.js +2 -2
- package/lib/Types/Call.js +2 -2
- package/lib/Types/Chat.js +8 -4
- package/lib/Types/Contact.js +2 -2
- package/lib/Types/Events.js +2 -2
- package/lib/Types/GroupMetadata.js +2 -2
- package/lib/Types/Label.js +24 -26
- package/lib/Types/LabelAssociation.js +6 -8
- package/lib/Types/Message.js +11 -95
- package/lib/Types/Mex.js +111 -112
- package/lib/Types/Product.js +2 -2
- package/lib/Types/Signal.js +2 -2
- package/lib/Types/Socket.js +3 -2
- package/lib/Types/State.js +56 -70
- package/lib/Types/USync.js +2 -2
- package/lib/Types/index.js +26 -55
- package/lib/Utils/auth-utils.js +288 -292
- package/lib/Utils/browser-utils.js +47 -113
- package/lib/Utils/business.js +224 -240
- package/lib/Utils/chat-utils.js +869 -1205
- package/lib/Utils/companion-reg-client-utils.js +34 -41
- package/lib/Utils/crypto.js +107 -144
- package/lib/Utils/decode-wa-message.js +308 -518
- package/lib/Utils/event-buffer.js +611 -596
- package/lib/Utils/generics.js +355 -515
- package/lib/Utils/history.js +134 -244
- package/lib/Utils/identity-change-handler.js +49 -51
- package/lib/Utils/index.js +23 -57
- package/lib/Utils/link-preview.js +77 -135
- package/lib/Utils/logger.js +3 -9
- package/lib/Utils/lt-hash.js +6 -37
- package/lib/Utils/make-mutex.js +33 -36
- package/lib/Utils/message-composer.js +233 -439
- package/lib/Utils/message-retry-manager.js +260 -265
- package/lib/Utils/messages-media.js +829 -855
- package/lib/Utils/messages.js +961 -2528
- package/lib/Utils/noise-handler.js +200 -195
- package/lib/Utils/offline-node-processor.js +33 -35
- package/lib/Utils/pre-key-manager.js +102 -103
- package/lib/Utils/process-message.js +560 -978
- package/lib/Utils/reporting-utils.js +253 -257
- package/lib/Utils/signal.js +195 -218
- package/lib/Utils/stanza-ack.js +29 -31
- package/lib/Utils/sticker.js +109 -144
- package/lib/Utils/sync-action-utils.js +45 -50
- package/lib/Utils/tc-token-utils.js +139 -137
- package/lib/Utils/use-multi-file-auth-state.js +109 -109
- package/lib/Utils/validate-connection.js +202 -218
- package/lib/WABinary/constants.js +1299 -1302
- package/lib/WABinary/decode.js +262 -343
- package/lib/WABinary/encode.js +4 -12
- package/lib/WABinary/generic-utils.js +187 -223
- package/lib/WABinary/index.js +6 -33
- package/lib/WABinary/jid-utils.js +88 -351
- package/lib/WABinary/types.js +2 -2
- package/lib/WAM/BinaryInfo.js +9 -12
- package/lib/WAM/constants.js +22853 -39486
- package/lib/WAM/encode.js +140 -132
- package/lib/WAM/index.js +4 -31
- package/lib/WAUSync/Protocols/USyncBotProfileProtocol.js +21 -23
- package/lib/WAUSync/Protocols/USyncBusinessProtocol.js +9 -9
- package/lib/WAUSync/Protocols/USyncContactProtocol.js +7 -7
- package/lib/WAUSync/Protocols/USyncDeviceProtocol.js +10 -10
- package/lib/WAUSync/Protocols/USyncDisappearingModeProtocol.js +7 -7
- package/lib/WAUSync/Protocols/USyncFeatureProtocol.js +11 -12
- package/lib/WAUSync/Protocols/USyncLIDProtocol.js +4 -5
- package/lib/WAUSync/Protocols/USyncPictureProtocol.js +7 -7
- package/lib/WAUSync/Protocols/USyncSidelistProtocol.js +7 -8
- package/lib/WAUSync/Protocols/USyncStatusProtocol.js +7 -7
- package/lib/WAUSync/Protocols/USyncTextStatusProtocol.js +8 -8
- package/lib/WAUSync/Protocols/USyncUsernameProtocol.js +7 -7
- package/lib/WAUSync/Protocols/index.js +12 -39
- package/lib/WAUSync/USyncQuery.js +67 -49
- package/lib/WAUSync/USyncUser.js +11 -5
- package/lib/WAUSync/index.js +3 -31
- package/lib/index.js +15 -48
- package/package.json +129 -99
- package/LICENSE +0 -21
- package/lib/Defaults/phonenumber-mcc.json +0 -223
- package/lib/Socket/aigroups.js +0 -240
- package/lib/Socket/interactive-handler.js +0 -522
- package/lib/Socket/managed-account.js +0 -183
- package/lib/Socket/registration.js +0 -427
- package/lib/Socket/text-router.js +0 -83
- package/lib/Types/Newsletter.js +0 -121
- package/lib/Utils/command-loader.d.ts +0 -31
- package/lib/Utils/command-loader.js +0 -100
- package/lib/Utils/consumer-application.js +0 -107
- package/lib/Utils/curve25519-js.js +0 -275
- package/lib/Utils/group-history.js +0 -60
- package/lib/Utils/jid-display-normalization.js +0 -218
- package/lib/Utils/meta-ai-msmsg.js +0 -262
- package/lib/Utils/native-bridge.js +0 -82
- package/lib/Utils/session-pool.d.ts +0 -16
- package/lib/Utils/session-pool.js +0 -94
- package/lib/Utils/sticker.d.ts +0 -17
- package/lib/Utils/view-once-cache.d.ts +0 -9
- package/lib/Utils/view-once-cache.js +0 -79
- package/lib/Utils/voip-rekey.js +0 -22
- package/lib/antiban.js +0 -4637
package/lib/Utils/sticker.js
CHANGED
|
@@ -1,145 +1,110 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const os = require('os')
|
|
5
|
-
const path = require('path')
|
|
6
|
-
const fs = require('fs')
|
|
7
|
-
const crypto = require('crypto')
|
|
8
|
-
const { exec } = require('child_process')
|
|
1
|
+
import { Boom } from '@hapi/boom';
|
|
2
|
+
import { spawn } from 'child_process';
|
|
3
|
+
import { randomUUID } from 'crypto';
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
* Converts a video buffer to an animated WhatsApp sticker-ready webp buffer.
|
|
117
|
-
* Requires the `ffmpeg` binary to be available on PATH.
|
|
118
|
-
* @param {Buffer} videoBuffer
|
|
119
|
-
* @param {{ packName?: string, packPublisher?: string, categories?: string[], fps?: number, seconds?: number }} [options]
|
|
120
|
-
* @returns {Promise<Buffer>}
|
|
121
|
-
*/
|
|
122
|
-
const videoToWebpSticker = async (videoBuffer, options = {}) => {
|
|
123
|
-
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'xazbails-sticker-'))
|
|
124
|
-
const inputPath = path.join(tmpDir, 'input.mp4')
|
|
125
|
-
const outputPath = path.join(tmpDir, 'output.webp')
|
|
126
|
-
fs.writeFileSync(inputPath, videoBuffer)
|
|
127
|
-
const fps = options.fps ?? 10
|
|
128
|
-
const seconds = options.seconds ?? 5
|
|
129
|
-
const cmd =
|
|
130
|
-
`ffmpeg -y -i ${inputPath} -t ${seconds} -vf ` +
|
|
131
|
-
`"fps=${fps},scale=512:512:force_original_aspect_ratio=decrease,` +
|
|
132
|
-
`pad=512:512:(ow-iw)/2:(oh-ih)/2:color=0x00000000,split[a][b];` +
|
|
133
|
-
`[a]palettegen=reserve_transparent=1[p];[b][p]paletteuse" ` +
|
|
134
|
-
`-loop 0 -preset default -an -vsync 0 ${outputPath}`
|
|
135
|
-
try {
|
|
136
|
-
await new Promise((resolve, reject) => {
|
|
137
|
-
exec(cmd, err => (err ? reject(err) : resolve()))
|
|
138
|
-
})
|
|
139
|
-
const webp = fs.readFileSync(outputPath)
|
|
140
|
-
return await addExifToWebp(webp, options)
|
|
141
|
-
} finally {
|
|
142
|
-
fs.rmSync(tmpDir, { recursive: true, force: true })
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
exports.videoToWebpSticker = videoToWebpSticker
|
|
5
|
+
const runFfmpeg = (input, args) => new Promise((resolve, reject) => {
|
|
6
|
+
const proc = spawn('ffmpeg', ['-hide_banner', '-loglevel', 'error', '-i', 'pipe:0', ...args, 'pipe:1'], { stdio: ['pipe', 'pipe', 'pipe'] });
|
|
7
|
+
const outChunks = [];
|
|
8
|
+
const errChunks = [];
|
|
9
|
+
proc.stdout.on('data', chunk => outChunks.push(chunk));
|
|
10
|
+
proc.stderr.on('data', chunk => errChunks.push(chunk));
|
|
11
|
+
proc.on('error', err => reject(new Boom(`ffmpeg failed to start: ${err.message}`, { statusCode: 500 })));
|
|
12
|
+
proc.on('close', code => {
|
|
13
|
+
if (code !== 0) {
|
|
14
|
+
reject(new Boom(`ffmpeg exited with code ${code}: ${Buffer.concat(errChunks).toString('utf8').slice(0, 500)}`, { statusCode: 500 }));
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
resolve(Buffer.concat(outChunks));
|
|
18
|
+
});
|
|
19
|
+
proc.stdin.on('error', () => { });
|
|
20
|
+
proc.stdin.end(input);
|
|
21
|
+
});
|
|
22
|
+
export const convertToWebp = async (buffer, { animated = false, quality = 60 } = {}) => {
|
|
23
|
+
const scalePad = "scale='min(512,iw)':'min(512,ih)':force_original_aspect_ratio=decrease,format=rgba,pad=512:512:-1:-1:color=#00000000";
|
|
24
|
+
const args = animated
|
|
25
|
+
? ['-vf', `${scalePad},fps=15`, '-loop', '0', '-preset', 'default', '-an', '-vsync', '0', '-vcodec', 'libwebp', '-q:v', String(quality), '-f', 'webp']
|
|
26
|
+
: ['-vf', `${scalePad}`, '-vframes', '1', '-vcodec', 'libwebp', '-q:v', String(quality), '-f', 'webp'];
|
|
27
|
+
return runFfmpeg(buffer, args);
|
|
28
|
+
};
|
|
29
|
+
const readChunks = (buf) => {
|
|
30
|
+
const chunks = [];
|
|
31
|
+
let offset = 12;
|
|
32
|
+
while (offset + 8 <= buf.length) {
|
|
33
|
+
const fourCC = buf.toString('ascii', offset, offset + 4);
|
|
34
|
+
const size = buf.readUInt32LE(offset + 4);
|
|
35
|
+
const dataStart = offset + 8;
|
|
36
|
+
const data = buf.subarray(dataStart, dataStart + size);
|
|
37
|
+
chunks.push({ fourCC, data });
|
|
38
|
+
offset = dataStart + size + (size % 2);
|
|
39
|
+
}
|
|
40
|
+
return chunks;
|
|
41
|
+
};
|
|
42
|
+
const buildChunk = (fourCC, data) => {
|
|
43
|
+
const header = Buffer.alloc(8);
|
|
44
|
+
header.write(fourCC, 0, 4, 'ascii');
|
|
45
|
+
header.writeUInt32LE(data.length, 4);
|
|
46
|
+
const pad = data.length % 2 === 1 ? Buffer.from([0]) : Buffer.alloc(0);
|
|
47
|
+
return Buffer.concat([header, data, pad]);
|
|
48
|
+
};
|
|
49
|
+
const buildExifChunkData = (json) => {
|
|
50
|
+
const header = Buffer.from([0x49, 0x49, 0x2a, 0x00, 0x08, 0x00, 0x00, 0x00, 0x01, 0x00, 0x41, 0x57, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00]);
|
|
51
|
+
const payload = Buffer.from(JSON.stringify(json), 'utf8');
|
|
52
|
+
header.writeUInt32LE(payload.length, 14);
|
|
53
|
+
return Buffer.concat([header, payload]);
|
|
54
|
+
};
|
|
55
|
+
export const writeExifToWebp = (webpBuffer, { packId, packName = '', publisher = '', emojis = [], isAvatar = false } = {}) => {
|
|
56
|
+
if (webpBuffer.toString('ascii', 0, 4) !== 'RIFF' || webpBuffer.toString('ascii', 8, 12) !== 'WEBP') {
|
|
57
|
+
throw new Boom('writeExifToWebp: not a valid webp buffer', { statusCode: 400 });
|
|
58
|
+
}
|
|
59
|
+
const chunks = readChunks(webpBuffer);
|
|
60
|
+
const exifData = buildExifChunkData({
|
|
61
|
+
'sticker-pack-id': packId || randomUUID(),
|
|
62
|
+
'sticker-pack-name': packName,
|
|
63
|
+
'sticker-pack-publisher': publisher,
|
|
64
|
+
emojis: emojis.length ? emojis : ['🤖'],
|
|
65
|
+
'is-avatar-sticker': isAvatar ? 1 : 0
|
|
66
|
+
});
|
|
67
|
+
let vp8x = chunks.find(c => c.fourCC === 'VP8X');
|
|
68
|
+
const otherChunks = chunks.filter(c => c.fourCC !== 'VP8X' && c.fourCC !== 'EXIF');
|
|
69
|
+
if (!vp8x) {
|
|
70
|
+
const img = otherChunks.find(c => c.fourCC === 'VP8 ' || c.fourCC === 'VP8L');
|
|
71
|
+
if (!img) {
|
|
72
|
+
throw new Boom('writeExifToWebp: no VP8/VP8L image data found', { statusCode: 400 });
|
|
73
|
+
}
|
|
74
|
+
let width;
|
|
75
|
+
let height;
|
|
76
|
+
if (img.fourCC === 'VP8 ') {
|
|
77
|
+
width = (img.data.readUInt16LE(6) & 0x3fff);
|
|
78
|
+
height = (img.data.readUInt16LE(8) & 0x3fff);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
const b = img.data;
|
|
82
|
+
width = 1 + (((b[2] & 0x3f) << 8) | b[1]);
|
|
83
|
+
height = 1 + (((b[4] & 0xf) << 10) | (b[3] << 2) | ((b[2] & 0xc0) >> 6));
|
|
84
|
+
}
|
|
85
|
+
const flags = Buffer.alloc(4);
|
|
86
|
+
flags[0] = 0x08;
|
|
87
|
+
const dims = Buffer.alloc(6);
|
|
88
|
+
dims.writeUIntLE(width - 1, 0, 3);
|
|
89
|
+
dims.writeUIntLE(height - 1, 3, 3);
|
|
90
|
+
vp8x = { fourCC: 'VP8X', data: Buffer.concat([flags, dims]) };
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
const flagsByte = vp8x.data[0] | 0x08;
|
|
94
|
+
vp8x = { fourCC: 'VP8X', data: Buffer.concat([Buffer.from([flagsByte]), vp8x.data.subarray(1)]) };
|
|
95
|
+
}
|
|
96
|
+
const rebuilt = [vp8x, ...otherChunks, { fourCC: 'EXIF', data: exifData }];
|
|
97
|
+
const chunkBuffers = rebuilt.map(c => buildChunk(c.fourCC, c.data));
|
|
98
|
+
const payload = Buffer.concat(chunkBuffers);
|
|
99
|
+
const riffSize = 4 + payload.length;
|
|
100
|
+
const out = Buffer.alloc(8 + 4 + payload.length);
|
|
101
|
+
out.write('RIFF', 0, 4, 'ascii');
|
|
102
|
+
out.writeUInt32LE(riffSize, 4);
|
|
103
|
+
out.write('WEBP', 8, 4, 'ascii');
|
|
104
|
+
payload.copy(out, 12);
|
|
105
|
+
return out;
|
|
106
|
+
};
|
|
107
|
+
export const makeSticker = async (buffer, { pack = '', author = '', emojis = [], isPrivate = false, animated = false, quality = 60 } = {}) => {
|
|
108
|
+
const webp = await convertToWebp(buffer, { animated, quality });
|
|
109
|
+
return writeExifToWebp(webp, { packName: pack, publisher: author, emojis, isAvatar: isPrivate });
|
|
110
|
+
};
|
|
@@ -1,54 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.emitSyncActionResults = exports.processContactAction = void 0
|
|
4
|
-
const WABinary_1 = require('../WABinary')
|
|
1
|
+
import { proto } from '../../WAProto/index.js';
|
|
2
|
+
import { isLidUser, isPnUser } from '../WABinary/index.js';
|
|
5
3
|
/**
|
|
6
4
|
* Process contactAction and return events to emit.
|
|
7
5
|
* Pure function - no side effects.
|
|
8
6
|
*/
|
|
9
|
-
const processContactAction = (action, id, logger) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
exports.emitSyncActionResults = emitSyncActionResults
|
|
7
|
+
export const processContactAction = (action, id, logger) => {
|
|
8
|
+
const results = [];
|
|
9
|
+
if (!id) {
|
|
10
|
+
logger?.warn({ hasFullName: !!action.fullName, hasLidJid: !!action.lidJid, hasPnJid: !!action.pnJid }, 'contactAction sync: missing id in index');
|
|
11
|
+
return results;
|
|
12
|
+
}
|
|
13
|
+
const lidJid = action.lidJid;
|
|
14
|
+
const idIsPn = isPnUser(id);
|
|
15
|
+
// PN is in index[1], not in contactAction.pnJid which is usually null
|
|
16
|
+
const phoneNumber = idIsPn ? id : action.pnJid || undefined;
|
|
17
|
+
// Always emit contacts.upsert
|
|
18
|
+
results.push({
|
|
19
|
+
event: 'contacts.upsert',
|
|
20
|
+
data: [
|
|
21
|
+
{
|
|
22
|
+
id,
|
|
23
|
+
name: action.fullName || action.firstName || action.username || undefined,
|
|
24
|
+
username: action.username || undefined,
|
|
25
|
+
lid: lidJid || undefined,
|
|
26
|
+
phoneNumber
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
});
|
|
30
|
+
// Emit lid-mapping.update if we have valid LID-PN pair
|
|
31
|
+
if (lidJid && isLidUser(lidJid) && idIsPn) {
|
|
32
|
+
results.push({
|
|
33
|
+
event: 'lid-mapping.update',
|
|
34
|
+
data: { lid: lidJid, pn: id }
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return results;
|
|
38
|
+
};
|
|
39
|
+
export const emitSyncActionResults = (ev, results) => {
|
|
40
|
+
for (const result of results) {
|
|
41
|
+
if (result.event === 'contacts.upsert') {
|
|
42
|
+
ev.emit('contacts.upsert', result.data);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
ev.emit('lid-mapping.update', result.data);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=sync-action-utils.js.map
|