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.
package/lib/Defaults/index.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
667
|
-
|
|
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({
|
package/lib/Utils/messages.js
CHANGED
|
@@ -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 {
|
|
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
|
})
|