Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
163b11aa36 | ||
|
|
f4171a9086 | ||
|
|
dfbae9c71e | ||
|
|
91caa7ba25 | ||
|
|
2ac57bb6c3 | ||
|
|
e01647eb48 | ||
|
|
90bc05ecf3 | ||
|
|
21998cbfae | ||
|
|
87c49a8766 | ||
|
|
4e78d559a8 | ||
|
|
18ce902c60 |
No files matched your search
+1
-1
@@ -1,4 +1,4 @@
|
||||
ARG NODE_IMAGE_TAG=22.16-bookworm-slim
|
||||
ARG NODE_IMAGE_TAG=24.11-bookworm-slim
|
||||
ARG GOLANG_IMAGE_TAG=1.24-bookworm
|
||||
|
||||
#
|
||||
|
||||
@@ -70,16 +70,6 @@ else
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Enable CPU profiling
|
||||
#
|
||||
if [ "$WAHA_DEBUG_MODE" = "true" ] || [ "$WAHA_DEBUG_MODE" = "True" ] || [ "$WAHA_DEBUG_MODE" = "1" ]; then
|
||||
case " $NODE_OPTIONS " in
|
||||
*" --cpu-prof "*) ;;
|
||||
*) export NODE_OPTIONS="${NODE_OPTIONS:+$NODE_OPTIONS }--cpu-prof" ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
#
|
||||
# Start your application using node with exec to ensure proper signal handling
|
||||
#
|
||||
|
||||
+2
-1
@@ -70,7 +70,7 @@
|
||||
"express-basic-auth": "^1.2.1",
|
||||
"file-type": "16.5.4",
|
||||
"fs-extra": "^11.2.0",
|
||||
"google-protobuf": "^4.0.1",
|
||||
"google-protobuf": "^3.21.4",
|
||||
"https-proxy-agent": "^7.0.0",
|
||||
"ical.js": "^2.2.1",
|
||||
"ioredis": "^5",
|
||||
@@ -106,6 +106,7 @@
|
||||
"swagger-ui-express": "^4.1.4",
|
||||
"ulid": "^2.3.0",
|
||||
"undici": "^7.16.0",
|
||||
"uniqid": "^5.4.0",
|
||||
"whatsapp-web.js": "github:devlikeapro/whatsapp-web.js#fork-main-2025-11-05",
|
||||
"write-file-atomic": "^6.0.0",
|
||||
"yaml": "^2.7.1"
|
||||
|
||||
@@ -181,7 +181,7 @@ export abstract class WhatsappSession {
|
||||
public name: string;
|
||||
protected mediaManager: IMediaManager;
|
||||
public loggerBuilder: LoggerBuilder;
|
||||
protected logger: Logger;
|
||||
public logger: Logger;
|
||||
protected sessionStore: DataStore;
|
||||
protected proxyConfig?: ProxyConfig;
|
||||
public sessionConfig?: SessionConfig;
|
||||
|
||||
@@ -7,13 +7,15 @@ let eventStreamClient: messages.EventStreamClient | null = null;
|
||||
export const MessageServiceClientSingleton = (
|
||||
address: string,
|
||||
credentials: grpc.ChannelCredentials,
|
||||
options?: grpc.ChannelOptions,
|
||||
): messages.MessageServiceClient => {
|
||||
if (!messageServiceClient) {
|
||||
messageServiceClient = new messages.MessageServiceClient(
|
||||
address,
|
||||
credentials,
|
||||
options,
|
||||
{
|
||||
'grpc.max_send_message_length': 128 * 1024 * 1024,
|
||||
'grpc.max_receive_message_length': 128 * 1024 * 1024,
|
||||
},
|
||||
);
|
||||
}
|
||||
return messageServiceClient;
|
||||
@@ -22,14 +24,12 @@ export const MessageServiceClientSingleton = (
|
||||
export const EventStreamClientSingleton = (
|
||||
address: string,
|
||||
credentials: grpc.ChannelCredentials,
|
||||
options?: grpc.ChannelOptions,
|
||||
): messages.EventStreamClient => {
|
||||
if (!eventStreamClient) {
|
||||
eventStreamClient = new messages.EventStreamClient(
|
||||
address,
|
||||
credentials,
|
||||
options,
|
||||
);
|
||||
eventStreamClient = new messages.EventStreamClient(address, credentials, {
|
||||
'grpc.max_send_message_length': 128 * 1024 * 1024,
|
||||
'grpc.max_receive_message_length': 128 * 1024 * 1024,
|
||||
});
|
||||
}
|
||||
return eventStreamClient;
|
||||
};
|
||||
@@ -2687,6 +2687,7 @@ export namespace messages {
|
||||
mimetype?: string;
|
||||
audio?: AudioInfo;
|
||||
filename?: string;
|
||||
contentPath?: string;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
@@ -2706,6 +2707,9 @@ export namespace messages {
|
||||
if ("filename" in data && data.filename != undefined) {
|
||||
this.filename = data.filename;
|
||||
}
|
||||
if ("contentPath" in data && data.contentPath != undefined) {
|
||||
this.contentPath = data.contentPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
get content() {
|
||||
@@ -2741,12 +2745,19 @@ export namespace messages {
|
||||
set filename(value: string) {
|
||||
pb_1.Message.setField(this, 5, value);
|
||||
}
|
||||
get contentPath() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 6, "") as string;
|
||||
}
|
||||
set contentPath(value: string) {
|
||||
pb_1.Message.setField(this, 6, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
content?: Uint8Array;
|
||||
type?: MediaType;
|
||||
mimetype?: string;
|
||||
audio?: ReturnType<typeof AudioInfo.prototype.toObject>;
|
||||
filename?: string;
|
||||
contentPath?: string;
|
||||
}): Media {
|
||||
const message = new Media({});
|
||||
if (data.content != null) {
|
||||
@@ -2764,6 +2775,9 @@ export namespace messages {
|
||||
if (data.filename != null) {
|
||||
message.filename = data.filename;
|
||||
}
|
||||
if (data.contentPath != null) {
|
||||
message.contentPath = data.contentPath;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
@@ -2773,6 +2787,7 @@ export namespace messages {
|
||||
mimetype?: string;
|
||||
audio?: ReturnType<typeof AudioInfo.prototype.toObject>;
|
||||
filename?: string;
|
||||
contentPath?: string;
|
||||
} = {};
|
||||
if (this.content != null) {
|
||||
data.content = this.content;
|
||||
@@ -2789,6 +2804,9 @@ export namespace messages {
|
||||
if (this.filename != null) {
|
||||
data.filename = this.filename;
|
||||
}
|
||||
if (this.contentPath != null) {
|
||||
data.contentPath = this.contentPath;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
@@ -2805,6 +2823,8 @@ export namespace messages {
|
||||
writer.writeMessage(4, this.audio, () => this.audio.serialize(writer));
|
||||
if (this.filename.length)
|
||||
writer.writeString(5, this.filename);
|
||||
if (this.contentPath.length)
|
||||
writer.writeString(6, this.contentPath);
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
@@ -2829,6 +2849,9 @@ export namespace messages {
|
||||
case 5:
|
||||
message.filename = reader.readString();
|
||||
break;
|
||||
case 6:
|
||||
message.contentPath = reader.readString();
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
@@ -7949,6 +7972,7 @@ export namespace messages {
|
||||
message?: string;
|
||||
jid?: string;
|
||||
messageId?: string;
|
||||
contentPath?: string;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
@@ -7965,6 +7989,9 @@ export namespace messages {
|
||||
if ("messageId" in data && data.messageId != undefined) {
|
||||
this.messageId = data.messageId;
|
||||
}
|
||||
if ("contentPath" in data && data.contentPath != undefined) {
|
||||
this.contentPath = data.contentPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
get session() {
|
||||
@@ -7994,11 +8021,18 @@ export namespace messages {
|
||||
set messageId(value: string) {
|
||||
pb_1.Message.setField(this, 4, value);
|
||||
}
|
||||
get contentPath() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 5, "") as string;
|
||||
}
|
||||
set contentPath(value: string) {
|
||||
pb_1.Message.setField(this, 5, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
session?: ReturnType<typeof Session.prototype.toObject>;
|
||||
message?: string;
|
||||
jid?: string;
|
||||
messageId?: string;
|
||||
contentPath?: string;
|
||||
}): DownloadMediaRequest {
|
||||
const message = new DownloadMediaRequest({});
|
||||
if (data.session != null) {
|
||||
@@ -8013,6 +8047,9 @@ export namespace messages {
|
||||
if (data.messageId != null) {
|
||||
message.messageId = data.messageId;
|
||||
}
|
||||
if (data.contentPath != null) {
|
||||
message.contentPath = data.contentPath;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
@@ -8021,6 +8058,7 @@ export namespace messages {
|
||||
message?: string;
|
||||
jid?: string;
|
||||
messageId?: string;
|
||||
contentPath?: string;
|
||||
} = {};
|
||||
if (this.session != null) {
|
||||
data.session = this.session.toObject();
|
||||
@@ -8034,6 +8072,9 @@ export namespace messages {
|
||||
if (this.messageId != null) {
|
||||
data.messageId = this.messageId;
|
||||
}
|
||||
if (this.contentPath != null) {
|
||||
data.contentPath = this.contentPath;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
@@ -8048,6 +8089,8 @@ export namespace messages {
|
||||
writer.writeString(3, this.jid);
|
||||
if (this.messageId.length)
|
||||
writer.writeString(4, this.messageId);
|
||||
if (this.contentPath.length)
|
||||
writer.writeString(5, this.contentPath);
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
@@ -8069,6 +8112,9 @@ export namespace messages {
|
||||
case 4:
|
||||
message.messageId = reader.readString();
|
||||
break;
|
||||
case 5:
|
||||
message.contentPath = reader.readString();
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
@@ -8085,6 +8131,7 @@ export namespace messages {
|
||||
#one_of_decls: number[][] = [];
|
||||
constructor(data?: any[] | {
|
||||
content?: Uint8Array;
|
||||
contentPath?: string;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
@@ -8092,6 +8139,9 @@ export namespace messages {
|
||||
if ("content" in data && data.content != undefined) {
|
||||
this.content = data.content;
|
||||
}
|
||||
if ("contentPath" in data && data.contentPath != undefined) {
|
||||
this.contentPath = data.contentPath;
|
||||
}
|
||||
}
|
||||
}
|
||||
get content() {
|
||||
@@ -8100,22 +8150,36 @@ export namespace messages {
|
||||
set content(value: Uint8Array) {
|
||||
pb_1.Message.setField(this, 1, value);
|
||||
}
|
||||
get contentPath() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 5, "") as string;
|
||||
}
|
||||
set contentPath(value: string) {
|
||||
pb_1.Message.setField(this, 5, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
content?: Uint8Array;
|
||||
contentPath?: string;
|
||||
}): DownloadMediaResponse {
|
||||
const message = new DownloadMediaResponse({});
|
||||
if (data.content != null) {
|
||||
message.content = data.content;
|
||||
}
|
||||
if (data.contentPath != null) {
|
||||
message.contentPath = data.contentPath;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
const data: {
|
||||
content?: Uint8Array;
|
||||
contentPath?: string;
|
||||
} = {};
|
||||
if (this.content != null) {
|
||||
data.content = this.content;
|
||||
}
|
||||
if (this.contentPath != null) {
|
||||
data.contentPath = this.contentPath;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
@@ -8124,6 +8188,8 @@ export namespace messages {
|
||||
const writer = w || new pb_1.BinaryWriter();
|
||||
if (this.content.length)
|
||||
writer.writeBytes(1, this.content);
|
||||
if (this.contentPath.length)
|
||||
writer.writeString(5, this.contentPath);
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
@@ -8136,6 +8202,9 @@ export namespace messages {
|
||||
case 1:
|
||||
message.content = reader.readBytes();
|
||||
break;
|
||||
case 5:
|
||||
message.contentPath = reader.readString();
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7115,7 +7115,8 @@ proto.messages.Media.toObject = function(includeInstance, msg) {
|
||||
type: jspb.Message.getFieldWithDefault(msg, 2, 0),
|
||||
mimetype: jspb.Message.getFieldWithDefault(msg, 3, ""),
|
||||
audio: (f = msg.getAudio()) && proto.messages.AudioInfo.toObject(includeInstance, f),
|
||||
filename: jspb.Message.getFieldWithDefault(msg, 5, "")
|
||||
filename: jspb.Message.getFieldWithDefault(msg, 5, ""),
|
||||
contentpath: jspb.Message.getFieldWithDefault(msg, 6, "")
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
@@ -7173,6 +7174,10 @@ proto.messages.Media.deserializeBinaryFromReader = function(msg, reader) {
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setFilename(value);
|
||||
break;
|
||||
case 6:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setContentpath(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
@@ -7238,6 +7243,13 @@ proto.messages.Media.serializeBinaryToWriter = function(message, writer) {
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getContentpath();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
6,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -7374,6 +7386,24 @@ proto.messages.Media.prototype.setFilename = function(value) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string contentPath = 6;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.messages.Media.prototype.getContentpath = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 6, ""));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @return {!proto.messages.Media} returns this
|
||||
*/
|
||||
proto.messages.Media.prototype.setContentpath = function(value) {
|
||||
return jspb.Message.setProto3StringField(this, 6, value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -16673,7 +16703,8 @@ proto.messages.DownloadMediaRequest.toObject = function(includeInstance, msg) {
|
||||
session: (f = msg.getSession()) && proto.messages.Session.toObject(includeInstance, f),
|
||||
message: jspb.Message.getFieldWithDefault(msg, 2, ""),
|
||||
jid: jspb.Message.getFieldWithDefault(msg, 3, ""),
|
||||
messageid: jspb.Message.getFieldWithDefault(msg, 4, "")
|
||||
messageid: jspb.Message.getFieldWithDefault(msg, 4, ""),
|
||||
contentpath: jspb.Message.getFieldWithDefault(msg, 5, "")
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
@@ -16727,6 +16758,10 @@ proto.messages.DownloadMediaRequest.deserializeBinaryFromReader = function(msg,
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setMessageid(value);
|
||||
break;
|
||||
case 5:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setContentpath(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
@@ -16785,6 +16820,13 @@ proto.messages.DownloadMediaRequest.serializeBinaryToWriter = function(message,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getContentpath();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
5,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -16879,6 +16921,24 @@ proto.messages.DownloadMediaRequest.prototype.setMessageid = function(value) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string contentPath = 5;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.messages.DownloadMediaRequest.prototype.getContentpath = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, ""));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @return {!proto.messages.DownloadMediaRequest} returns this
|
||||
*/
|
||||
proto.messages.DownloadMediaRequest.prototype.setContentpath = function(value) {
|
||||
return jspb.Message.setProto3StringField(this, 5, value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -16911,7 +16971,8 @@ proto.messages.DownloadMediaResponse.prototype.toObject = function(opt_includeIn
|
||||
*/
|
||||
proto.messages.DownloadMediaResponse.toObject = function(includeInstance, msg) {
|
||||
var f, obj = {
|
||||
content: msg.getContent_asB64()
|
||||
content: msg.getContent_asB64(),
|
||||
contentpath: jspb.Message.getFieldWithDefault(msg, 5, "")
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
@@ -16952,6 +17013,10 @@ proto.messages.DownloadMediaResponse.deserializeBinaryFromReader = function(msg,
|
||||
var value = /** @type {!Uint8Array} */ (reader.readBytes());
|
||||
msg.setContent(value);
|
||||
break;
|
||||
case 5:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setContentpath(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
@@ -16988,6 +17053,13 @@ proto.messages.DownloadMediaResponse.serializeBinaryToWriter = function(message,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getContentpath();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
5,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -17033,6 +17105,24 @@ proto.messages.DownloadMediaResponse.prototype.setContent = function(value) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string contentPath = 5;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.messages.DownloadMediaResponse.prototype.getContentpath = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, ""));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @return {!proto.messages.DownloadMediaResponse} returns this
|
||||
*/
|
||||
proto.messages.DownloadMediaResponse.prototype.setContentpath = function(value) {
|
||||
return jspb.Message.setProto3StringField(this, 5, value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -177,11 +177,14 @@ import {
|
||||
} from '@waha/core/engines/gows/clients';
|
||||
import esm from '@waha/vendor/esm';
|
||||
import { IsEditedMessage } from '@waha/core/utils/pwa';
|
||||
import MessageServiceClient = messages.MessageServiceClient;
|
||||
import { GoToJSWAProto } from '@waha/core/engines/gows/waproto';
|
||||
import { extractWALocation } from '@waha/core/engines/waproto/locaiton';
|
||||
import { extractVCards } from '@waha/core/engines/waproto/vcards';
|
||||
import { Activity } from '@waha/core/abc/activity';
|
||||
import { TmpDir } from '@waha/utils/tmpdir';
|
||||
import * as path from 'path';
|
||||
import MessageServiceClient = messages.MessageServiceClient;
|
||||
import * as fsp from 'fs/promises';
|
||||
|
||||
enum WhatsMeowEvent {
|
||||
CONNECTED = 'gows.ConnectedEventData',
|
||||
@@ -207,11 +210,6 @@ enum WhatsMeowEvent {
|
||||
POLL_VOTE_EVENT = 'gows.PollVoteEvent',
|
||||
}
|
||||
|
||||
const gRPCClientConfig = {
|
||||
'grpc.max_send_message_length': 512 * 1024 * 1024,
|
||||
'grpc.max_receive_message_length': 512 * 1024 * 1024,
|
||||
};
|
||||
|
||||
export interface GowsConfig {
|
||||
connection: string;
|
||||
}
|
||||
@@ -279,7 +277,6 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
|
||||
this.client = MessageServiceClientSingleton(
|
||||
this.engineConfig.connection,
|
||||
grpc.credentials.createInsecure(),
|
||||
gRPCClientConfig,
|
||||
);
|
||||
|
||||
try {
|
||||
@@ -309,7 +306,6 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
|
||||
const client = EventStreamClientSingleton(
|
||||
this.engineConfig.connection,
|
||||
grpc.credentials.createInsecure(),
|
||||
gRPCClientConfig,
|
||||
);
|
||||
const stream = client.StreamEvents(this.session);
|
||||
return { client, stream };
|
||||
@@ -2375,30 +2371,44 @@ export class GOWSEngineMediaProcessor implements IMediaEngineProcessor<any> {
|
||||
const mediaDownloadTimeoutMs = 600_000; // 10 minutes
|
||||
|
||||
const data = JSON.stringify(message.Message);
|
||||
const request = new messages.DownloadMediaRequest({
|
||||
// double "session" it's not a mistake here
|
||||
session: this.session.session,
|
||||
message: data,
|
||||
jid: message.Info.Chat,
|
||||
messageId: message.Info.ID,
|
||||
});
|
||||
|
||||
const opts = {
|
||||
deadline: new Date(Date.now() + mediaDownloadTimeoutMs),
|
||||
};
|
||||
const call = promisify(
|
||||
this.session.client.DownloadMedia.bind(this.session.client),
|
||||
const tmpdir = new TmpDir(
|
||||
this.session.logger,
|
||||
`waha-media-${this.session.name}-`,
|
||||
);
|
||||
try {
|
||||
const response = await call(request, opts);
|
||||
const obj = response.toObject();
|
||||
return Buffer.from(obj.content);
|
||||
} catch (err) {
|
||||
if (err?.code === grpc.status.DEADLINE_EXCEEDED) {
|
||||
err.message = `DownloadMedia timed out after ${mediaDownloadTimeoutMs}ms for message '${message?.Info?.ID}'`;
|
||||
return await tmpdir.use(async (dir) => {
|
||||
const file = path.join(dir, 'content.tmp');
|
||||
const request = new messages.DownloadMediaRequest({
|
||||
// double "session" it's not a mistake here
|
||||
session: this.session.session,
|
||||
message: data,
|
||||
jid: message.Info.Chat,
|
||||
messageId: message.Info.ID,
|
||||
contentPath: file,
|
||||
});
|
||||
|
||||
const opts = {
|
||||
deadline: new Date(Date.now() + mediaDownloadTimeoutMs),
|
||||
};
|
||||
const call = promisify(
|
||||
this.session.client.DownloadMedia.bind(this.session.client),
|
||||
);
|
||||
try {
|
||||
const response = await call(request, opts);
|
||||
const obj = response.toObject();
|
||||
if (!obj.contentPath) {
|
||||
// Read directly from grpc response
|
||||
return Buffer.from(obj.content);
|
||||
} else {
|
||||
// Read from the file
|
||||
return await fsp.readFile(obj.contentPath);
|
||||
}
|
||||
} catch (err) {
|
||||
if (err?.code === grpc.status.DEADLINE_EXCEEDED) {
|
||||
err.message = `DownloadMedia timed out after ${mediaDownloadTimeoutMs}ms for message '${message?.Info?.ID}'`;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getFilename(message: any): string | null {
|
||||
|
||||
@@ -9,8 +9,9 @@ import axios, { AxiosInstance } from 'axios';
|
||||
import axiosRetry, { retryAfter } from 'axios-retry';
|
||||
import * as crypto from 'crypto';
|
||||
import { Logger } from 'pino';
|
||||
import { ulid } from 'ulid';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const uniqid = require('uniqid');
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const HttpAgent = require('agentkeepalive');
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
@@ -71,6 +72,7 @@ export class WebhookSender {
|
||||
const ctx = {
|
||||
id: headers['X-Webhook-Request-Id'],
|
||||
['event.id']: json.id,
|
||||
event: json.event,
|
||||
url: this.url,
|
||||
};
|
||||
this.logger.info(ctx, `Sending POST...`);
|
||||
@@ -133,7 +135,9 @@ export class WebhookSender {
|
||||
retryCondition: (error) => true,
|
||||
onRetry: (retryCount, error, requestConfig) => {
|
||||
this.logger.warn(
|
||||
{ id: requestConfig.headers['X-Webhook-Request-Id'] },
|
||||
{
|
||||
id: requestConfig.headers['X-Webhook-Request-Id'],
|
||||
},
|
||||
`Error sending POST request: '${error.message}'. Retrying ${retryCount}/${attempts}...`,
|
||||
);
|
||||
},
|
||||
@@ -157,7 +161,7 @@ export class WebhookSender {
|
||||
const timestamp = json.timestamp?.toString() || Date.now().toString();
|
||||
return {
|
||||
// UUID, no '-' in it
|
||||
'X-Webhook-Request-Id': ulid(),
|
||||
'X-Webhook-Request-Id': uniqid(),
|
||||
// unix timestamp with ms
|
||||
'X-Webhook-Timestamp': timestamp,
|
||||
};
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ export function getWAHAVersion(): WAHAVersion {
|
||||
}
|
||||
|
||||
export const VERSION: WAHAEnvironment = {
|
||||
version: '2025.11.3',
|
||||
version: '2025.11.4',
|
||||
engine: getEngineName(),
|
||||
tier: getWAHAVersion(),
|
||||
browser:
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
"waha": {
|
||||
"gows": {
|
||||
"repo": "devlikeapro/gows",
|
||||
"ref": "v1.0.23"
|
||||
"ref": "v1.0.24"
|
||||
},
|
||||
"dashboard": {
|
||||
"repo": "devlikeapro/dashboard",
|
||||
|
||||
@@ -7279,10 +7279,10 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"google-protobuf@npm:^4.0.1":
|
||||
version: 4.0.1
|
||||
resolution: "google-protobuf@npm:4.0.1"
|
||||
checksum: d6ed3007b121ac28dbe9a686bdcc26ba4aba8bc41bd43bbaf59c2cbad96eba4d56338b9da56e8006fa89922eb5b15cb5c79f40b82d03ac39e006c9163435ad4b
|
||||
"google-protobuf@npm:^3.21.4":
|
||||
version: 3.21.4
|
||||
resolution: "google-protobuf@npm:3.21.4"
|
||||
checksum: 048fa2cb579f5f88c977774b2ae36851807379d9329a6895fe3685df69ba6c927e2ff463d08d5eecd56becd9c65bca406f34f90e27984a3077e8629bb3a2a766
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -12392,6 +12392,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"uniqid@npm:^5.4.0":
|
||||
version: 5.4.0
|
||||
resolution: "uniqid@npm:5.4.0"
|
||||
checksum: 69fc28e7b2b5b24227b4295e51aa7c1d4085a60655ad071db8fc350876cc9044d68ee0781c0d27c2c98691380aa418970e0d1b02a1e4564480f9d19b0dc1707b
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"unique-filename@npm:^1.1.1":
|
||||
version: 1.1.1
|
||||
resolution: "unique-filename@npm:1.1.1"
|
||||
@@ -12609,7 +12616,7 @@ __metadata:
|
||||
express-basic-auth: ^1.2.1
|
||||
file-type: 16.5.4
|
||||
fs-extra: ^11.2.0
|
||||
google-protobuf: ^4.0.1
|
||||
google-protobuf: ^3.21.4
|
||||
grpc-tools: ^1.13.0
|
||||
https-proxy-agent: ^7.0.0
|
||||
ical.js: ^2.2.1
|
||||
@@ -12656,6 +12663,7 @@ __metadata:
|
||||
typescript: 5.9.2
|
||||
ulid: ^2.3.0
|
||||
undici: ^7.16.0
|
||||
uniqid: ^5.4.0
|
||||
whatsapp-web.js: "github:devlikeapro/whatsapp-web.js#fork-main-2025-11-05"
|
||||
write-file-atomic: ^6.0.0
|
||||
yaml: ^2.7.1
|
||||
@@ -12759,7 +12767,7 @@ __metadata:
|
||||
|
||||
"whatsapp-web.js@github:devlikeapro/whatsapp-web.js#fork-main-2025-11-05":
|
||||
version: 1.34.2
|
||||
resolution: "whatsapp-web.js@https://github.com/devlikeapro/whatsapp-web.js.git#commit=06c56b6a693d438e38793cec150c2890ca59910f"
|
||||
resolution: "whatsapp-web.js@https://github.com/devlikeapro/whatsapp-web.js.git#commit=59a904a9a1f2869d39754117289267e0a925a7af"
|
||||
dependencies:
|
||||
"@pedroslopez/moduleraid": ^5.0.2
|
||||
archiver: ^5.3.1
|
||||
@@ -12777,7 +12785,7 @@ __metadata:
|
||||
optional: true
|
||||
unzipper:
|
||||
optional: true
|
||||
checksum: 46971900f209cb9988a8386ce13d9d082d7133711b1e6c38e1880684a70c1eda407be3c6fe45cd2526160efd47c2780b6b55500592ffc2b8c784f5e6c7d54670
|
||||
checksum: a59e4cee66a41f2a59d0340c4a765848f9fe76bdf4cfdd749c50deb5246f61bb8f9974fe4b35a7cc13d3adde6244975cea02caf72ca6e746b18b5d9c5c425b69
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
||||
Reference in new issue
Block a user