whatsapp-store-db 1.3.56 → 1.3.58
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/dist/handlers/contact.js
CHANGED
|
@@ -70,6 +70,14 @@ function contactHandler(sessionId, event, getJid = undefined) {
|
|
|
70
70
|
}
|
|
71
71
|
return out;
|
|
72
72
|
};
|
|
73
|
+
/**
|
|
74
|
+
* Checks if a contact has at least one meaningful field beyond just the id.
|
|
75
|
+
* Contacts with only a phone number and no name/notify/verifiedName/imgUrl/status
|
|
76
|
+
* are not useful and should be skipped.
|
|
77
|
+
*/
|
|
78
|
+
const hasContactInfo = (data) => {
|
|
79
|
+
return !!(data.name || data.notify || data.verifiedName || data.imgUrl || data.status);
|
|
80
|
+
};
|
|
73
81
|
const set = async ({ contacts }) => {
|
|
74
82
|
// Skip if sessionId is empty
|
|
75
83
|
if (!sessionId || sessionId.trim() === '') {
|
|
@@ -88,8 +96,12 @@ function contactHandler(sessionId, event, getJid = undefined) {
|
|
|
88
96
|
const data = sanitizeContactData((0, utils_1.transformPrisma)(c));
|
|
89
97
|
return Object.assign(Object.assign({}, data), { id });
|
|
90
98
|
}));
|
|
91
|
-
// Filter
|
|
92
|
-
const finalContacts = normalizedContacts.filter((c) => isValidContact(c.id));
|
|
99
|
+
// Filter out contacts with empty id or no meaningful info
|
|
100
|
+
const finalContacts = normalizedContacts.filter((c) => isValidContact(c.id) && hasContactInfo(c));
|
|
101
|
+
const skippedNoInfo = normalizedContacts.filter((c) => isValidContact(c.id) && !hasContactInfo(c)).length;
|
|
102
|
+
if (skippedNoInfo > 0) {
|
|
103
|
+
logger.info({ skippedNoInfo }, 'Skipped contacts with no useful info (no name/notify/verifiedName)');
|
|
104
|
+
}
|
|
93
105
|
await Promise.all(finalContacts.map((data) => prisma.contact.upsert({
|
|
94
106
|
select: { pkId: true },
|
|
95
107
|
create: Object.assign(Object.assign({}, data), { sessionId }),
|
|
@@ -116,8 +128,8 @@ function contactHandler(sessionId, event, getJid = undefined) {
|
|
|
116
128
|
const data = sanitizeContactData((0, utils_1.transformPrisma)(c));
|
|
117
129
|
return Object.assign(Object.assign({}, data), { id });
|
|
118
130
|
}));
|
|
119
|
-
// Filter
|
|
120
|
-
const finalContacts = normalizedContacts.filter((c) => isValidContact(c.id));
|
|
131
|
+
// Filter out contacts with empty id or no meaningful info
|
|
132
|
+
const finalContacts = normalizedContacts.filter((c) => isValidContact(c.id) && hasContactInfo(c));
|
|
121
133
|
await Promise.all(finalContacts.map((data) => prisma.contact.upsert({
|
|
122
134
|
select: { pkId: true },
|
|
123
135
|
create: Object.assign(Object.assign({}, data), { sessionId }),
|
|
@@ -148,6 +160,19 @@ function contactHandler(sessionId, event, getJid = undefined) {
|
|
|
148
160
|
continue;
|
|
149
161
|
}
|
|
150
162
|
const transformedData = sanitizeContactData((0, utils_1.transformPrisma)(update));
|
|
163
|
+
// Skip if update has no meaningful contact info
|
|
164
|
+
if (!hasContactInfo(transformedData)) {
|
|
165
|
+
// Check if the contact already exists before skipping
|
|
166
|
+
// If it exists, we might still want to update other fields
|
|
167
|
+
const existing = await prisma.contact.findUnique({
|
|
168
|
+
select: { pkId: true },
|
|
169
|
+
where: { sessionId_id: { sessionId, id: contactId } },
|
|
170
|
+
});
|
|
171
|
+
if (!existing) {
|
|
172
|
+
logger.debug({ contactId }, 'Skipping contact update with no useful info - contact does not exist');
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
151
176
|
await prisma.contact.upsert({
|
|
152
177
|
select: { pkId: true },
|
|
153
178
|
create: Object.assign(Object.assign({}, transformedData), { id: contactId, sessionId }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "whatsapp-store-db",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.58",
|
|
4
4
|
"description": "Minimal Baileys data storage for your favorite DBMS built with Prisma",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
"build": "tsc",
|
|
15
15
|
"typecheck": "tsc --noEmit",
|
|
16
16
|
"lint": "eslint .",
|
|
17
|
-
"format": "prettier . --write"
|
|
17
|
+
"format": "prettier . --write",
|
|
18
|
+
"postinstall": "patch-package"
|
|
18
19
|
},
|
|
19
20
|
"devDependencies": {
|
|
20
21
|
"@prisma/client": "^5.10.2",
|
|
@@ -30,6 +31,7 @@
|
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
33
|
"baileys": "7.0.0-rc.9",
|
|
34
|
+
"patch-package": "^8.0.0",
|
|
33
35
|
"tiny-invariant": "^1.3.1"
|
|
34
36
|
},
|
|
35
37
|
"peerDependencies": {
|
|
@@ -37,6 +39,7 @@
|
|
|
37
39
|
},
|
|
38
40
|
"files": [
|
|
39
41
|
"dist/",
|
|
42
|
+
"patches/",
|
|
40
43
|
"prisma/schema.prisma",
|
|
41
44
|
".env.example"
|
|
42
45
|
]
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
diff --git a/node_modules/baileys/lib/Socket/messages-recv.js b/node_modules/baileys/lib/Socket/messages-recv.js
|
|
2
|
+
index f2e2e10..e1a6c95 100644
|
|
3
|
+
--- a/node_modules/baileys/lib/Socket/messages-recv.js
|
|
4
|
+
+++ b/node_modules/baileys/lib/Socket/messages-recv.js
|
|
5
|
+
@@ -988,8 +988,12 @@ export const makeMessagesRecvSocket = (config) => {
|
|
6
|
+
await decrypt();
|
|
7
|
+
// message failed to decrypt
|
|
8
|
+
if (msg.messageStubType === proto.WebMessageInfo.StubType.CIPHERTEXT && msg.category !== 'peer') {
|
|
9
|
+
- if (msg?.messageStubParameters?.[0] === MISSING_KEYS_ERROR_TEXT ||
|
|
10
|
+
- msg.messageStubParameters?.[0] === NO_MESSAGE_FOUND_ERROR_TEXT) {
|
|
11
|
+
+ if (msg?.messageStubParameters?.[0] === MISSING_KEYS_ERROR_TEXT) {
|
|
12
|
+
+ return sendMessageAck(node);
|
|
13
|
+
+ }
|
|
14
|
+
+ if (msg.messageStubParameters?.[0] === NO_MESSAGE_FOUND_ERROR_TEXT) {
|
|
15
|
+
+ logger.error({ msgId: msg.key?.id, remoteJid: msg.key?.remoteJid }, 'CTWA: Message absent from node detected, requesting placeholder resend');
|
|
16
|
+
+ requestPlaceholderResend(msg.key).catch(err => logger.error({ err, msgId: msg.key?.id }, 'CTWA: Failed to request placeholder resend'));
|
|
17
|
+
return sendMessageAck(node);
|
|
18
|
+
}
|
|
19
|
+
const errorMessage = msg?.messageStubParameters?.[0] || '';
|