@queenanya/baileys 8.3.3 → 8.3.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.
- package/lib/Utils/index.d.ts +2 -1
- package/lib/Utils/index.js +2 -1
- package/lib/Utils/{midea-msg.d.ts → media-messages.d.ts} +4 -0
- package/lib/Utils/{midea-msg.js → media-messages.js} +31 -1
- package/lib/{Socket/chat-set.js → Utils/media-set.js} +3 -3
- package/package.json +1 -1
- /package/lib/{Socket/chat-set.d.ts → Utils/media-set.d.ts} +0 -0
package/lib/Utils/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './generics';
|
|
2
2
|
export * from './decode-wa-message';
|
|
3
3
|
export * from './messages';
|
|
4
|
+
export * from './media-messages';
|
|
5
|
+
export * from './media-set';
|
|
4
6
|
export * from './messages-media';
|
|
5
7
|
export * from './validate-connection';
|
|
6
8
|
export * from './crypto';
|
|
@@ -15,4 +17,3 @@ export * from './use-multi-file-auth-state';
|
|
|
15
17
|
export * from './link-preview';
|
|
16
18
|
export * from './event-buffer';
|
|
17
19
|
export * from './process-message';
|
|
18
|
-
export * from './midea-msg';
|
package/lib/Utils/index.js
CHANGED
|
@@ -17,6 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
__exportStar(require("./generics"), exports);
|
|
18
18
|
__exportStar(require("./decode-wa-message"), exports);
|
|
19
19
|
__exportStar(require("./messages"), exports);
|
|
20
|
+
__exportStar(require("./media-messages"), exports);
|
|
21
|
+
__exportStar(require("./media-set"), exports);
|
|
20
22
|
__exportStar(require("./messages-media"), exports);
|
|
21
23
|
__exportStar(require("./validate-connection"), exports);
|
|
22
24
|
__exportStar(require("./crypto"), exports);
|
|
@@ -31,4 +33,3 @@ __exportStar(require("./use-multi-file-auth-state"), exports);
|
|
|
31
33
|
__exportStar(require("./link-preview"), exports);
|
|
32
34
|
__exportStar(require("./event-buffer"), exports);
|
|
33
35
|
__exportStar(require("./process-message"), exports);
|
|
34
|
-
__exportStar(require("./midea-msg"), exports);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { WAMediaUpload } from '../Types';
|
|
1
2
|
export declare const generateProfilePictureFull: (img: any) => Promise<{
|
|
2
3
|
img: Buffer<ArrayBufferLike>;
|
|
3
4
|
}>;
|
|
@@ -9,6 +10,9 @@ export declare const generatePP: (buffer: any) => Promise<{
|
|
|
9
10
|
img: Buffer<ArrayBufferLike>;
|
|
10
11
|
preview: Buffer<ArrayBufferLike>;
|
|
11
12
|
}>;
|
|
13
|
+
export declare const generateProfilePicturee: (mediaUpload: WAMediaUpload) => Promise<{
|
|
14
|
+
img: Buffer<ArrayBufferLike>;
|
|
15
|
+
}>;
|
|
12
16
|
export declare const changeprofileFull: (img: any) => Promise<{
|
|
13
17
|
img: any;
|
|
14
18
|
}>;
|
|
@@ -3,9 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.changeprofileFull = exports.generatePP = exports.generateProfilePictureFP = exports.generateProfilePictureFull = void 0;
|
|
6
|
+
exports.changeprofileFull = exports.generateProfilePicturee = exports.generatePP = exports.generateProfilePictureFP = exports.generateProfilePictureFull = void 0;
|
|
7
7
|
const jimp_1 = __importDefault(require("jimp"));
|
|
8
8
|
const jimp_2 = require("jimp");
|
|
9
|
+
const toBuffer = async (stream) => {
|
|
10
|
+
const chunks = [];
|
|
11
|
+
for await (const chunk of stream) {
|
|
12
|
+
chunks.push(chunk);
|
|
13
|
+
}
|
|
14
|
+
stream.destroy();
|
|
15
|
+
return Buffer.concat(chunks);
|
|
16
|
+
};
|
|
9
17
|
const generateProfilePictureFull = async (img) => {
|
|
10
18
|
const jimp = await (0, jimp_2.read)(img);
|
|
11
19
|
const min = Math.min(jimp.getWidth(), jimp.getHeight());
|
|
@@ -48,6 +56,28 @@ const generatePP = async (buffer) => {
|
|
|
48
56
|
};
|
|
49
57
|
};
|
|
50
58
|
exports.generatePP = generatePP;
|
|
59
|
+
const generateProfilePicturee = async (mediaUpload) => {
|
|
60
|
+
let bufferOrFilePath;
|
|
61
|
+
let img;
|
|
62
|
+
if (Buffer.isBuffer(mediaUpload)) {
|
|
63
|
+
bufferOrFilePath = mediaUpload;
|
|
64
|
+
}
|
|
65
|
+
else if ('url' in mediaUpload) {
|
|
66
|
+
bufferOrFilePath = mediaUpload.url.toString();
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
bufferOrFilePath = await toBuffer(mediaUpload.stream);
|
|
70
|
+
}
|
|
71
|
+
const jimp = await jimp_1.default.read(bufferOrFilePath);
|
|
72
|
+
const cropped = jimp.getWidth() > jimp.getHeight() ? jimp.resize(720, -1) : jimp.resize(-1, 720);
|
|
73
|
+
img = cropped
|
|
74
|
+
.quality(100)
|
|
75
|
+
.getBufferAsync(jimp_1.default.MIME_JPEG);
|
|
76
|
+
return {
|
|
77
|
+
img: await img,
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
exports.generateProfilePicturee = generateProfilePicturee;
|
|
51
81
|
const changeprofileFull = async (img) => {
|
|
52
82
|
const Jimp = require('jimp');
|
|
53
83
|
const { read, MIME_JPEG, RESIZE_BILINEAR } = require('jimp');
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.updateProfilePictureFull2 = exports.updateProfilePictureFull = void 0;
|
|
4
4
|
const boom_1 = require("@hapi/boom");
|
|
5
5
|
const WABinary_1 = require("../WABinary");
|
|
6
|
-
const
|
|
6
|
+
const media_messages_1 = require("./media-messages");
|
|
7
7
|
/** update the profile picture for yourself or a group as Full */
|
|
8
8
|
const updateProfilePictureFull = async (jid, content, sock) => {
|
|
9
9
|
const { authState, query } = sock;
|
|
@@ -14,7 +14,7 @@ const updateProfilePictureFull = async (jid, content, sock) => {
|
|
|
14
14
|
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
|
15
15
|
targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
|
|
16
16
|
}
|
|
17
|
-
const { img } = await (0,
|
|
17
|
+
const { img } = await (0, media_messages_1.generateProfilePictureFP)(content);
|
|
18
18
|
await query({
|
|
19
19
|
tag: 'iq',
|
|
20
20
|
attrs: {
|
|
@@ -42,7 +42,7 @@ const updateProfilePictureFull2 = async (jid, content, sock) => {
|
|
|
42
42
|
if ((0, WABinary_1.jidNormalizedUser)(jid) !== (0, WABinary_1.jidNormalizedUser)(authState.creds.me.id)) {
|
|
43
43
|
targetJid = (0, WABinary_1.jidNormalizedUser)(jid); // in case it is someone other than us
|
|
44
44
|
}
|
|
45
|
-
const { preview } = await (0,
|
|
45
|
+
const { preview } = await (0, media_messages_1.generatePP)(content);
|
|
46
46
|
await query({
|
|
47
47
|
tag: 'iq',
|
|
48
48
|
attrs: {
|
package/package.json
CHANGED
|
File without changes
|