nishiki-bail 1.1.23 → 1.1.24

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.
@@ -98,7 +98,11 @@ export const NEWSLETTER_MEDIA_PATH_MAP = {
98
98
  video: '/newsletter/newsletter-video',
99
99
  document: '/newsletter/newsletter-document',
100
100
  audio: '/newsletter/newsletter-audio',
101
- sticker: '/newsletter/newsletter-sticker'
101
+ gif: '/newsletter/newsletter-gif',
102
+ ptt: '/newsletter/newsletter-ptt',
103
+ ptv: '/newsletter/newsletter-ptv',
104
+ sticker: '/newsletter/newsletter-sticker-pack',
105
+ 'thumbnail-link': '/newsletter/newsletter-image'
102
106
  };
103
107
  export const MEDIA_HKDF_KEY_MAPPING = {
104
108
  audio: 'Audio',
@@ -723,7 +723,7 @@ export const makeMessagesSocket = (config) => {
723
723
  const bytes = encodeNewsletterMessage(patched);
724
724
  binaryNodeContent.push({
725
725
  tag: 'plaintext',
726
- attrs: {},
726
+ attrs: mediaType ? { mediatype: mediaType } : {},
727
727
  content: bytes
728
728
  });
729
729
  const stanza = {
@@ -663,8 +663,13 @@ export const getWAUploadToServer = ({ customUploadHosts, fetchAgent, logger, opt
663
663
  logger.debug(`uploading to "${hostname}"`);
664
664
  const auth = encodeURIComponent(uploadInfo.auth);
665
665
  const mediaPath = (newsletter && NEWSLETTER_MEDIA_PATH_MAP[mediaType]) || MEDIA_PATH_MAP[mediaType];
666
- const serverThumbnail = newsletter ? '&server_thumb_gen=1' : '';
667
- const url = `https://${hostname}${mediaPath}/${fileEncSha256B64}?auth=${auth}&token=${fileEncSha256B64}${serverThumbnail}`;
666
+ let url = `https://${hostname}${mediaPath}/${fileEncSha256B64}?auth=${auth}&token=${fileEncSha256B64}`;
667
+ if (newsletter) {
668
+ url += '&server_thumb_gen=1';
669
+ if (mediaType === 'video' || mediaType === 'gif' || mediaType === 'ptv') {
670
+ url += '&server_transcode=1';
671
+ }
672
+ }
668
673
  let result;
669
674
  try {
670
675
  result = await uploadMedia({
@@ -101,7 +101,7 @@ export const prepareWAMessageMedia = async (message, options) => {
101
101
  logger?.info({ key: cacheableKey }, 'Preparing raw media for newsletter');
102
102
  const { filePath, fileSha256, fileLength } = await getRawMediaUploadData(uploadData.media, options.mediaTypeOverride || mediaType, logger);
103
103
  const fileSha256B64 = fileSha256.toString('base64');
104
- const { mediaUrl, directPath, thumbnailDirectPath, thumbnailSha256 } = await options.upload(filePath, {
104
+ const { directPath, thumbnailDirectPath, thumbnailSha256 } = await options.upload(filePath, {
105
105
  fileEncSha256B64: fileSha256B64,
106
106
  mediaType: mediaType,
107
107
  timeoutMs: options.mediaUploadTimeoutMs,
@@ -111,12 +111,11 @@ export const prepareWAMessageMedia = async (message, options) => {
111
111
  const obj = WAProto.Message.fromObject({
112
112
  // todo: add more support here
113
113
  [`${mediaType}Message`]: MessageTypeProto[mediaType].fromObject({
114
- url: mediaUrl || directPath,
115
114
  directPath,
116
115
  fileSha256,
117
116
  fileLength,
118
117
  thumbnailDirectPath,
119
- thumbnailSha256,
118
+ thumbnailSha256: thumbnailSha256 ? Buffer.from(thumbnailSha256, 'base64') : undefined,
120
119
  ...uploadData,
121
120
  media: undefined
122
121
  })
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nishiki-bail",
3
3
  "type": "module",
4
- "version": "1.1.23",
4
+ "version": "1.1.24",
5
5
  "description": "666",
6
6
  "keywords": [
7
7
  "whatsapp"