MCPcopy Create free account
hub / github.com/Maccoder3/MAC-MD / serialize

Function serialize

lib/simple.js:1293–1730  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1291
1292// https://github.com/Nurutomo/wabot-aq/issues/490
1293export function serialize() {
1294 const MediaType = [
1295 'imageMessage',
1296 'videoMessage',
1297 'audioMessage',
1298 'stickerMessage',
1299 'documentMessage',
1300 ]
1301 return Object.defineProperties(proto.WebMessageInfo.prototype, {
1302 conn: {
1303 value: undefined,
1304 enumerable: false,
1305 writable: true,
1306 },
1307 id: {
1308 get() {
1309 return this.key?.id
1310 },
1311 },
1312 isBaileys: {
1313 get() {
1314 return (
1315 this.id?.length === 16 || (this.id?.startsWith('3EB0') && this.id?.length === 12) || false
1316 )
1317 },
1318 },
1319 chat: {
1320 get() {
1321 const senderKeyDistributionMessage = this.message?.senderKeyDistributionMessage?.groupId
1322 return (
1323 this.key?.remoteJid ||
1324 (senderKeyDistributionMessage && senderKeyDistributionMessage !== 'status@broadcast') ||
1325 ''
1326 ).decodeJid()
1327 },
1328 },
1329 isGroup: {
1330 get() {
1331 return this.chat.endsWith('@g.us')
1332 },
1333 enumerable: true,
1334 },
1335 sender: {
1336 get() {
1337 return this.conn?.decodeJid(
1338 (this.key?.fromMe && this.conn?.user.id) ||
1339 this.participant ||
1340 this.key.participant ||
1341 this.chat ||
1342 ''
1343 )
1344 },
1345 enumerable: true,
1346 },
1347 fromMe: {
1348 get() {
1349 return this.key?.fromMe || areJidsSameUser(this.conn?.user.id, this.sender) || false
1350 },

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected