amiudmodz 5.1.2 → 5.1.5

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.
@@ -444,6 +444,7 @@ const getHttpStream = async (url, options = {}) => {
444
444
  exports.getHttpStream = getHttpStream;
445
445
  const prepareStream = async (media, mediaType, { logger, saveOriginalFileIfRequired, opts } = {}) => {
446
446
  const { stream, type } = await (0, exports.getStream)(media, opts);
447
+ media = undefined; // Help GC
447
448
  logger === null || logger === void 0 ? void 0 : logger.debug('fetched media stream');
448
449
  let bodyPath;
449
450
  let didSaveToTmpPath = false;
@@ -515,6 +516,7 @@ const prepareStream = async (media, mediaType, { logger, saveOriginalFileIfRequi
515
516
  exports.prepareStream = prepareStream;
516
517
  const encryptedStream = async (media, mediaType, { logger, saveOriginalFileIfRequired, opts, isPtt, forceOpus } = {}) => {
517
518
  const { stream, type, spilledPath } = await (0, exports.getStream)(media, opts);
519
+ media = undefined; // Help GC
518
520
  let finalStream = stream;
519
521
  let opusConverted = false;
520
522
  let opusSpillPath;
@@ -826,11 +828,14 @@ const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options },
826
828
 
827
829
 
828
830
 
831
+ if (streamPath && stream && typeof stream.destroy === 'function') {
832
+ stream.destroy();
833
+ }
829
834
  const reqBody = streamPath ? createReadStream(streamPath) : stream;
830
835
 
831
836
  let result;
832
837
  try {
833
- const bodyLength = fileLength || (streamPath ? (await fs_1.promises.stat(streamPath)).size : (Buffer.isBuffer(reqBody) ? reqBody.length : 0));
838
+ const bodyLength = fileLength || (streamPath ? (await fs_1.promises.stat(streamPath)).size : (Buffer.isBuffer(reqBody) ? reqBody.length : (stream.size || 0)));
834
839
  if (maxContentLengthBytes && bodyLength > maxContentLengthBytes) {
835
840
  throw new boom_1.Boom(`Body too large for "${hostname}" (${bodyLength} > ${maxContentLengthBytes})`, { statusCode: 413 });
836
841
  }
@@ -869,7 +874,7 @@ const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, options },
869
874
  result = (_a = error.response) === null || _a === void 0 ? void 0 : _a.data;
870
875
  }
871
876
  const isLast = hostname === ((_b = hosts[hosts.length - 1]) === null || _b === void 0 ? void 0 : _b.hostname);
872
- logger.warn({ trace: error.stack, uploadResult: result, message: error.message }, `Error in uploading to ${hostname} ${isLast ? '' : ', retrying...'}`);
877
+ logger.warn({ trace: error.stack, uploadResult: result, message: error.message, statusCode: error.response?.status }, `Error in uploading to ${hostname} ${isLast ? '' : ', retrying...'}`);
873
878
  }
874
879
  }
875
880
  if (!urls) {
@@ -149,7 +149,10 @@ const prepareWAMessageMedia = async (message, options) => {
149
149
  const requiresAudioBackground = options.backgroundColor && mediaType === 'audio' && uploadData.ptt === true;
150
150
  const requiresOriginalForSomeProcessing = requiresDurationComputation || requiresThumbnailComputation;
151
151
 
152
- const { mediaKey, encWriteStream, bodyPath, streamPath, spilledPath, fileEncSha256, fileSha256, fileLength, didSaveToTmpPath, opusConverted } = await (options.newsletter ? messages_media_1.prepareStream : messages_media_1.encryptedStream)(uploadData.media, options.mediaTypeOverride || mediaType, {
152
+ const media = uploadData.media;
153
+ uploadData.media = undefined;
154
+
155
+ const { mediaKey, encWriteStream, bodyPath, streamPath, spilledPath, fileEncSha256, fileSha256, fileLength, didSaveToTmpPath, opusConverted } = await (options.newsletter ? messages_media_1.prepareStream : messages_media_1.encryptedStream)(media, options.mediaTypeOverride || mediaType, {
153
156
  logger,
154
157
  saveOriginalFileIfRequired: requiresOriginalForSomeProcessing,
155
158
  opts: options.options,
@@ -157,9 +160,6 @@ const prepareWAMessageMedia = async (message, options) => {
157
160
  forceOpus: (mediaType === "audio" && uploadData.mimetype && uploadData.mimetype.includes('opus'))
158
161
  });
159
162
 
160
- // Nullify the media reference to help GC free the memory if it's a large Buffer
161
- uploadData.media = undefined;
162
-
163
163
  if (mediaType === 'audio' && opusConverted) {
164
164
  uploadData.mimetype = 'audio/ogg; codecs=opus';
165
165
  }
@@ -22,7 +22,8 @@ const jidDecode = (jid) => {
22
22
  return {
23
23
  server,
24
24
  user,
25
- domainType: server === 'lid' ? 1 : 0,
25
+
26
+ domainType: (server === 'lid' || server === 'hosted.lid') ? 1 : 0,
26
27
  device: device ? +device : undefined
27
28
  };
28
29
  };
@@ -36,8 +37,8 @@ exports.areJidsSameUser = areJidsSameUser;
36
37
  /** is the jid a user */
37
38
  const isJidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@s.whatsapp.net'));
38
39
  exports.isJidUser = isJidUser;
39
- /** is the jid a group */
40
- const isLidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@lid'));
40
+ /** is the jid a user */
41
+ const isLidUser = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@lid') || jid.endsWith('@hosted.lid'));
41
42
  exports.isLidUser = isLidUser;
42
43
  /** is the jid a broadcast */
43
44
  const isJidBroadcast = (jid) => (jid === null || jid === void 0 ? void 0 : jid.endsWith('@broadcast'));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amiudmodz",
3
- "version": "5.1.2",
3
+ "version": "5.1.5",
4
4
  "description": "WhatsApp Baileys mod Powered by UDMODZ",
5
5
  "keywords": [
6
6
  "whatsapp",
@@ -44,7 +44,7 @@
44
44
  "chalk": "^4.1.2",
45
45
  "futoin-hkdf": "^1.5.1",
46
46
  "libphonenumber-js": "^1.10.20",
47
- "libsignal": "git+https://github.com/xhclintohn/libsignal-node",
47
+ "libsignal": "git+https://github.com/xhclintohn/libsignal-node.git",
48
48
  "lodash": "^4.17.21",
49
49
  "lru-cache": "^11.1.0",
50
50
  "music-metadata": "^11.12.3",
@@ -106,4 +106,4 @@
106
106
  "engines": {
107
107
  "node": ">=20.0.0"
108
108
  }
109
- }
109
+ }