@c4t4/heyamigo 0.8.5 → 0.8.6
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/gateway/incoming.js +18 -2
- package/dist/store/media.js +1 -0
- package/package.json +1 -1
package/dist/gateway/incoming.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { unlink } from 'fs/promises';
|
|
1
2
|
import { getContentType, isJidGroup, jidDecode, jidNormalizedUser, } from 'baileys';
|
|
2
3
|
import { getSession } from '../ai/sessions.js';
|
|
3
4
|
import { config } from '../config.js';
|
|
@@ -77,15 +78,30 @@ async function processMessages(messages, sock, ownerJid, isHistorySync = false)
|
|
|
77
78
|
const size = getMediaSize(msg);
|
|
78
79
|
if (size !== null && size > limits.maxFileBytes) {
|
|
79
80
|
await append(stored);
|
|
80
|
-
const mb = (limits.maxFileBytes / (1024 * 1024)).toFixed(1);
|
|
81
81
|
const quoted = isGroup && config.reply.quoteInGroups ? msg : undefined;
|
|
82
|
-
await sendText(sock, stored.jid,
|
|
82
|
+
await sendText(sock, stored.jid, 'Could not process that, please try a smaller file.', quoted).catch((err) => logger.error({ err, jid: stored.jid }, 'failed to send oversized-file notice'));
|
|
83
83
|
logger.info({ ...logCtx, size, cap: limits.maxFileBytes }, 'oversized media rejected');
|
|
84
84
|
continue;
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
// Download media if present (image, video, audio, document)
|
|
88
88
|
const media = await downloadAndSave(msg, stored.jid);
|
|
89
|
+
// Post-download safety net: re-check against the real buffer size.
|
|
90
|
+
// Catches cases the pre-download gate missed — protobuf fileLength
|
|
91
|
+
// missing, nested in documentWithCaptionMessage, stickers, etc.
|
|
92
|
+
// Only enforced when we'd otherwise respond; silent groups keep the
|
|
93
|
+
// archive intact regardless of size.
|
|
94
|
+
if (media &&
|
|
95
|
+
limits.maxFileBytes !== null &&
|
|
96
|
+
decision.respond &&
|
|
97
|
+
media.bytes > limits.maxFileBytes) {
|
|
98
|
+
await unlink(media.mediaPath).catch(() => undefined);
|
|
99
|
+
await append(stored);
|
|
100
|
+
const quoted = isGroup && config.reply.quoteInGroups ? msg : undefined;
|
|
101
|
+
await sendText(sock, stored.jid, 'Could not process that, please try a smaller file.', quoted).catch((err) => logger.error({ err, jid: stored.jid }, 'failed to send oversized-file notice'));
|
|
102
|
+
logger.info({ ...logCtx, bytes: media.bytes, cap: limits.maxFileBytes }, 'oversized media rejected (post-download)');
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
89
105
|
if (media) {
|
|
90
106
|
stored.mediaType = media.mediaType;
|
|
91
107
|
stored.mediaPath = media.mediaPath;
|
package/dist/store/media.js
CHANGED