Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ec94dc13c | ||
|
|
6b11e08f3d | ||
|
|
e884e56b47 | ||
|
|
2d74affed4 | ||
|
|
3572b17049 | ||
|
|
4ee7091cd1 | ||
|
|
ff5e89d97c | ||
|
|
c4e82afc0c | ||
|
|
52c5d85487 | ||
|
|
fd0438f80b | ||
|
|
cb5781ca65 | ||
|
|
4d8aad9dfe | ||
|
|
39429a2e44 | ||
|
|
0a3514d81e | ||
|
|
4e5e0a7c34 | ||
|
|
f6cc6a9bef | ||
|
|
2e545e9fb9 | ||
|
|
d49ef64e7e | ||
|
|
b1e6eaef90 | ||
|
|
3420d0199b | ||
|
|
671db35571 | ||
|
|
d724f87726 | ||
|
|
5ab8565205 | ||
|
|
660c567d1b | ||
|
|
2c68d13c56 | ||
|
|
b9fc155b4f | ||
|
|
8dd5aefc81 | ||
|
|
f9aaf5dcef | ||
|
|
34a6e773df | ||
|
|
f0beb03344 | ||
|
|
1ff9a81ab3 |
No files matched your search
@@ -1,9 +1,10 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: '[BUG][WEBJS] - '
|
||||
title: '[WEBJS] - '
|
||||
labels: bug
|
||||
assignees: ''
|
||||
type: 'BUG'
|
||||
---
|
||||
|
||||
### Describe the bug
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: '[Feature Request]'
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
type: 'Feature'
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.** I'm always
|
||||
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
SessionApiParam,
|
||||
WorkingSessionParam,
|
||||
} from '@waha/nestjs/params/SessionApiParam';
|
||||
import { Result } from '@waha/structures/base.dto';
|
||||
import { CountResponse, Result } from '@waha/structures/base.dto';
|
||||
import {
|
||||
ChatPictureQuery,
|
||||
ChatPictureResponse,
|
||||
@@ -94,6 +94,20 @@ export class GroupsController {
|
||||
return groups;
|
||||
}
|
||||
|
||||
@Get('/count')
|
||||
@SessionApiParam
|
||||
@ApiOperation({ summary: 'Get the number of groups.' })
|
||||
@UsePipes(new ValidationPipe({ transform: true, whitelist: true }))
|
||||
async getGroupsCount(
|
||||
@WorkingSessionParam session: WhatsappSession,
|
||||
): Promise<CountResponse> {
|
||||
const data: any = await session.getGroups({});
|
||||
const groups: any[] = Array.isArray(data) ? data : Object.values(data);
|
||||
return {
|
||||
count: groups.length,
|
||||
};
|
||||
}
|
||||
|
||||
@Post('refresh')
|
||||
@HttpCode(HttpStatus.OK)
|
||||
@SessionApiParam
|
||||
|
||||
@@ -218,11 +218,14 @@ export function populateSessionInfo(
|
||||
) {
|
||||
return (payload: any): WAHAWebhook => {
|
||||
const id = payload._eventId;
|
||||
const timestampMs = payload._timestampMs;
|
||||
const data = { ...payload };
|
||||
delete data._eventId;
|
||||
delete data._timestampMs;
|
||||
const me = session.getSessionMeInfo();
|
||||
return {
|
||||
id: id,
|
||||
timestamp: timestampMs,
|
||||
event: event,
|
||||
session: session.name,
|
||||
metadata: session.sessionConfig?.metadata,
|
||||
|
||||
@@ -18,7 +18,7 @@ import { SendButtonsRequest } from '@waha/structures/chatting.buttons.dto';
|
||||
import { BinaryFile, RemoteFile } from '@waha/structures/files.dto';
|
||||
import { Label, LabelDTO, LabelID } from '@waha/structures/labels.dto';
|
||||
import { PaginationParams } from '@waha/structures/pagination.dto';
|
||||
import { WAMessage } from '@waha/structures/responses.dto';
|
||||
import { MessageSource, WAMessage } from '@waha/structures/responses.dto';
|
||||
import { DefaultMap } from '@waha/utils/DefaultMap';
|
||||
import { generatePrefixedId } from '@waha/utils/ids';
|
||||
import { LoggerBuilder } from '@waha/utils/logging';
|
||||
@@ -26,7 +26,6 @@ import { complete } from '@waha/utils/reactive/complete';
|
||||
import { SwitchObservable } from '@waha/utils/reactive/SwitchObservable';
|
||||
import * as fs from 'fs';
|
||||
import * as lodash from 'lodash';
|
||||
import { PinoLogger } from 'nestjs-pino';
|
||||
import * as NodeCache from 'node-cache';
|
||||
import { Logger } from 'pino';
|
||||
import {
|
||||
@@ -73,7 +72,6 @@ import {
|
||||
CreateGroupRequest,
|
||||
GroupField,
|
||||
GroupsListFields,
|
||||
GroupsPaginationParams,
|
||||
ParticipantsRequest,
|
||||
SettingsSecurityChangeInfo,
|
||||
} from '../../structures/groups.dto';
|
||||
@@ -148,6 +146,12 @@ export abstract class WhatsappSession {
|
||||
stdTTL: 24 * 60 * 60, // 1 day
|
||||
});
|
||||
|
||||
// Save sent messages ids in cache so we can determine if a message was sent
|
||||
// via API or APP
|
||||
private sentMessageIds: NodeCache = new NodeCache({
|
||||
stdTTL: 10 * 60, // 10 minutes
|
||||
});
|
||||
|
||||
public constructor({
|
||||
name,
|
||||
printQR,
|
||||
@@ -178,6 +182,7 @@ export abstract class WhatsappSession {
|
||||
filter(Boolean),
|
||||
map((data) => {
|
||||
data._eventId = generatePrefixedId('evt');
|
||||
data._timestampMs = Date.now();
|
||||
return data;
|
||||
}),
|
||||
retry(),
|
||||
@@ -884,6 +889,18 @@ export abstract class WhatsappSession {
|
||||
);
|
||||
qrcode.generate(qr.raw, { small: true });
|
||||
}
|
||||
|
||||
protected saveSentMessageId(id: string) {
|
||||
this.sentMessageIds.set(id, true);
|
||||
}
|
||||
|
||||
protected getMessageSource(id: string): MessageSource {
|
||||
if (!id) {
|
||||
return MessageSource.APP;
|
||||
}
|
||||
const api = this.sentMessageIds.has(id);
|
||||
return api ? MessageSource.API : MessageSource.APP;
|
||||
}
|
||||
}
|
||||
|
||||
export function isNewsletter(jid: string) {
|
||||
@@ -915,3 +932,19 @@ export function parseChannelInviteLink(link: string): string {
|
||||
export function getPublicUrlFromDirectPath(directPath: string) {
|
||||
return `https://pps.whatsapp.net${directPath}`;
|
||||
}
|
||||
|
||||
const deviceRegexp = /^.*:(\d+)@.*$/;
|
||||
|
||||
/**
|
||||
* Extracts the device ID from a JID string.
|
||||
*
|
||||
* @param jid - The JID string (e.g., "123123:12@c.us")
|
||||
* @return The extracted device ID (e.g., "12") or null if the format is invalid.
|
||||
*/
|
||||
export function extractDeviceId(jid: string): string | null {
|
||||
if (!jid) {
|
||||
return null;
|
||||
}
|
||||
const match = jid.match(deviceRegexp);
|
||||
return match ? match[1] : null;
|
||||
}
|
||||
@@ -2380,6 +2380,7 @@ export namespace messages {
|
||||
type?: MediaType;
|
||||
mimetype?: string;
|
||||
audio?: AudioInfo;
|
||||
filename?: string;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
@@ -2396,6 +2397,9 @@ export namespace messages {
|
||||
if ("audio" in data && data.audio != undefined) {
|
||||
this.audio = data.audio;
|
||||
}
|
||||
if ("filename" in data && data.filename != undefined) {
|
||||
this.filename = data.filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
get content() {
|
||||
@@ -2425,11 +2429,18 @@ export namespace messages {
|
||||
get has_audio() {
|
||||
return pb_1.Message.getField(this, 4) != null;
|
||||
}
|
||||
get filename() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 5, "") as string;
|
||||
}
|
||||
set filename(value: string) {
|
||||
pb_1.Message.setField(this, 5, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
content?: Uint8Array;
|
||||
type?: MediaType;
|
||||
mimetype?: string;
|
||||
audio?: ReturnType<typeof AudioInfo.prototype.toObject>;
|
||||
filename?: string;
|
||||
}): Media {
|
||||
const message = new Media({});
|
||||
if (data.content != null) {
|
||||
@@ -2444,6 +2455,9 @@ export namespace messages {
|
||||
if (data.audio != null) {
|
||||
message.audio = AudioInfo.fromObject(data.audio);
|
||||
}
|
||||
if (data.filename != null) {
|
||||
message.filename = data.filename;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
@@ -2452,6 +2466,7 @@ export namespace messages {
|
||||
type?: MediaType;
|
||||
mimetype?: string;
|
||||
audio?: ReturnType<typeof AudioInfo.prototype.toObject>;
|
||||
filename?: string;
|
||||
} = {};
|
||||
if (this.content != null) {
|
||||
data.content = this.content;
|
||||
@@ -2465,6 +2480,9 @@ export namespace messages {
|
||||
if (this.audio != null) {
|
||||
data.audio = this.audio.toObject();
|
||||
}
|
||||
if (this.filename != null) {
|
||||
data.filename = this.filename;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
@@ -2479,6 +2497,8 @@ export namespace messages {
|
||||
writer.writeString(3, this.mimetype);
|
||||
if (this.has_audio)
|
||||
writer.writeMessage(4, this.audio, () => this.audio.serialize(writer));
|
||||
if (this.filename.length)
|
||||
writer.writeString(5, this.filename);
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
@@ -2500,6 +2520,9 @@ export namespace messages {
|
||||
case 4:
|
||||
reader.readMessage(message.audio, () => message.audio = AudioInfo.deserialize(reader));
|
||||
break;
|
||||
case 5:
|
||||
message.filename = reader.readString();
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
@@ -2521,6 +2544,9 @@ export namespace messages {
|
||||
media?: Media;
|
||||
backgroundColor?: OptionalString;
|
||||
font?: OptionalUInt32;
|
||||
linkPreview?: boolean;
|
||||
linkPreviewHighQuality?: boolean;
|
||||
replyTo?: string;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
@@ -2543,6 +2569,15 @@ export namespace messages {
|
||||
if ("font" in data && data.font != undefined) {
|
||||
this.font = data.font;
|
||||
}
|
||||
if ("linkPreview" in data && data.linkPreview != undefined) {
|
||||
this.linkPreview = data.linkPreview;
|
||||
}
|
||||
if ("linkPreviewHighQuality" in data && data.linkPreviewHighQuality != undefined) {
|
||||
this.linkPreviewHighQuality = data.linkPreviewHighQuality;
|
||||
}
|
||||
if ("replyTo" in data && data.replyTo != undefined) {
|
||||
this.replyTo = data.replyTo;
|
||||
}
|
||||
}
|
||||
}
|
||||
get session() {
|
||||
@@ -2593,6 +2628,24 @@ export namespace messages {
|
||||
get has_font() {
|
||||
return pb_1.Message.getField(this, 6) != null;
|
||||
}
|
||||
get linkPreview() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 7, false) as boolean;
|
||||
}
|
||||
set linkPreview(value: boolean) {
|
||||
pb_1.Message.setField(this, 7, value);
|
||||
}
|
||||
get linkPreviewHighQuality() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 8, false) as boolean;
|
||||
}
|
||||
set linkPreviewHighQuality(value: boolean) {
|
||||
pb_1.Message.setField(this, 8, value);
|
||||
}
|
||||
get replyTo() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 9, "") as string;
|
||||
}
|
||||
set replyTo(value: string) {
|
||||
pb_1.Message.setField(this, 9, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
session?: ReturnType<typeof Session.prototype.toObject>;
|
||||
jid?: string;
|
||||
@@ -2600,6 +2653,9 @@ export namespace messages {
|
||||
media?: ReturnType<typeof Media.prototype.toObject>;
|
||||
backgroundColor?: ReturnType<typeof OptionalString.prototype.toObject>;
|
||||
font?: ReturnType<typeof OptionalUInt32.prototype.toObject>;
|
||||
linkPreview?: boolean;
|
||||
linkPreviewHighQuality?: boolean;
|
||||
replyTo?: string;
|
||||
}): MessageRequest {
|
||||
const message = new MessageRequest({});
|
||||
if (data.session != null) {
|
||||
@@ -2620,6 +2676,15 @@ export namespace messages {
|
||||
if (data.font != null) {
|
||||
message.font = OptionalUInt32.fromObject(data.font);
|
||||
}
|
||||
if (data.linkPreview != null) {
|
||||
message.linkPreview = data.linkPreview;
|
||||
}
|
||||
if (data.linkPreviewHighQuality != null) {
|
||||
message.linkPreviewHighQuality = data.linkPreviewHighQuality;
|
||||
}
|
||||
if (data.replyTo != null) {
|
||||
message.replyTo = data.replyTo;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
@@ -2630,6 +2695,9 @@ export namespace messages {
|
||||
media?: ReturnType<typeof Media.prototype.toObject>;
|
||||
backgroundColor?: ReturnType<typeof OptionalString.prototype.toObject>;
|
||||
font?: ReturnType<typeof OptionalUInt32.prototype.toObject>;
|
||||
linkPreview?: boolean;
|
||||
linkPreviewHighQuality?: boolean;
|
||||
replyTo?: string;
|
||||
} = {};
|
||||
if (this.session != null) {
|
||||
data.session = this.session.toObject();
|
||||
@@ -2649,6 +2717,15 @@ export namespace messages {
|
||||
if (this.font != null) {
|
||||
data.font = this.font.toObject();
|
||||
}
|
||||
if (this.linkPreview != null) {
|
||||
data.linkPreview = this.linkPreview;
|
||||
}
|
||||
if (this.linkPreviewHighQuality != null) {
|
||||
data.linkPreviewHighQuality = this.linkPreviewHighQuality;
|
||||
}
|
||||
if (this.replyTo != null) {
|
||||
data.replyTo = this.replyTo;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
@@ -2667,6 +2744,12 @@ export namespace messages {
|
||||
writer.writeMessage(5, this.backgroundColor, () => this.backgroundColor.serialize(writer));
|
||||
if (this.has_font)
|
||||
writer.writeMessage(6, this.font, () => this.font.serialize(writer));
|
||||
if (this.linkPreview != false)
|
||||
writer.writeBool(7, this.linkPreview);
|
||||
if (this.linkPreviewHighQuality != false)
|
||||
writer.writeBool(8, this.linkPreviewHighQuality);
|
||||
if (this.replyTo.length)
|
||||
writer.writeString(9, this.replyTo);
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
@@ -2694,6 +2777,15 @@ export namespace messages {
|
||||
case 6:
|
||||
reader.readMessage(message.font, () => message.font = OptionalUInt32.deserialize(reader));
|
||||
break;
|
||||
case 7:
|
||||
message.linkPreview = reader.readBool();
|
||||
break;
|
||||
case 8:
|
||||
message.linkPreviewHighQuality = reader.readBool();
|
||||
break;
|
||||
case 9:
|
||||
message.replyTo = reader.readString();
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
@@ -2873,6 +2965,7 @@ export namespace messages {
|
||||
constructor(data?: any[] | {
|
||||
id?: string;
|
||||
timestamp?: number;
|
||||
message?: Json;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
@@ -2883,6 +2976,9 @@ export namespace messages {
|
||||
if ("timestamp" in data && data.timestamp != undefined) {
|
||||
this.timestamp = data.timestamp;
|
||||
}
|
||||
if ("message" in data && data.message != undefined) {
|
||||
this.message = data.message;
|
||||
}
|
||||
}
|
||||
}
|
||||
get id() {
|
||||
@@ -2897,9 +2993,19 @@ export namespace messages {
|
||||
set timestamp(value: number) {
|
||||
pb_1.Message.setField(this, 2, value);
|
||||
}
|
||||
get message() {
|
||||
return pb_1.Message.getWrapperField(this, Json, 3) as Json;
|
||||
}
|
||||
set message(value: Json) {
|
||||
pb_1.Message.setWrapperField(this, 3, value);
|
||||
}
|
||||
get has_message() {
|
||||
return pb_1.Message.getField(this, 3) != null;
|
||||
}
|
||||
static fromObject(data: {
|
||||
id?: string;
|
||||
timestamp?: number;
|
||||
message?: ReturnType<typeof Json.prototype.toObject>;
|
||||
}): MessageResponse {
|
||||
const message = new MessageResponse({});
|
||||
if (data.id != null) {
|
||||
@@ -2908,12 +3014,16 @@ export namespace messages {
|
||||
if (data.timestamp != null) {
|
||||
message.timestamp = data.timestamp;
|
||||
}
|
||||
if (data.message != null) {
|
||||
message.message = Json.fromObject(data.message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
const data: {
|
||||
id?: string;
|
||||
timestamp?: number;
|
||||
message?: ReturnType<typeof Json.prototype.toObject>;
|
||||
} = {};
|
||||
if (this.id != null) {
|
||||
data.id = this.id;
|
||||
@@ -2921,6 +3031,9 @@ export namespace messages {
|
||||
if (this.timestamp != null) {
|
||||
data.timestamp = this.timestamp;
|
||||
}
|
||||
if (this.message != null) {
|
||||
data.message = this.message.toObject();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
@@ -2931,6 +3044,8 @@ export namespace messages {
|
||||
writer.writeString(1, this.id);
|
||||
if (this.timestamp != 0)
|
||||
writer.writeInt64(2, this.timestamp);
|
||||
if (this.has_message)
|
||||
writer.writeMessage(3, this.message, () => this.message.serialize(writer));
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
@@ -2946,6 +3061,9 @@ export namespace messages {
|
||||
case 2:
|
||||
message.timestamp = reader.readInt64();
|
||||
break;
|
||||
case 3:
|
||||
reader.readMessage(message.message, () => message.message = Json.deserialize(reader));
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
@@ -3855,6 +3973,330 @@ export namespace messages {
|
||||
return CheckPhonesResponse.deserialize(bytes);
|
||||
}
|
||||
}
|
||||
export class RevokeMessageRequest extends pb_1.Message {
|
||||
#one_of_decls: number[][] = [];
|
||||
constructor(data?: any[] | {
|
||||
session?: Session;
|
||||
jid?: string;
|
||||
sender?: string;
|
||||
messageId?: string;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
if (!Array.isArray(data) && typeof data == "object") {
|
||||
if ("session" in data && data.session != undefined) {
|
||||
this.session = data.session;
|
||||
}
|
||||
if ("jid" in data && data.jid != undefined) {
|
||||
this.jid = data.jid;
|
||||
}
|
||||
if ("sender" in data && data.sender != undefined) {
|
||||
this.sender = data.sender;
|
||||
}
|
||||
if ("messageId" in data && data.messageId != undefined) {
|
||||
this.messageId = data.messageId;
|
||||
}
|
||||
}
|
||||
}
|
||||
get session() {
|
||||
return pb_1.Message.getWrapperField(this, Session, 1) as Session;
|
||||
}
|
||||
set session(value: Session) {
|
||||
pb_1.Message.setWrapperField(this, 1, value);
|
||||
}
|
||||
get has_session() {
|
||||
return pb_1.Message.getField(this, 1) != null;
|
||||
}
|
||||
get jid() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
|
||||
}
|
||||
set jid(value: string) {
|
||||
pb_1.Message.setField(this, 2, value);
|
||||
}
|
||||
get sender() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 3, "") as string;
|
||||
}
|
||||
set sender(value: string) {
|
||||
pb_1.Message.setField(this, 3, value);
|
||||
}
|
||||
get messageId() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 4, "") as string;
|
||||
}
|
||||
set messageId(value: string) {
|
||||
pb_1.Message.setField(this, 4, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
session?: ReturnType<typeof Session.prototype.toObject>;
|
||||
jid?: string;
|
||||
sender?: string;
|
||||
messageId?: string;
|
||||
}): RevokeMessageRequest {
|
||||
const message = new RevokeMessageRequest({});
|
||||
if (data.session != null) {
|
||||
message.session = Session.fromObject(data.session);
|
||||
}
|
||||
if (data.jid != null) {
|
||||
message.jid = data.jid;
|
||||
}
|
||||
if (data.sender != null) {
|
||||
message.sender = data.sender;
|
||||
}
|
||||
if (data.messageId != null) {
|
||||
message.messageId = data.messageId;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
const data: {
|
||||
session?: ReturnType<typeof Session.prototype.toObject>;
|
||||
jid?: string;
|
||||
sender?: string;
|
||||
messageId?: string;
|
||||
} = {};
|
||||
if (this.session != null) {
|
||||
data.session = this.session.toObject();
|
||||
}
|
||||
if (this.jid != null) {
|
||||
data.jid = this.jid;
|
||||
}
|
||||
if (this.sender != null) {
|
||||
data.sender = this.sender;
|
||||
}
|
||||
if (this.messageId != null) {
|
||||
data.messageId = this.messageId;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
serialize(w: pb_1.BinaryWriter): void;
|
||||
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
|
||||
const writer = w || new pb_1.BinaryWriter();
|
||||
if (this.has_session)
|
||||
writer.writeMessage(1, this.session, () => this.session.serialize(writer));
|
||||
if (this.jid.length)
|
||||
writer.writeString(2, this.jid);
|
||||
if (this.sender.length)
|
||||
writer.writeString(3, this.sender);
|
||||
if (this.messageId.length)
|
||||
writer.writeString(4, this.messageId);
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): RevokeMessageRequest {
|
||||
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new RevokeMessageRequest();
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup())
|
||||
break;
|
||||
switch (reader.getFieldNumber()) {
|
||||
case 1:
|
||||
reader.readMessage(message.session, () => message.session = Session.deserialize(reader));
|
||||
break;
|
||||
case 2:
|
||||
message.jid = reader.readString();
|
||||
break;
|
||||
case 3:
|
||||
message.sender = reader.readString();
|
||||
break;
|
||||
case 4:
|
||||
message.messageId = reader.readString();
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
serializeBinary(): Uint8Array {
|
||||
return this.serialize();
|
||||
}
|
||||
static deserializeBinary(bytes: Uint8Array): RevokeMessageRequest {
|
||||
return RevokeMessageRequest.deserialize(bytes);
|
||||
}
|
||||
}
|
||||
export class EditMessageRequest extends pb_1.Message {
|
||||
#one_of_decls: number[][] = [];
|
||||
constructor(data?: any[] | {
|
||||
session?: Session;
|
||||
jid?: string;
|
||||
messageId?: string;
|
||||
text?: string;
|
||||
linkPreview?: boolean;
|
||||
linkPreviewHighQuality?: boolean;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
if (!Array.isArray(data) && typeof data == "object") {
|
||||
if ("session" in data && data.session != undefined) {
|
||||
this.session = data.session;
|
||||
}
|
||||
if ("jid" in data && data.jid != undefined) {
|
||||
this.jid = data.jid;
|
||||
}
|
||||
if ("messageId" in data && data.messageId != undefined) {
|
||||
this.messageId = data.messageId;
|
||||
}
|
||||
if ("text" in data && data.text != undefined) {
|
||||
this.text = data.text;
|
||||
}
|
||||
if ("linkPreview" in data && data.linkPreview != undefined) {
|
||||
this.linkPreview = data.linkPreview;
|
||||
}
|
||||
if ("linkPreviewHighQuality" in data && data.linkPreviewHighQuality != undefined) {
|
||||
this.linkPreviewHighQuality = data.linkPreviewHighQuality;
|
||||
}
|
||||
}
|
||||
}
|
||||
get session() {
|
||||
return pb_1.Message.getWrapperField(this, Session, 1) as Session;
|
||||
}
|
||||
set session(value: Session) {
|
||||
pb_1.Message.setWrapperField(this, 1, value);
|
||||
}
|
||||
get has_session() {
|
||||
return pb_1.Message.getField(this, 1) != null;
|
||||
}
|
||||
get jid() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
|
||||
}
|
||||
set jid(value: string) {
|
||||
pb_1.Message.setField(this, 2, value);
|
||||
}
|
||||
get messageId() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 4, "") as string;
|
||||
}
|
||||
set messageId(value: string) {
|
||||
pb_1.Message.setField(this, 4, value);
|
||||
}
|
||||
get text() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 5, "") as string;
|
||||
}
|
||||
set text(value: string) {
|
||||
pb_1.Message.setField(this, 5, value);
|
||||
}
|
||||
get linkPreview() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 6, false) as boolean;
|
||||
}
|
||||
set linkPreview(value: boolean) {
|
||||
pb_1.Message.setField(this, 6, value);
|
||||
}
|
||||
get linkPreviewHighQuality() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 7, false) as boolean;
|
||||
}
|
||||
set linkPreviewHighQuality(value: boolean) {
|
||||
pb_1.Message.setField(this, 7, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
session?: ReturnType<typeof Session.prototype.toObject>;
|
||||
jid?: string;
|
||||
messageId?: string;
|
||||
text?: string;
|
||||
linkPreview?: boolean;
|
||||
linkPreviewHighQuality?: boolean;
|
||||
}): EditMessageRequest {
|
||||
const message = new EditMessageRequest({});
|
||||
if (data.session != null) {
|
||||
message.session = Session.fromObject(data.session);
|
||||
}
|
||||
if (data.jid != null) {
|
||||
message.jid = data.jid;
|
||||
}
|
||||
if (data.messageId != null) {
|
||||
message.messageId = data.messageId;
|
||||
}
|
||||
if (data.text != null) {
|
||||
message.text = data.text;
|
||||
}
|
||||
if (data.linkPreview != null) {
|
||||
message.linkPreview = data.linkPreview;
|
||||
}
|
||||
if (data.linkPreviewHighQuality != null) {
|
||||
message.linkPreviewHighQuality = data.linkPreviewHighQuality;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
const data: {
|
||||
session?: ReturnType<typeof Session.prototype.toObject>;
|
||||
jid?: string;
|
||||
messageId?: string;
|
||||
text?: string;
|
||||
linkPreview?: boolean;
|
||||
linkPreviewHighQuality?: boolean;
|
||||
} = {};
|
||||
if (this.session != null) {
|
||||
data.session = this.session.toObject();
|
||||
}
|
||||
if (this.jid != null) {
|
||||
data.jid = this.jid;
|
||||
}
|
||||
if (this.messageId != null) {
|
||||
data.messageId = this.messageId;
|
||||
}
|
||||
if (this.text != null) {
|
||||
data.text = this.text;
|
||||
}
|
||||
if (this.linkPreview != null) {
|
||||
data.linkPreview = this.linkPreview;
|
||||
}
|
||||
if (this.linkPreviewHighQuality != null) {
|
||||
data.linkPreviewHighQuality = this.linkPreviewHighQuality;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
serialize(w: pb_1.BinaryWriter): void;
|
||||
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
|
||||
const writer = w || new pb_1.BinaryWriter();
|
||||
if (this.has_session)
|
||||
writer.writeMessage(1, this.session, () => this.session.serialize(writer));
|
||||
if (this.jid.length)
|
||||
writer.writeString(2, this.jid);
|
||||
if (this.messageId.length)
|
||||
writer.writeString(4, this.messageId);
|
||||
if (this.text.length)
|
||||
writer.writeString(5, this.text);
|
||||
if (this.linkPreview != false)
|
||||
writer.writeBool(6, this.linkPreview);
|
||||
if (this.linkPreviewHighQuality != false)
|
||||
writer.writeBool(7, this.linkPreviewHighQuality);
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): EditMessageRequest {
|
||||
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new EditMessageRequest();
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup())
|
||||
break;
|
||||
switch (reader.getFieldNumber()) {
|
||||
case 1:
|
||||
reader.readMessage(message.session, () => message.session = Session.deserialize(reader));
|
||||
break;
|
||||
case 2:
|
||||
message.jid = reader.readString();
|
||||
break;
|
||||
case 4:
|
||||
message.messageId = reader.readString();
|
||||
break;
|
||||
case 5:
|
||||
message.text = reader.readString();
|
||||
break;
|
||||
case 6:
|
||||
message.linkPreview = reader.readBool();
|
||||
break;
|
||||
case 7:
|
||||
message.linkPreviewHighQuality = reader.readBool();
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
serializeBinary(): Uint8Array {
|
||||
return this.serialize();
|
||||
}
|
||||
static deserializeBinary(bytes: Uint8Array): EditMessageRequest {
|
||||
return EditMessageRequest.deserialize(bytes);
|
||||
}
|
||||
}
|
||||
export class NewsletterListRequest extends pb_1.Message {
|
||||
#one_of_decls: number[][] = [];
|
||||
constructor(data?: any[] | {
|
||||
@@ -6795,24 +7237,6 @@ export namespace messages {
|
||||
responseSerialize: (message: JsonList) => Buffer.from(message.serialize()),
|
||||
responseDeserialize: (bytes: Buffer) => JsonList.deserialize(new Uint8Array(bytes))
|
||||
},
|
||||
SendMessage: {
|
||||
path: "/messages.MessageService/SendMessage",
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestSerialize: (message: MessageRequest) => Buffer.from(message.serialize()),
|
||||
requestDeserialize: (bytes: Buffer) => MessageRequest.deserialize(new Uint8Array(bytes)),
|
||||
responseSerialize: (message: MessageResponse) => Buffer.from(message.serialize()),
|
||||
responseDeserialize: (bytes: Buffer) => MessageResponse.deserialize(new Uint8Array(bytes))
|
||||
},
|
||||
SendReaction: {
|
||||
path: "/messages.MessageService/SendReaction",
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestSerialize: (message: MessageReaction) => Buffer.from(message.serialize()),
|
||||
requestDeserialize: (bytes: Buffer) => MessageReaction.deserialize(new Uint8Array(bytes)),
|
||||
responseSerialize: (message: MessageResponse) => Buffer.from(message.serialize()),
|
||||
responseDeserialize: (bytes: Buffer) => MessageResponse.deserialize(new Uint8Array(bytes))
|
||||
},
|
||||
GetProfilePicture: {
|
||||
path: "/messages.MessageService/GetProfilePicture",
|
||||
requestStream: false,
|
||||
@@ -6849,6 +7273,33 @@ export namespace messages {
|
||||
responseSerialize: (message: Empty) => Buffer.from(message.serialize()),
|
||||
responseDeserialize: (bytes: Buffer) => Empty.deserialize(new Uint8Array(bytes))
|
||||
},
|
||||
CheckPhones: {
|
||||
path: "/messages.MessageService/CheckPhones",
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestSerialize: (message: CheckPhonesRequest) => Buffer.from(message.serialize()),
|
||||
requestDeserialize: (bytes: Buffer) => CheckPhonesRequest.deserialize(new Uint8Array(bytes)),
|
||||
responseSerialize: (message: CheckPhonesResponse) => Buffer.from(message.serialize()),
|
||||
responseDeserialize: (bytes: Buffer) => CheckPhonesResponse.deserialize(new Uint8Array(bytes))
|
||||
},
|
||||
SendMessage: {
|
||||
path: "/messages.MessageService/SendMessage",
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestSerialize: (message: MessageRequest) => Buffer.from(message.serialize()),
|
||||
requestDeserialize: (bytes: Buffer) => MessageRequest.deserialize(new Uint8Array(bytes)),
|
||||
responseSerialize: (message: MessageResponse) => Buffer.from(message.serialize()),
|
||||
responseDeserialize: (bytes: Buffer) => MessageResponse.deserialize(new Uint8Array(bytes))
|
||||
},
|
||||
SendReaction: {
|
||||
path: "/messages.MessageService/SendReaction",
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestSerialize: (message: MessageReaction) => Buffer.from(message.serialize()),
|
||||
requestDeserialize: (bytes: Buffer) => MessageReaction.deserialize(new Uint8Array(bytes)),
|
||||
responseSerialize: (message: MessageResponse) => Buffer.from(message.serialize()),
|
||||
responseDeserialize: (bytes: Buffer) => MessageResponse.deserialize(new Uint8Array(bytes))
|
||||
},
|
||||
MarkRead: {
|
||||
path: "/messages.MessageService/MarkRead",
|
||||
requestStream: false,
|
||||
@@ -6858,14 +7309,23 @@ export namespace messages {
|
||||
responseSerialize: (message: Empty) => Buffer.from(message.serialize()),
|
||||
responseDeserialize: (bytes: Buffer) => Empty.deserialize(new Uint8Array(bytes))
|
||||
},
|
||||
CheckPhones: {
|
||||
path: "/messages.MessageService/CheckPhones",
|
||||
EditMessage: {
|
||||
path: "/messages.MessageService/EditMessage",
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestSerialize: (message: CheckPhonesRequest) => Buffer.from(message.serialize()),
|
||||
requestDeserialize: (bytes: Buffer) => CheckPhonesRequest.deserialize(new Uint8Array(bytes)),
|
||||
responseSerialize: (message: CheckPhonesResponse) => Buffer.from(message.serialize()),
|
||||
responseDeserialize: (bytes: Buffer) => CheckPhonesResponse.deserialize(new Uint8Array(bytes))
|
||||
requestSerialize: (message: EditMessageRequest) => Buffer.from(message.serialize()),
|
||||
requestDeserialize: (bytes: Buffer) => EditMessageRequest.deserialize(new Uint8Array(bytes)),
|
||||
responseSerialize: (message: MessageResponse) => Buffer.from(message.serialize()),
|
||||
responseDeserialize: (bytes: Buffer) => MessageResponse.deserialize(new Uint8Array(bytes))
|
||||
},
|
||||
RevokeMessage: {
|
||||
path: "/messages.MessageService/RevokeMessage",
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestSerialize: (message: RevokeMessageRequest) => Buffer.from(message.serialize()),
|
||||
requestDeserialize: (bytes: Buffer) => RevokeMessageRequest.deserialize(new Uint8Array(bytes)),
|
||||
responseSerialize: (message: MessageResponse) => Buffer.from(message.serialize()),
|
||||
responseDeserialize: (bytes: Buffer) => MessageResponse.deserialize(new Uint8Array(bytes))
|
||||
},
|
||||
GetSubscribedNewsletters: {
|
||||
path: "/messages.MessageService/GetSubscribedNewsletters",
|
||||
@@ -7018,14 +7478,16 @@ export namespace messages {
|
||||
abstract SetGroupLocked(call: grpc_1.ServerUnaryCall<JidBoolRequest, Empty>, callback: grpc_1.sendUnaryData<Empty>): void;
|
||||
abstract SetGroupAnnounce(call: grpc_1.ServerUnaryCall<JidBoolRequest, Empty>, callback: grpc_1.sendUnaryData<Empty>): void;
|
||||
abstract UpdateGroupParticipants(call: grpc_1.ServerUnaryCall<UpdateParticipantsRequest, JsonList>, callback: grpc_1.sendUnaryData<JsonList>): void;
|
||||
abstract SendMessage(call: grpc_1.ServerUnaryCall<MessageRequest, MessageResponse>, callback: grpc_1.sendUnaryData<MessageResponse>): void;
|
||||
abstract SendReaction(call: grpc_1.ServerUnaryCall<MessageReaction, MessageResponse>, callback: grpc_1.sendUnaryData<MessageResponse>): void;
|
||||
abstract GetProfilePicture(call: grpc_1.ServerUnaryCall<ProfilePictureRequest, ProfilePictureResponse>, callback: grpc_1.sendUnaryData<ProfilePictureResponse>): void;
|
||||
abstract SendPresence(call: grpc_1.ServerUnaryCall<PresenceRequest, Empty>, callback: grpc_1.sendUnaryData<Empty>): void;
|
||||
abstract SendChatPresence(call: grpc_1.ServerUnaryCall<ChatPresenceRequest, Empty>, callback: grpc_1.sendUnaryData<Empty>): void;
|
||||
abstract SubscribePresence(call: grpc_1.ServerUnaryCall<SubscribePresenceRequest, Empty>, callback: grpc_1.sendUnaryData<Empty>): void;
|
||||
abstract MarkRead(call: grpc_1.ServerUnaryCall<MarkReadRequest, Empty>, callback: grpc_1.sendUnaryData<Empty>): void;
|
||||
abstract CheckPhones(call: grpc_1.ServerUnaryCall<CheckPhonesRequest, CheckPhonesResponse>, callback: grpc_1.sendUnaryData<CheckPhonesResponse>): void;
|
||||
abstract SendMessage(call: grpc_1.ServerUnaryCall<MessageRequest, MessageResponse>, callback: grpc_1.sendUnaryData<MessageResponse>): void;
|
||||
abstract SendReaction(call: grpc_1.ServerUnaryCall<MessageReaction, MessageResponse>, callback: grpc_1.sendUnaryData<MessageResponse>): void;
|
||||
abstract MarkRead(call: grpc_1.ServerUnaryCall<MarkReadRequest, Empty>, callback: grpc_1.sendUnaryData<Empty>): void;
|
||||
abstract EditMessage(call: grpc_1.ServerUnaryCall<EditMessageRequest, MessageResponse>, callback: grpc_1.sendUnaryData<MessageResponse>): void;
|
||||
abstract RevokeMessage(call: grpc_1.ServerUnaryCall<RevokeMessageRequest, MessageResponse>, callback: grpc_1.sendUnaryData<MessageResponse>): void;
|
||||
abstract GetSubscribedNewsletters(call: grpc_1.ServerUnaryCall<NewsletterListRequest, NewsletterList>, callback: grpc_1.sendUnaryData<NewsletterList>): void;
|
||||
abstract GetNewsletterInfo(call: grpc_1.ServerUnaryCall<NewsletterInfoRequest, Newsletter>, callback: grpc_1.sendUnaryData<Newsletter>): void;
|
||||
abstract GetNewsletterMessagesByInvite(call: grpc_1.ServerUnaryCall<GetNewsletterMessagesByInviteRequest, Json>, callback: grpc_1.sendUnaryData<Json>): void;
|
||||
@@ -7114,12 +7576,6 @@ export namespace messages {
|
||||
UpdateGroupParticipants: GrpcUnaryServiceInterface<UpdateParticipantsRequest, JsonList> = (message: UpdateParticipantsRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<JsonList>, options?: grpc_1.CallOptions | grpc_1.requestCallback<JsonList>, callback?: grpc_1.requestCallback<JsonList>): grpc_1.ClientUnaryCall => {
|
||||
return super.UpdateGroupParticipants(message, metadata, options, callback);
|
||||
};
|
||||
SendMessage: GrpcUnaryServiceInterface<MessageRequest, MessageResponse> = (message: MessageRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<MessageResponse>, options?: grpc_1.CallOptions | grpc_1.requestCallback<MessageResponse>, callback?: grpc_1.requestCallback<MessageResponse>): grpc_1.ClientUnaryCall => {
|
||||
return super.SendMessage(message, metadata, options, callback);
|
||||
};
|
||||
SendReaction: GrpcUnaryServiceInterface<MessageReaction, MessageResponse> = (message: MessageReaction, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<MessageResponse>, options?: grpc_1.CallOptions | grpc_1.requestCallback<MessageResponse>, callback?: grpc_1.requestCallback<MessageResponse>): grpc_1.ClientUnaryCall => {
|
||||
return super.SendReaction(message, metadata, options, callback);
|
||||
};
|
||||
GetProfilePicture: GrpcUnaryServiceInterface<ProfilePictureRequest, ProfilePictureResponse> = (message: ProfilePictureRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<ProfilePictureResponse>, options?: grpc_1.CallOptions | grpc_1.requestCallback<ProfilePictureResponse>, callback?: grpc_1.requestCallback<ProfilePictureResponse>): grpc_1.ClientUnaryCall => {
|
||||
return super.GetProfilePicture(message, metadata, options, callback);
|
||||
};
|
||||
@@ -7132,11 +7588,23 @@ export namespace messages {
|
||||
SubscribePresence: GrpcUnaryServiceInterface<SubscribePresenceRequest, Empty> = (message: SubscribePresenceRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<Empty>, options?: grpc_1.CallOptions | grpc_1.requestCallback<Empty>, callback?: grpc_1.requestCallback<Empty>): grpc_1.ClientUnaryCall => {
|
||||
return super.SubscribePresence(message, metadata, options, callback);
|
||||
};
|
||||
CheckPhones: GrpcUnaryServiceInterface<CheckPhonesRequest, CheckPhonesResponse> = (message: CheckPhonesRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<CheckPhonesResponse>, options?: grpc_1.CallOptions | grpc_1.requestCallback<CheckPhonesResponse>, callback?: grpc_1.requestCallback<CheckPhonesResponse>): grpc_1.ClientUnaryCall => {
|
||||
return super.CheckPhones(message, metadata, options, callback);
|
||||
};
|
||||
SendMessage: GrpcUnaryServiceInterface<MessageRequest, MessageResponse> = (message: MessageRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<MessageResponse>, options?: grpc_1.CallOptions | grpc_1.requestCallback<MessageResponse>, callback?: grpc_1.requestCallback<MessageResponse>): grpc_1.ClientUnaryCall => {
|
||||
return super.SendMessage(message, metadata, options, callback);
|
||||
};
|
||||
SendReaction: GrpcUnaryServiceInterface<MessageReaction, MessageResponse> = (message: MessageReaction, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<MessageResponse>, options?: grpc_1.CallOptions | grpc_1.requestCallback<MessageResponse>, callback?: grpc_1.requestCallback<MessageResponse>): grpc_1.ClientUnaryCall => {
|
||||
return super.SendReaction(message, metadata, options, callback);
|
||||
};
|
||||
MarkRead: GrpcUnaryServiceInterface<MarkReadRequest, Empty> = (message: MarkReadRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<Empty>, options?: grpc_1.CallOptions | grpc_1.requestCallback<Empty>, callback?: grpc_1.requestCallback<Empty>): grpc_1.ClientUnaryCall => {
|
||||
return super.MarkRead(message, metadata, options, callback);
|
||||
};
|
||||
CheckPhones: GrpcUnaryServiceInterface<CheckPhonesRequest, CheckPhonesResponse> = (message: CheckPhonesRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<CheckPhonesResponse>, options?: grpc_1.CallOptions | grpc_1.requestCallback<CheckPhonesResponse>, callback?: grpc_1.requestCallback<CheckPhonesResponse>): grpc_1.ClientUnaryCall => {
|
||||
return super.CheckPhones(message, metadata, options, callback);
|
||||
EditMessage: GrpcUnaryServiceInterface<EditMessageRequest, MessageResponse> = (message: EditMessageRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<MessageResponse>, options?: grpc_1.CallOptions | grpc_1.requestCallback<MessageResponse>, callback?: grpc_1.requestCallback<MessageResponse>): grpc_1.ClientUnaryCall => {
|
||||
return super.EditMessage(message, metadata, options, callback);
|
||||
};
|
||||
RevokeMessage: GrpcUnaryServiceInterface<RevokeMessageRequest, MessageResponse> = (message: RevokeMessageRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<MessageResponse>, options?: grpc_1.CallOptions | grpc_1.requestCallback<MessageResponse>, callback?: grpc_1.requestCallback<MessageResponse>): grpc_1.ClientUnaryCall => {
|
||||
return super.RevokeMessage(message, metadata, options, callback);
|
||||
};
|
||||
GetSubscribedNewsletters: GrpcUnaryServiceInterface<NewsletterListRequest, NewsletterList> = (message: NewsletterListRequest, metadata: grpc_1.Metadata | grpc_1.CallOptions | grpc_1.requestCallback<NewsletterList>, options?: grpc_1.CallOptions | grpc_1.requestCallback<NewsletterList>, callback?: grpc_1.requestCallback<NewsletterList>): grpc_1.ClientUnaryCall => {
|
||||
return super.GetSubscribedNewsletters(message, metadata, options, callback);
|
||||
|
||||
@@ -81,6 +81,17 @@ function deserialize_messages_DownloadMediaResponse(buffer_arg) {
|
||||
return gows_pb.DownloadMediaResponse.deserializeBinary(new Uint8Array(buffer_arg));
|
||||
}
|
||||
|
||||
function serialize_messages_EditMessageRequest(arg) {
|
||||
if (!(arg instanceof gows_pb.EditMessageRequest)) {
|
||||
throw new Error('Expected argument of type messages.EditMessageRequest');
|
||||
}
|
||||
return Buffer.from(arg.serializeBinary());
|
||||
}
|
||||
|
||||
function deserialize_messages_EditMessageRequest(buffer_arg) {
|
||||
return gows_pb.EditMessageRequest.deserializeBinary(new Uint8Array(buffer_arg));
|
||||
}
|
||||
|
||||
function serialize_messages_Empty(arg) {
|
||||
if (!(arg instanceof gows_pb.Empty)) {
|
||||
throw new Error('Expected argument of type messages.Empty');
|
||||
@@ -433,6 +444,17 @@ function deserialize_messages_ProfileStatusRequest(buffer_arg) {
|
||||
return gows_pb.ProfileStatusRequest.deserializeBinary(new Uint8Array(buffer_arg));
|
||||
}
|
||||
|
||||
function serialize_messages_RevokeMessageRequest(arg) {
|
||||
if (!(arg instanceof gows_pb.RevokeMessageRequest)) {
|
||||
throw new Error('Expected argument of type messages.RevokeMessageRequest');
|
||||
}
|
||||
return Buffer.from(arg.serializeBinary());
|
||||
}
|
||||
|
||||
function deserialize_messages_RevokeMessageRequest(buffer_arg) {
|
||||
return gows_pb.RevokeMessageRequest.deserializeBinary(new Uint8Array(buffer_arg));
|
||||
}
|
||||
|
||||
function serialize_messages_SearchNewslettersByTextRequest(arg) {
|
||||
if (!(arg instanceof gows_pb.SearchNewslettersByTextRequest)) {
|
||||
throw new Error('Expected argument of type messages.SearchNewslettersByTextRequest');
|
||||
@@ -819,29 +841,7 @@ updateGroupParticipants: {
|
||||
//
|
||||
// Actions
|
||||
//
|
||||
sendMessage: {
|
||||
path: '/messages.MessageService/SendMessage',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestType: gows_pb.MessageRequest,
|
||||
responseType: gows_pb.MessageResponse,
|
||||
requestSerialize: serialize_messages_MessageRequest,
|
||||
requestDeserialize: deserialize_messages_MessageRequest,
|
||||
responseSerialize: serialize_messages_MessageResponse,
|
||||
responseDeserialize: deserialize_messages_MessageResponse,
|
||||
},
|
||||
sendReaction: {
|
||||
path: '/messages.MessageService/SendReaction',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestType: gows_pb.MessageReaction,
|
||||
responseType: gows_pb.MessageResponse,
|
||||
requestSerialize: serialize_messages_MessageReaction,
|
||||
requestDeserialize: deserialize_messages_MessageReaction,
|
||||
responseSerialize: serialize_messages_MessageResponse,
|
||||
responseDeserialize: deserialize_messages_MessageResponse,
|
||||
},
|
||||
getProfilePicture: {
|
||||
getProfilePicture: {
|
||||
path: '/messages.MessageService/GetProfilePicture',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
@@ -885,6 +885,42 @@ sendMessage: {
|
||||
responseSerialize: serialize_messages_Empty,
|
||||
responseDeserialize: deserialize_messages_Empty,
|
||||
},
|
||||
checkPhones: {
|
||||
path: '/messages.MessageService/CheckPhones',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestType: gows_pb.CheckPhonesRequest,
|
||||
responseType: gows_pb.CheckPhonesResponse,
|
||||
requestSerialize: serialize_messages_CheckPhonesRequest,
|
||||
requestDeserialize: deserialize_messages_CheckPhonesRequest,
|
||||
responseSerialize: serialize_messages_CheckPhonesResponse,
|
||||
responseDeserialize: deserialize_messages_CheckPhonesResponse,
|
||||
},
|
||||
//
|
||||
// Message
|
||||
//
|
||||
sendMessage: {
|
||||
path: '/messages.MessageService/SendMessage',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestType: gows_pb.MessageRequest,
|
||||
responseType: gows_pb.MessageResponse,
|
||||
requestSerialize: serialize_messages_MessageRequest,
|
||||
requestDeserialize: deserialize_messages_MessageRequest,
|
||||
responseSerialize: serialize_messages_MessageResponse,
|
||||
responseDeserialize: deserialize_messages_MessageResponse,
|
||||
},
|
||||
sendReaction: {
|
||||
path: '/messages.MessageService/SendReaction',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestType: gows_pb.MessageReaction,
|
||||
responseType: gows_pb.MessageResponse,
|
||||
requestSerialize: serialize_messages_MessageReaction,
|
||||
requestDeserialize: deserialize_messages_MessageReaction,
|
||||
responseSerialize: serialize_messages_MessageResponse,
|
||||
responseDeserialize: deserialize_messages_MessageResponse,
|
||||
},
|
||||
markRead: {
|
||||
path: '/messages.MessageService/MarkRead',
|
||||
requestStream: false,
|
||||
@@ -896,16 +932,27 @@ sendMessage: {
|
||||
responseSerialize: serialize_messages_Empty,
|
||||
responseDeserialize: deserialize_messages_Empty,
|
||||
},
|
||||
checkPhones: {
|
||||
path: '/messages.MessageService/CheckPhones',
|
||||
editMessage: {
|
||||
path: '/messages.MessageService/EditMessage',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestType: gows_pb.CheckPhonesRequest,
|
||||
responseType: gows_pb.CheckPhonesResponse,
|
||||
requestSerialize: serialize_messages_CheckPhonesRequest,
|
||||
requestDeserialize: deserialize_messages_CheckPhonesRequest,
|
||||
responseSerialize: serialize_messages_CheckPhonesResponse,
|
||||
responseDeserialize: deserialize_messages_CheckPhonesResponse,
|
||||
requestType: gows_pb.EditMessageRequest,
|
||||
responseType: gows_pb.MessageResponse,
|
||||
requestSerialize: serialize_messages_EditMessageRequest,
|
||||
requestDeserialize: deserialize_messages_EditMessageRequest,
|
||||
responseSerialize: serialize_messages_MessageResponse,
|
||||
responseDeserialize: deserialize_messages_MessageResponse,
|
||||
},
|
||||
revokeMessage: {
|
||||
path: '/messages.MessageService/RevokeMessage',
|
||||
requestStream: false,
|
||||
responseStream: false,
|
||||
requestType: gows_pb.RevokeMessageRequest,
|
||||
responseType: gows_pb.MessageResponse,
|
||||
requestSerialize: serialize_messages_RevokeMessageRequest,
|
||||
requestDeserialize: deserialize_messages_RevokeMessageRequest,
|
||||
responseSerialize: serialize_messages_MessageResponse,
|
||||
responseDeserialize: deserialize_messages_MessageResponse,
|
||||
},
|
||||
//
|
||||
// Newsletters
|
||||
|
||||
@@ -30,6 +30,7 @@ goog.exportSymbol('proto.messages.CreateGroupRequest', null, global);
|
||||
goog.exportSymbol('proto.messages.CreateNewsletterRequest', null, global);
|
||||
goog.exportSymbol('proto.messages.DownloadMediaRequest', null, global);
|
||||
goog.exportSymbol('proto.messages.DownloadMediaResponse', null, global);
|
||||
goog.exportSymbol('proto.messages.EditMessageRequest', null, global);
|
||||
goog.exportSymbol('proto.messages.Empty', null, global);
|
||||
goog.exportSymbol('proto.messages.EntityByIdRequest', null, global);
|
||||
goog.exportSymbol('proto.messages.EventJson', null, global);
|
||||
@@ -74,6 +75,7 @@ goog.exportSymbol('proto.messages.ProfilePictureRequest', null, global);
|
||||
goog.exportSymbol('proto.messages.ProfilePictureResponse', null, global);
|
||||
goog.exportSymbol('proto.messages.ProfileStatusRequest', null, global);
|
||||
goog.exportSymbol('proto.messages.ReceiptType', null, global);
|
||||
goog.exportSymbol('proto.messages.RevokeMessageRequest', null, global);
|
||||
goog.exportSymbol('proto.messages.SearchNewslettersByTextRequest', null, global);
|
||||
goog.exportSymbol('proto.messages.SearchNewslettersByViewRequest', null, global);
|
||||
goog.exportSymbol('proto.messages.SearchPage', null, global);
|
||||
@@ -910,6 +912,48 @@ if (goog.DEBUG && !COMPILED) {
|
||||
*/
|
||||
proto.messages.CheckPhonesResponse.displayName = 'proto.messages.CheckPhonesResponse';
|
||||
}
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
||||
* server response, or constructed directly in Javascript. The array is used
|
||||
* in place and becomes part of the constructed object. It is not cloned.
|
||||
* If no data is provided, the constructed object will be empty, but still
|
||||
* valid.
|
||||
* @extends {jspb.Message}
|
||||
* @constructor
|
||||
*/
|
||||
proto.messages.RevokeMessageRequest = function(opt_data) {
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
|
||||
};
|
||||
goog.inherits(proto.messages.RevokeMessageRequest, jspb.Message);
|
||||
if (goog.DEBUG && !COMPILED) {
|
||||
/**
|
||||
* @public
|
||||
* @override
|
||||
*/
|
||||
proto.messages.RevokeMessageRequest.displayName = 'proto.messages.RevokeMessageRequest';
|
||||
}
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
||||
* server response, or constructed directly in Javascript. The array is used
|
||||
* in place and becomes part of the constructed object. It is not cloned.
|
||||
* If no data is provided, the constructed object will be empty, but still
|
||||
* valid.
|
||||
* @extends {jspb.Message}
|
||||
* @constructor
|
||||
*/
|
||||
proto.messages.EditMessageRequest = function(opt_data) {
|
||||
jspb.Message.initialize(this, opt_data, 0, -1, null, null);
|
||||
};
|
||||
goog.inherits(proto.messages.EditMessageRequest, jspb.Message);
|
||||
if (goog.DEBUG && !COMPILED) {
|
||||
/**
|
||||
* @public
|
||||
* @override
|
||||
*/
|
||||
proto.messages.EditMessageRequest.displayName = 'proto.messages.EditMessageRequest';
|
||||
}
|
||||
/**
|
||||
* Generated by JsPbCodeGenerator.
|
||||
* @param {Array=} opt_data Optional initial data array, typically from a
|
||||
@@ -5989,7 +6033,8 @@ proto.messages.Media.toObject = function(includeInstance, msg) {
|
||||
content: msg.getContent_asB64(),
|
||||
type: jspb.Message.getFieldWithDefault(msg, 2, 0),
|
||||
mimetype: jspb.Message.getFieldWithDefault(msg, 3, ""),
|
||||
audio: (f = msg.getAudio()) && proto.messages.AudioInfo.toObject(includeInstance, f)
|
||||
audio: (f = msg.getAudio()) && proto.messages.AudioInfo.toObject(includeInstance, f),
|
||||
filename: jspb.Message.getFieldWithDefault(msg, 5, "")
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
@@ -6043,6 +6088,10 @@ proto.messages.Media.deserializeBinaryFromReader = function(msg, reader) {
|
||||
reader.readMessage(value,proto.messages.AudioInfo.deserializeBinaryFromReader);
|
||||
msg.setAudio(value);
|
||||
break;
|
||||
case 5:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setFilename(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
@@ -6101,6 +6150,13 @@ proto.messages.Media.serializeBinaryToWriter = function(message, writer) {
|
||||
proto.messages.AudioInfo.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
f = message.getFilename();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
5,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -6219,6 +6275,24 @@ proto.messages.Media.prototype.hasAudio = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string filename = 5;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.messages.Media.prototype.getFilename = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, ""));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @return {!proto.messages.Media} returns this
|
||||
*/
|
||||
proto.messages.Media.prototype.setFilename = function(value) {
|
||||
return jspb.Message.setProto3StringField(this, 5, value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6256,7 +6330,10 @@ proto.messages.MessageRequest.toObject = function(includeInstance, msg) {
|
||||
text: jspb.Message.getFieldWithDefault(msg, 3, ""),
|
||||
media: (f = msg.getMedia()) && proto.messages.Media.toObject(includeInstance, f),
|
||||
backgroundcolor: (f = msg.getBackgroundcolor()) && proto.messages.OptionalString.toObject(includeInstance, f),
|
||||
font: (f = msg.getFont()) && proto.messages.OptionalUInt32.toObject(includeInstance, f)
|
||||
font: (f = msg.getFont()) && proto.messages.OptionalUInt32.toObject(includeInstance, f),
|
||||
linkpreview: jspb.Message.getBooleanFieldWithDefault(msg, 7, false),
|
||||
linkpreviewhighquality: jspb.Message.getBooleanFieldWithDefault(msg, 8, false),
|
||||
replyto: jspb.Message.getFieldWithDefault(msg, 9, "")
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
@@ -6321,6 +6398,18 @@ proto.messages.MessageRequest.deserializeBinaryFromReader = function(msg, reader
|
||||
reader.readMessage(value,proto.messages.OptionalUInt32.deserializeBinaryFromReader);
|
||||
msg.setFont(value);
|
||||
break;
|
||||
case 7:
|
||||
var value = /** @type {boolean} */ (reader.readBool());
|
||||
msg.setLinkpreview(value);
|
||||
break;
|
||||
case 8:
|
||||
var value = /** @type {boolean} */ (reader.readBool());
|
||||
msg.setLinkpreviewhighquality(value);
|
||||
break;
|
||||
case 9:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setReplyto(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
@@ -6396,6 +6485,27 @@ proto.messages.MessageRequest.serializeBinaryToWriter = function(message, writer
|
||||
proto.messages.OptionalUInt32.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
f = message.getLinkpreview();
|
||||
if (f) {
|
||||
writer.writeBool(
|
||||
7,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getLinkpreviewhighquality();
|
||||
if (f) {
|
||||
writer.writeBool(
|
||||
8,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getReplyto();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
9,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -6583,6 +6693,60 @@ proto.messages.MessageRequest.prototype.hasFont = function() {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional bool linkPreview = 7;
|
||||
* @return {boolean}
|
||||
*/
|
||||
proto.messages.MessageRequest.prototype.getLinkpreview = function() {
|
||||
return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 7, false));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {boolean} value
|
||||
* @return {!proto.messages.MessageRequest} returns this
|
||||
*/
|
||||
proto.messages.MessageRequest.prototype.setLinkpreview = function(value) {
|
||||
return jspb.Message.setProto3BooleanField(this, 7, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional bool linkPreviewHighQuality = 8;
|
||||
* @return {boolean}
|
||||
*/
|
||||
proto.messages.MessageRequest.prototype.getLinkpreviewhighquality = function() {
|
||||
return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 8, false));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {boolean} value
|
||||
* @return {!proto.messages.MessageRequest} returns this
|
||||
*/
|
||||
proto.messages.MessageRequest.prototype.setLinkpreviewhighquality = function(value) {
|
||||
return jspb.Message.setProto3BooleanField(this, 8, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string replyTo = 9;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.messages.MessageRequest.prototype.getReplyto = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 9, ""));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @return {!proto.messages.MessageRequest} returns this
|
||||
*/
|
||||
proto.messages.MessageRequest.prototype.setReplyto = function(value) {
|
||||
return jspb.Message.setProto3StringField(this, 9, value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -6887,7 +7051,8 @@ proto.messages.MessageResponse.prototype.toObject = function(opt_includeInstance
|
||||
proto.messages.MessageResponse.toObject = function(includeInstance, msg) {
|
||||
var f, obj = {
|
||||
id: jspb.Message.getFieldWithDefault(msg, 1, ""),
|
||||
timestamp: jspb.Message.getFieldWithDefault(msg, 2, 0)
|
||||
timestamp: jspb.Message.getFieldWithDefault(msg, 2, 0),
|
||||
message: (f = msg.getMessage()) && proto.messages.Json.toObject(includeInstance, f)
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
@@ -6932,6 +7097,11 @@ proto.messages.MessageResponse.deserializeBinaryFromReader = function(msg, reade
|
||||
var value = /** @type {number} */ (reader.readInt64());
|
||||
msg.setTimestamp(value);
|
||||
break;
|
||||
case 3:
|
||||
var value = new proto.messages.Json;
|
||||
reader.readMessage(value,proto.messages.Json.deserializeBinaryFromReader);
|
||||
msg.setMessage(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
@@ -6975,6 +7145,14 @@ proto.messages.MessageResponse.serializeBinaryToWriter = function(message, write
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getMessage();
|
||||
if (f != null) {
|
||||
writer.writeMessage(
|
||||
3,
|
||||
f,
|
||||
proto.messages.Json.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -7014,6 +7192,43 @@ proto.messages.MessageResponse.prototype.setTimestamp = function(value) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional Json message = 3;
|
||||
* @return {?proto.messages.Json}
|
||||
*/
|
||||
proto.messages.MessageResponse.prototype.getMessage = function() {
|
||||
return /** @type{?proto.messages.Json} */ (
|
||||
jspb.Message.getWrapperField(this, proto.messages.Json, 3));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {?proto.messages.Json|undefined} value
|
||||
* @return {!proto.messages.MessageResponse} returns this
|
||||
*/
|
||||
proto.messages.MessageResponse.prototype.setMessage = function(value) {
|
||||
return jspb.Message.setWrapperField(this, 3, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Clears the message field making it undefined.
|
||||
* @return {!proto.messages.MessageResponse} returns this
|
||||
*/
|
||||
proto.messages.MessageResponse.prototype.clearMessage = function() {
|
||||
return this.setMessage(undefined);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether this field is set.
|
||||
* @return {boolean}
|
||||
*/
|
||||
proto.messages.MessageResponse.prototype.hasMessage = function() {
|
||||
return jspb.Message.getField(this, 3) != null;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -8729,6 +8944,548 @@ proto.messages.CheckPhonesResponse.prototype.clearInfosList = function() {
|
||||
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
/**
|
||||
* Creates an object representation of this proto.
|
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name.
|
||||
* Optional fields that are not set will be set to undefined.
|
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
|
||||
* For the list of reserved names please see:
|
||||
* net/proto2/compiler/js/internal/generator.cc#kKeyword.
|
||||
* @param {boolean=} opt_includeInstance Deprecated. whether to include the
|
||||
* JSPB instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.messages.RevokeMessageRequest.prototype.toObject = function(opt_includeInstance) {
|
||||
return proto.messages.RevokeMessageRequest.toObject(opt_includeInstance, this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Static version of the {@see toObject} method.
|
||||
* @param {boolean|undefined} includeInstance Deprecated. Whether to include
|
||||
* the JSPB instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.messages.RevokeMessageRequest} msg The msg instance to transform.
|
||||
* @return {!Object}
|
||||
* @suppress {unusedLocalVariables} f is only used for nested messages
|
||||
*/
|
||||
proto.messages.RevokeMessageRequest.toObject = function(includeInstance, msg) {
|
||||
var f, obj = {
|
||||
session: (f = msg.getSession()) && proto.messages.Session.toObject(includeInstance, f),
|
||||
jid: jspb.Message.getFieldWithDefault(msg, 2, ""),
|
||||
sender: jspb.Message.getFieldWithDefault(msg, 3, ""),
|
||||
messageid: jspb.Message.getFieldWithDefault(msg, 4, "")
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
obj.$jspbMessageInstance = msg;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format).
|
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize.
|
||||
* @return {!proto.messages.RevokeMessageRequest}
|
||||
*/
|
||||
proto.messages.RevokeMessageRequest.deserializeBinary = function(bytes) {
|
||||
var reader = new jspb.BinaryReader(bytes);
|
||||
var msg = new proto.messages.RevokeMessageRequest;
|
||||
return proto.messages.RevokeMessageRequest.deserializeBinaryFromReader(msg, reader);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format) from the
|
||||
* given reader into the given message object.
|
||||
* @param {!proto.messages.RevokeMessageRequest} msg The message object to deserialize into.
|
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
|
||||
* @return {!proto.messages.RevokeMessageRequest}
|
||||
*/
|
||||
proto.messages.RevokeMessageRequest.deserializeBinaryFromReader = function(msg, reader) {
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup()) {
|
||||
break;
|
||||
}
|
||||
var field = reader.getFieldNumber();
|
||||
switch (field) {
|
||||
case 1:
|
||||
var value = new proto.messages.Session;
|
||||
reader.readMessage(value,proto.messages.Session.deserializeBinaryFromReader);
|
||||
msg.setSession(value);
|
||||
break;
|
||||
case 2:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setJid(value);
|
||||
break;
|
||||
case 3:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setSender(value);
|
||||
break;
|
||||
case 4:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setMessageid(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format).
|
||||
* @return {!Uint8Array}
|
||||
*/
|
||||
proto.messages.RevokeMessageRequest.prototype.serializeBinary = function() {
|
||||
var writer = new jspb.BinaryWriter();
|
||||
proto.messages.RevokeMessageRequest.serializeBinaryToWriter(this, writer);
|
||||
return writer.getResultBuffer();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the given message to binary data (in protobuf wire
|
||||
* format), writing to the given BinaryWriter.
|
||||
* @param {!proto.messages.RevokeMessageRequest} message
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
* @suppress {unusedLocalVariables} f is only used for nested messages
|
||||
*/
|
||||
proto.messages.RevokeMessageRequest.serializeBinaryToWriter = function(message, writer) {
|
||||
var f = undefined;
|
||||
f = message.getSession();
|
||||
if (f != null) {
|
||||
writer.writeMessage(
|
||||
1,
|
||||
f,
|
||||
proto.messages.Session.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
f = message.getJid();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
2,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getSender();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
3,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getMessageid();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
4,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional Session session = 1;
|
||||
* @return {?proto.messages.Session}
|
||||
*/
|
||||
proto.messages.RevokeMessageRequest.prototype.getSession = function() {
|
||||
return /** @type{?proto.messages.Session} */ (
|
||||
jspb.Message.getWrapperField(this, proto.messages.Session, 1));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {?proto.messages.Session|undefined} value
|
||||
* @return {!proto.messages.RevokeMessageRequest} returns this
|
||||
*/
|
||||
proto.messages.RevokeMessageRequest.prototype.setSession = function(value) {
|
||||
return jspb.Message.setWrapperField(this, 1, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Clears the message field making it undefined.
|
||||
* @return {!proto.messages.RevokeMessageRequest} returns this
|
||||
*/
|
||||
proto.messages.RevokeMessageRequest.prototype.clearSession = function() {
|
||||
return this.setSession(undefined);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether this field is set.
|
||||
* @return {boolean}
|
||||
*/
|
||||
proto.messages.RevokeMessageRequest.prototype.hasSession = function() {
|
||||
return jspb.Message.getField(this, 1) != null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string jid = 2;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.messages.RevokeMessageRequest.prototype.getJid = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @return {!proto.messages.RevokeMessageRequest} returns this
|
||||
*/
|
||||
proto.messages.RevokeMessageRequest.prototype.setJid = function(value) {
|
||||
return jspb.Message.setProto3StringField(this, 2, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string sender = 3;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.messages.RevokeMessageRequest.prototype.getSender = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 3, ""));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @return {!proto.messages.RevokeMessageRequest} returns this
|
||||
*/
|
||||
proto.messages.RevokeMessageRequest.prototype.setSender = function(value) {
|
||||
return jspb.Message.setProto3StringField(this, 3, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string messageId = 4;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.messages.RevokeMessageRequest.prototype.getMessageid = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, ""));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @return {!proto.messages.RevokeMessageRequest} returns this
|
||||
*/
|
||||
proto.messages.RevokeMessageRequest.prototype.setMessageid = function(value) {
|
||||
return jspb.Message.setProto3StringField(this, 4, value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
/**
|
||||
* Creates an object representation of this proto.
|
||||
* Field names that are reserved in JavaScript and will be renamed to pb_name.
|
||||
* Optional fields that are not set will be set to undefined.
|
||||
* To access a reserved field use, foo.pb_<name>, eg, foo.pb_default.
|
||||
* For the list of reserved names please see:
|
||||
* net/proto2/compiler/js/internal/generator.cc#kKeyword.
|
||||
* @param {boolean=} opt_includeInstance Deprecated. whether to include the
|
||||
* JSPB instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @return {!Object}
|
||||
*/
|
||||
proto.messages.EditMessageRequest.prototype.toObject = function(opt_includeInstance) {
|
||||
return proto.messages.EditMessageRequest.toObject(opt_includeInstance, this);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Static version of the {@see toObject} method.
|
||||
* @param {boolean|undefined} includeInstance Deprecated. Whether to include
|
||||
* the JSPB instance for transitional soy proto support:
|
||||
* http://goto/soy-param-migration
|
||||
* @param {!proto.messages.EditMessageRequest} msg The msg instance to transform.
|
||||
* @return {!Object}
|
||||
* @suppress {unusedLocalVariables} f is only used for nested messages
|
||||
*/
|
||||
proto.messages.EditMessageRequest.toObject = function(includeInstance, msg) {
|
||||
var f, obj = {
|
||||
session: (f = msg.getSession()) && proto.messages.Session.toObject(includeInstance, f),
|
||||
jid: jspb.Message.getFieldWithDefault(msg, 2, ""),
|
||||
messageid: jspb.Message.getFieldWithDefault(msg, 4, ""),
|
||||
text: jspb.Message.getFieldWithDefault(msg, 5, ""),
|
||||
linkpreview: jspb.Message.getBooleanFieldWithDefault(msg, 6, false),
|
||||
linkpreviewhighquality: jspb.Message.getBooleanFieldWithDefault(msg, 7, false)
|
||||
};
|
||||
|
||||
if (includeInstance) {
|
||||
obj.$jspbMessageInstance = msg;
|
||||
}
|
||||
return obj;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format).
|
||||
* @param {jspb.ByteSource} bytes The bytes to deserialize.
|
||||
* @return {!proto.messages.EditMessageRequest}
|
||||
*/
|
||||
proto.messages.EditMessageRequest.deserializeBinary = function(bytes) {
|
||||
var reader = new jspb.BinaryReader(bytes);
|
||||
var msg = new proto.messages.EditMessageRequest;
|
||||
return proto.messages.EditMessageRequest.deserializeBinaryFromReader(msg, reader);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deserializes binary data (in protobuf wire format) from the
|
||||
* given reader into the given message object.
|
||||
* @param {!proto.messages.EditMessageRequest} msg The message object to deserialize into.
|
||||
* @param {!jspb.BinaryReader} reader The BinaryReader to use.
|
||||
* @return {!proto.messages.EditMessageRequest}
|
||||
*/
|
||||
proto.messages.EditMessageRequest.deserializeBinaryFromReader = function(msg, reader) {
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup()) {
|
||||
break;
|
||||
}
|
||||
var field = reader.getFieldNumber();
|
||||
switch (field) {
|
||||
case 1:
|
||||
var value = new proto.messages.Session;
|
||||
reader.readMessage(value,proto.messages.Session.deserializeBinaryFromReader);
|
||||
msg.setSession(value);
|
||||
break;
|
||||
case 2:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setJid(value);
|
||||
break;
|
||||
case 4:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setMessageid(value);
|
||||
break;
|
||||
case 5:
|
||||
var value = /** @type {string} */ (reader.readString());
|
||||
msg.setText(value);
|
||||
break;
|
||||
case 6:
|
||||
var value = /** @type {boolean} */ (reader.readBool());
|
||||
msg.setLinkpreview(value);
|
||||
break;
|
||||
case 7:
|
||||
var value = /** @type {boolean} */ (reader.readBool());
|
||||
msg.setLinkpreviewhighquality(value);
|
||||
break;
|
||||
default:
|
||||
reader.skipField();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return msg;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the message to binary data (in protobuf wire format).
|
||||
* @return {!Uint8Array}
|
||||
*/
|
||||
proto.messages.EditMessageRequest.prototype.serializeBinary = function() {
|
||||
var writer = new jspb.BinaryWriter();
|
||||
proto.messages.EditMessageRequest.serializeBinaryToWriter(this, writer);
|
||||
return writer.getResultBuffer();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Serializes the given message to binary data (in protobuf wire
|
||||
* format), writing to the given BinaryWriter.
|
||||
* @param {!proto.messages.EditMessageRequest} message
|
||||
* @param {!jspb.BinaryWriter} writer
|
||||
* @suppress {unusedLocalVariables} f is only used for nested messages
|
||||
*/
|
||||
proto.messages.EditMessageRequest.serializeBinaryToWriter = function(message, writer) {
|
||||
var f = undefined;
|
||||
f = message.getSession();
|
||||
if (f != null) {
|
||||
writer.writeMessage(
|
||||
1,
|
||||
f,
|
||||
proto.messages.Session.serializeBinaryToWriter
|
||||
);
|
||||
}
|
||||
f = message.getJid();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
2,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getMessageid();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
4,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getText();
|
||||
if (f.length > 0) {
|
||||
writer.writeString(
|
||||
5,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getLinkpreview();
|
||||
if (f) {
|
||||
writer.writeBool(
|
||||
6,
|
||||
f
|
||||
);
|
||||
}
|
||||
f = message.getLinkpreviewhighquality();
|
||||
if (f) {
|
||||
writer.writeBool(
|
||||
7,
|
||||
f
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional Session session = 1;
|
||||
* @return {?proto.messages.Session}
|
||||
*/
|
||||
proto.messages.EditMessageRequest.prototype.getSession = function() {
|
||||
return /** @type{?proto.messages.Session} */ (
|
||||
jspb.Message.getWrapperField(this, proto.messages.Session, 1));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {?proto.messages.Session|undefined} value
|
||||
* @return {!proto.messages.EditMessageRequest} returns this
|
||||
*/
|
||||
proto.messages.EditMessageRequest.prototype.setSession = function(value) {
|
||||
return jspb.Message.setWrapperField(this, 1, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Clears the message field making it undefined.
|
||||
* @return {!proto.messages.EditMessageRequest} returns this
|
||||
*/
|
||||
proto.messages.EditMessageRequest.prototype.clearSession = function() {
|
||||
return this.setSession(undefined);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether this field is set.
|
||||
* @return {boolean}
|
||||
*/
|
||||
proto.messages.EditMessageRequest.prototype.hasSession = function() {
|
||||
return jspb.Message.getField(this, 1) != null;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string jid = 2;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.messages.EditMessageRequest.prototype.getJid = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 2, ""));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @return {!proto.messages.EditMessageRequest} returns this
|
||||
*/
|
||||
proto.messages.EditMessageRequest.prototype.setJid = function(value) {
|
||||
return jspb.Message.setProto3StringField(this, 2, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string messageId = 4;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.messages.EditMessageRequest.prototype.getMessageid = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 4, ""));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @return {!proto.messages.EditMessageRequest} returns this
|
||||
*/
|
||||
proto.messages.EditMessageRequest.prototype.setMessageid = function(value) {
|
||||
return jspb.Message.setProto3StringField(this, 4, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional string text = 5;
|
||||
* @return {string}
|
||||
*/
|
||||
proto.messages.EditMessageRequest.prototype.getText = function() {
|
||||
return /** @type {string} */ (jspb.Message.getFieldWithDefault(this, 5, ""));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {string} value
|
||||
* @return {!proto.messages.EditMessageRequest} returns this
|
||||
*/
|
||||
proto.messages.EditMessageRequest.prototype.setText = function(value) {
|
||||
return jspb.Message.setProto3StringField(this, 5, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional bool linkPreview = 6;
|
||||
* @return {boolean}
|
||||
*/
|
||||
proto.messages.EditMessageRequest.prototype.getLinkpreview = function() {
|
||||
return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 6, false));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {boolean} value
|
||||
* @return {!proto.messages.EditMessageRequest} returns this
|
||||
*/
|
||||
proto.messages.EditMessageRequest.prototype.setLinkpreview = function(value) {
|
||||
return jspb.Message.setProto3BooleanField(this, 6, value);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* optional bool linkPreviewHighQuality = 7;
|
||||
* @return {boolean}
|
||||
*/
|
||||
proto.messages.EditMessageRequest.prototype.getLinkpreviewhighquality = function() {
|
||||
return /** @type {boolean} */ (jspb.Message.getBooleanFieldWithDefault(this, 7, false));
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {boolean} value
|
||||
* @return {!proto.messages.EditMessageRequest} returns this
|
||||
*/
|
||||
proto.messages.EditMessageRequest.prototype.setLinkpreviewhighquality = function(value) {
|
||||
return jspb.Message.setProto3BooleanField(this, 7, value);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (jspb.Message.GENERATE_TO_OBJECT) {
|
||||
/**
|
||||
* Creates an object representation of this proto.
|
||||
|
||||
@@ -8,19 +8,33 @@ import * as grpc from '@grpc/grpc-js';
|
||||
import { connectivityState } from '@grpc/grpc-js';
|
||||
import { UnprocessableEntityException } from '@nestjs/common';
|
||||
import {
|
||||
extractDeviceId,
|
||||
getChannelInviteLink,
|
||||
WhatsappSession,
|
||||
} from '@waha/core/abc/session.abc';
|
||||
import { Jid } from '@waha/core/engines/const';
|
||||
import { EventsFromObservable } from '@waha/core/engines/gows/EventsFromObservable';
|
||||
import { GowsEventStreamObservable } from '@waha/core/engines/gows/GowsEventStreamObservable';
|
||||
import {
|
||||
ToGroupV2JoinEvent,
|
||||
ToGroupV2LeaveEvent,
|
||||
ToGroupV2ParticipantsEvents,
|
||||
ToGroupV2UpdateEvent,
|
||||
} from '@waha/core/engines/gows/groups.gows';
|
||||
import { messages } from '@waha/core/engines/gows/grpc/gows';
|
||||
import {
|
||||
optional,
|
||||
parseJson,
|
||||
parseJsonList,
|
||||
statusToAck,
|
||||
} from '@waha/core/engines/gows/helpers';
|
||||
import { GowsAuthFactoryCore } from '@waha/core/engines/gows/store/GowsAuthFactoryCore';
|
||||
import {
|
||||
parseMessageIdSerialized,
|
||||
toCusFormat,
|
||||
toJID,
|
||||
} from '@waha/core/engines/noweb/session.noweb.core';
|
||||
import { extractMediaContent } from '@waha/core/engines/noweb/utils';
|
||||
import {
|
||||
AvailableInPlusVersion,
|
||||
NotImplementedByEngineError,
|
||||
@@ -38,9 +52,17 @@ import {
|
||||
ListChannelsQuery,
|
||||
PreviewChannelMessages,
|
||||
} from '@waha/structures/channels.dto';
|
||||
import {
|
||||
ChatSortField,
|
||||
ChatSummary,
|
||||
GetChatMessageQuery,
|
||||
GetChatMessagesFilter,
|
||||
GetChatMessagesQuery,
|
||||
} from '@waha/structures/chats.dto';
|
||||
import {
|
||||
ChatRequest,
|
||||
CheckNumberStatusQuery,
|
||||
EditMessageRequest,
|
||||
MessageFileRequest,
|
||||
MessageForwardRequest,
|
||||
MessageImageRequest,
|
||||
@@ -52,6 +74,7 @@ import {
|
||||
SendSeenRequest,
|
||||
WANumberExistResult,
|
||||
} from '@waha/structures/chatting.dto';
|
||||
import { ContactQuery } from '@waha/structures/contacts.dto';
|
||||
import {
|
||||
ACK_UNKNOWN,
|
||||
WAHAEvents,
|
||||
@@ -59,14 +82,33 @@ import {
|
||||
WAHASessionStatus,
|
||||
WAMessageAck,
|
||||
} from '@waha/structures/enums.dto';
|
||||
import { BinaryFile, RemoteFile } from '@waha/structures/files.dto';
|
||||
import {
|
||||
CreateGroupRequest,
|
||||
GroupSortField,
|
||||
Participant,
|
||||
ParticipantsRequest,
|
||||
SettingsSecurityChangeInfo,
|
||||
} from '@waha/structures/groups.dto';
|
||||
import { PaginationParams, SortOrder } from '@waha/structures/pagination.dto';
|
||||
import {
|
||||
WAHAChatPresences,
|
||||
WAHAPresenceData,
|
||||
} from '@waha/structures/presence.dto';
|
||||
import { WAMessage, WAMessageReaction } from '@waha/structures/responses.dto';
|
||||
import {
|
||||
MessageSource,
|
||||
WAMessage,
|
||||
WAMessageReaction,
|
||||
} from '@waha/structures/responses.dto';
|
||||
import { MeInfo, ProxyConfig } from '@waha/structures/sessions.dto';
|
||||
import { StatusRequest, TextStatus } from '@waha/structures/status.dto';
|
||||
import {
|
||||
BROADCAST_ID,
|
||||
DeleteStatusRequest,
|
||||
StatusRequest,
|
||||
TextStatus,
|
||||
} from '@waha/structures/status.dto';
|
||||
import { EnginePayload, WAMessageAckBody } from '@waha/structures/webhooks.dto';
|
||||
import { PaginatorInMemory } from '@waha/utils/Paginator';
|
||||
import { sleep, waitUntil } from '@waha/utils/promiseTimeout';
|
||||
import { onlyEvent } from '@waha/utils/reactive/ops/onlyEvent';
|
||||
import * as NodeCache from 'node-cache';
|
||||
@@ -86,37 +128,6 @@ import { promisify } from 'util';
|
||||
|
||||
import * as gows from './types';
|
||||
import MessageServiceClient = messages.MessageServiceClient;
|
||||
import {
|
||||
ToGroupV2JoinEvent,
|
||||
ToGroupV2LeaveEvent,
|
||||
ToGroupV2ParticipantsEvents,
|
||||
ToGroupV2UpdateEvent,
|
||||
} from '@waha/core/engines/gows/groups.gows';
|
||||
import {
|
||||
optional,
|
||||
parseJson,
|
||||
parseJsonList,
|
||||
statusToAck,
|
||||
} from '@waha/core/engines/gows/helpers';
|
||||
import { extractMediaContent } from '@waha/core/engines/noweb/utils';
|
||||
import {
|
||||
ChatSortField,
|
||||
ChatSummary,
|
||||
GetChatMessageQuery,
|
||||
GetChatMessagesFilter,
|
||||
GetChatMessagesQuery,
|
||||
} from '@waha/structures/chats.dto';
|
||||
import { ContactQuery } from '@waha/structures/contacts.dto';
|
||||
import { BinaryFile, RemoteFile } from '@waha/structures/files.dto';
|
||||
import {
|
||||
CreateGroupRequest,
|
||||
GroupSortField,
|
||||
Participant,
|
||||
ParticipantsRequest,
|
||||
SettingsSecurityChangeInfo,
|
||||
} from '@waha/structures/groups.dto';
|
||||
import { PaginationParams, SortOrder } from '@waha/structures/pagination.dto';
|
||||
import { PaginatorInMemory } from '@waha/utils/Paginator';
|
||||
|
||||
enum WhatsMeowEvent {
|
||||
CONNECTED = 'gows.ConnectedEventData',
|
||||
@@ -250,6 +261,8 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
|
||||
id: toCusFormat(jidNormalizedUser(data.ID)),
|
||||
pushName: data.PushName,
|
||||
};
|
||||
// @ts-ignore
|
||||
this.me.jid = data.ID;
|
||||
});
|
||||
|
||||
events.on(WhatsMeowEvent.DISCONNECTED, () => {
|
||||
@@ -530,12 +543,49 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
|
||||
jid: jid,
|
||||
text: request.text,
|
||||
session: this.session,
|
||||
linkPreview: request.linkPreview ?? true,
|
||||
linkPreviewHighQuality: request.linkPreviewHighQuality,
|
||||
replyTo: getMessageIdFromSerialized(request.reply_to),
|
||||
});
|
||||
const response = await promisify(this.client.SendMessage)(message);
|
||||
const data = response.toObject();
|
||||
return this.messageResponse(jid, data);
|
||||
}
|
||||
|
||||
public async editMessage(
|
||||
chatId: string,
|
||||
messageId: string,
|
||||
request: EditMessageRequest,
|
||||
) {
|
||||
const jid = toJID(this.ensureSuffix(chatId));
|
||||
const key = parseMessageIdSerialized(messageId, true);
|
||||
const message = new messages.EditMessageRequest({
|
||||
session: this.session,
|
||||
jid: jid,
|
||||
messageId: key.id,
|
||||
text: request.text,
|
||||
linkPreview: request.linkPreview ?? true,
|
||||
linkPreviewHighQuality: request.linkPreviewHighQuality,
|
||||
});
|
||||
const response = await promisify(this.client.EditMessage)(message);
|
||||
const data = response.toObject();
|
||||
return this.messageResponse(jid, data);
|
||||
}
|
||||
|
||||
public async deleteMessage(chatId: string, messageId: string) {
|
||||
const jid = toJID(this.ensureSuffix(chatId));
|
||||
const key = parseMessageIdSerialized(messageId);
|
||||
const message = new messages.RevokeMessageRequest({
|
||||
session: this.session,
|
||||
jid: jid,
|
||||
sender: key.participant || '',
|
||||
messageId: key.id,
|
||||
});
|
||||
const response = await promisify(this.client.RevokeMessage)(message);
|
||||
const data = response.toObject();
|
||||
return this.messageResponse(jid, data);
|
||||
}
|
||||
|
||||
protected checkStatusRequest(request: StatusRequest) {
|
||||
if (request.contacts && request.contacts?.length > 0) {
|
||||
const msg =
|
||||
@@ -557,13 +607,30 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
|
||||
font: new messages.OptionalUInt32({
|
||||
value: status.font,
|
||||
}),
|
||||
linkPreview: status.linkPreview ?? true,
|
||||
linkPreviewHighQuality: status.linkPreviewHighQuality,
|
||||
});
|
||||
const response = await promisify(this.client.SendMessage)(message);
|
||||
const data = response.toObject();
|
||||
return this.messageResponse(Jid.BROADCAST, data);
|
||||
}
|
||||
|
||||
public async deleteStatus(request: DeleteStatusRequest) {
|
||||
this.checkStatusRequest(request);
|
||||
const key = parseMessageIdSerialized(request.id, true);
|
||||
const message = new messages.RevokeMessageRequest({
|
||||
session: this.session,
|
||||
jid: BROADCAST_ID,
|
||||
sender: '',
|
||||
messageId: key.id,
|
||||
});
|
||||
const response = await promisify(this.client.RevokeMessage)(message);
|
||||
const data = response.toObject();
|
||||
return this.messageResponse(BROADCAST_ID, data);
|
||||
}
|
||||
|
||||
protected messageResponse(jid, data) {
|
||||
const message = parseJson(data.message);
|
||||
const id = buildMessageId({
|
||||
ID: data.id,
|
||||
IsFromMe: true,
|
||||
@@ -573,7 +640,7 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
|
||||
});
|
||||
return {
|
||||
id: id,
|
||||
_data: data,
|
||||
_data: message,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1296,6 +1363,8 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
|
||||
if (message.Message.pollUpdateMessage) return;
|
||||
// Ignore protocol messages
|
||||
if (message.Message.protocolMessage) return;
|
||||
// Ignore key distribution messages
|
||||
if (message.Message.senderKeyDistributionMessage) return;
|
||||
|
||||
if (downloadMedia) {
|
||||
try {
|
||||
@@ -1318,7 +1387,6 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
|
||||
const id = buildMessageId(message);
|
||||
const body = this.extractBody(message.Message);
|
||||
const replyTo = null; // TODO: this.extractReplyTo(message.message);
|
||||
|
||||
let ack;
|
||||
if (message.Status) {
|
||||
ack = statusToAck(message.Status);
|
||||
@@ -1326,12 +1394,14 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
|
||||
ack = message.Info.IsFromMe ? WAMessageAck.SERVER : WAMessageAck.DEVICE;
|
||||
}
|
||||
const mediaContent = extractMediaContent(message.Message);
|
||||
const source = this.getSourceDeviceByMsg(message);
|
||||
|
||||
return {
|
||||
id: id,
|
||||
timestamp: parseTimestampToSeconds(message.Info.Timestamp),
|
||||
from: toCusFormat(fromToParticipant.from),
|
||||
fromMe: message.Info.IsFromMe,
|
||||
source: source,
|
||||
body: body,
|
||||
to: toCusFormat(fromToParticipant.to),
|
||||
participant: toCusFormat(fromToParticipant.participant),
|
||||
@@ -1348,6 +1418,17 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
|
||||
};
|
||||
}
|
||||
|
||||
private getSourceDeviceByMsg(message): MessageSource {
|
||||
if (!message.Info.IsFromMe) {
|
||||
return MessageSource.APP;
|
||||
}
|
||||
// @ts-ignore
|
||||
const myJid = this.me.jid;
|
||||
const myDeviceId = extractDeviceId(myJid);
|
||||
const sentDeviceId = extractDeviceId(message.Info.Sender);
|
||||
return sentDeviceId === myDeviceId ? MessageSource.API : MessageSource.APP;
|
||||
}
|
||||
|
||||
private extractBody(message) {
|
||||
if (!message) {
|
||||
return null;
|
||||
@@ -1454,11 +1535,13 @@ export class WhatsappSessionGoWSCore extends WhatsappSession {
|
||||
const fromToParticipant = getFromToParticipant(message);
|
||||
const reactionMessage = message.Message.reactionMessage;
|
||||
const messageId = this.buildMessageIdFromKey(reactionMessage.key);
|
||||
const source = this.getSourceDeviceByMsg(message);
|
||||
const reaction: WAMessageReaction = {
|
||||
id: id,
|
||||
timestamp: parseTimestampToSeconds(message.Info.Timestamp),
|
||||
from: toCusFormat(fromToParticipant.from),
|
||||
fromMe: message.Info.IsFromMe,
|
||||
source: source,
|
||||
to: toCusFormat(fromToParticipant.to),
|
||||
participant: toCusFormat(fromToParticipant.participant),
|
||||
reaction: {
|
||||
@@ -1576,3 +1659,11 @@ function parseTimestampToSeconds(timestamp: string): number {
|
||||
}
|
||||
return Math.floor(ms / 1000);
|
||||
}
|
||||
|
||||
export function getMessageIdFromSerialized(serialized: string): string | null {
|
||||
if (!serialized) {
|
||||
return null;
|
||||
}
|
||||
const key = parseMessageIdSerialized(serialized, true);
|
||||
return key.id;
|
||||
}
|
||||
@@ -5,10 +5,10 @@ import makeWASocket, {
|
||||
DisconnectReason,
|
||||
downloadMediaMessage,
|
||||
extractMessageContent,
|
||||
generateMessageIDV2,
|
||||
getAggregateVotesInPollMessage,
|
||||
getContentType,
|
||||
getKeyAuthor,
|
||||
getUrlFromDirectPath,
|
||||
isJidGroup,
|
||||
isJidNewsletter,
|
||||
isJidStatusBroadcast,
|
||||
@@ -16,6 +16,7 @@ import makeWASocket, {
|
||||
isRealMessage,
|
||||
jidNormalizedUser,
|
||||
makeCacheableSignalKeyStore,
|
||||
MiscMessageGenerationOptions,
|
||||
NewsletterMetadata,
|
||||
normalizeMessageContent,
|
||||
PresenceData,
|
||||
@@ -40,6 +41,13 @@ import { MessageUserReceiptUpdate } from '@adiwajshing/baileys/lib/Types/Message
|
||||
import { isLidUser } from '@adiwajshing/baileys/lib/WABinary/jid-utils';
|
||||
import { Logger as BaileysLogger } from '@adiwajshing/baileys/node_modules/pino';
|
||||
import { UnprocessableEntityException } from '@nestjs/common';
|
||||
import {
|
||||
ensureSuffix,
|
||||
getChannelInviteLink,
|
||||
getPublicUrlFromDirectPath,
|
||||
isNewsletter,
|
||||
WhatsappSession,
|
||||
} from '@waha/core/abc/session.abc';
|
||||
import {
|
||||
ToGroupV2JoinEvent,
|
||||
ToGroupV2LeaveEvent,
|
||||
@@ -47,8 +55,16 @@ import {
|
||||
ToGroupV2UpdateEvent,
|
||||
} from '@waha/core/engines/noweb/groups.noweb';
|
||||
import { sendButtonMessage } from '@waha/core/engines/noweb/noweb.buttons';
|
||||
import { NowebAuthFactoryCore } from '@waha/core/engines/noweb/NowebAuthFactoryCore';
|
||||
import { NowebInMemoryStore } from '@waha/core/engines/noweb/store/NowebInMemoryStore';
|
||||
import {
|
||||
AvailableInPlusVersion,
|
||||
NotImplementedByEngineError,
|
||||
} from '@waha/core/exceptions';
|
||||
import { toVcard } from '@waha/core/helpers';
|
||||
import { createAgentProxy } from '@waha/core/helpers.proxy';
|
||||
import { IMediaEngineProcessor } from '@waha/core/media/IMediaEngineProcessor';
|
||||
import { QR } from '@waha/core/QR';
|
||||
import { flipObject, splitAt } from '@waha/helpers';
|
||||
import { PairingCodeResponse } from '@waha/structures/auth.dto';
|
||||
import { CallData } from '@waha/structures/calls.dto';
|
||||
@@ -71,8 +87,42 @@ import {
|
||||
PinDuration,
|
||||
} from '@waha/structures/chats.dto';
|
||||
import { SendButtonsRequest } from '@waha/structures/chatting.buttons.dto';
|
||||
import {
|
||||
ChatRequest,
|
||||
CheckNumberStatusQuery,
|
||||
EditMessageRequest,
|
||||
MessageContactVcardRequest,
|
||||
MessageDestination,
|
||||
MessageFileRequest,
|
||||
MessageForwardRequest,
|
||||
MessageImageRequest,
|
||||
MessageLinkPreviewRequest,
|
||||
MessageLocationRequest,
|
||||
MessagePollRequest,
|
||||
MessageReactionRequest,
|
||||
MessageReplyRequest,
|
||||
MessageStarRequest,
|
||||
MessageTextRequest,
|
||||
MessageVoiceRequest,
|
||||
SendSeenRequest,
|
||||
WANumberExistResult,
|
||||
} from '@waha/structures/chatting.dto';
|
||||
import { ContactQuery, ContactRequest } from '@waha/structures/contacts.dto';
|
||||
import {
|
||||
ACK_UNKNOWN,
|
||||
SECOND,
|
||||
WAHAEngine,
|
||||
WAHAEvents,
|
||||
WAHAPresenceStatus,
|
||||
WAHASessionStatus,
|
||||
WAMessageAck,
|
||||
} from '@waha/structures/enums.dto';
|
||||
import { BinaryFile, RemoteFile } from '@waha/structures/files.dto';
|
||||
import {
|
||||
CreateGroupRequest,
|
||||
ParticipantsRequest,
|
||||
SettingsSecurityChangeInfo,
|
||||
} from '@waha/structures/groups.dto';
|
||||
import {
|
||||
Label,
|
||||
LabelChatAssociation,
|
||||
@@ -81,6 +131,17 @@ import {
|
||||
} from '@waha/structures/labels.dto';
|
||||
import { ReplyToMessage } from '@waha/structures/message.dto';
|
||||
import { PaginationParams } from '@waha/structures/pagination.dto';
|
||||
import {
|
||||
WAHAChatPresences,
|
||||
WAHAPresenceData,
|
||||
} from '@waha/structures/presence.dto';
|
||||
import { WAMessage, WAMessageReaction } from '@waha/structures/responses.dto';
|
||||
import { MeInfo } from '@waha/structures/sessions.dto';
|
||||
import {
|
||||
BROADCAST_ID,
|
||||
DeleteStatusRequest,
|
||||
TextStatus,
|
||||
} from '@waha/structures/status.dto';
|
||||
import {
|
||||
EnginePayload,
|
||||
PollVote,
|
||||
@@ -107,73 +168,9 @@ import {
|
||||
Observable,
|
||||
partition,
|
||||
share,
|
||||
Subject,
|
||||
} from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import {
|
||||
ChatRequest,
|
||||
CheckNumberStatusQuery,
|
||||
EditMessageRequest,
|
||||
MessageContactVcardRequest,
|
||||
MessageDestination,
|
||||
MessageFileRequest,
|
||||
MessageForwardRequest,
|
||||
MessageImageRequest,
|
||||
MessageLinkPreviewRequest,
|
||||
MessageLocationRequest,
|
||||
MessagePollRequest,
|
||||
MessageReactionRequest,
|
||||
MessageReplyRequest,
|
||||
MessageStarRequest,
|
||||
MessageTextRequest,
|
||||
MessageVoiceRequest,
|
||||
SendSeenRequest,
|
||||
WANumberExistResult,
|
||||
} from '../../../structures/chatting.dto';
|
||||
import {
|
||||
ACK_UNKNOWN,
|
||||
SECOND,
|
||||
WAHAEngine,
|
||||
WAHAEvents,
|
||||
WAHAPresenceStatus,
|
||||
WAHASessionStatus,
|
||||
WAMessageAck,
|
||||
} from '../../../structures/enums.dto';
|
||||
import {
|
||||
CreateGroupRequest,
|
||||
ParticipantsRequest,
|
||||
SettingsSecurityChangeInfo,
|
||||
} from '../../../structures/groups.dto';
|
||||
import {
|
||||
WAHAChatPresences,
|
||||
WAHAPresenceData,
|
||||
} from '../../../structures/presence.dto';
|
||||
import {
|
||||
WAMessage,
|
||||
WAMessageReaction,
|
||||
} from '../../../structures/responses.dto';
|
||||
import { MeInfo } from '../../../structures/sessions.dto';
|
||||
import {
|
||||
BROADCAST_ID,
|
||||
DeleteStatusRequest,
|
||||
TextStatus,
|
||||
} from '../../../structures/status.dto';
|
||||
import {
|
||||
ensureSuffix,
|
||||
getChannelInviteLink,
|
||||
getPublicUrlFromDirectPath,
|
||||
isNewsletter,
|
||||
WhatsappSession,
|
||||
} from '../../abc/session.abc';
|
||||
import {
|
||||
AvailableInPlusVersion,
|
||||
NotImplementedByEngineError,
|
||||
} from '../../exceptions';
|
||||
import { toVcard } from '../../helpers';
|
||||
import { createAgentProxy } from '../../helpers.proxy';
|
||||
import { QR } from '../../QR';
|
||||
import { NowebAuthFactoryCore } from './NowebAuthFactoryCore';
|
||||
import { INowebStore } from './store/INowebStore';
|
||||
import { NowebPersistentStore } from './store/NowebPersistentStore';
|
||||
import { NowebStorageFactoryCore } from './store/NowebStorageFactoryCore';
|
||||
@@ -701,14 +698,18 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
mentions: request.mentions?.map(toJID),
|
||||
linkPreview: this.getLinkPreview(request),
|
||||
};
|
||||
const options = await this.getMessageOptions(request);
|
||||
const options: any = await this.getMessageOptions(request);
|
||||
options.linkPreviewHighQuality = request.linkPreviewHighQuality;
|
||||
return this.sock.sendMessage(chatId, message, options);
|
||||
}
|
||||
|
||||
public deleteMessage(chatId: string, messageId: string) {
|
||||
const jid = toJID(this.ensureSuffix(chatId));
|
||||
const key = parseMessageIdSerialized(messageId);
|
||||
return this.sock.sendMessage(jid, { delete: key });
|
||||
const options = {
|
||||
messageId: this.generateMessageID(),
|
||||
};
|
||||
return this.sock.sendMessage(jid, { delete: key }, options);
|
||||
}
|
||||
|
||||
public editMessage(
|
||||
@@ -722,18 +723,21 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
text: request.text,
|
||||
mentions: request.mentions?.map(toJID),
|
||||
edit: key,
|
||||
linkPreview: this.getLinkPreview(request),
|
||||
linkPreviewHighQuality: request.linkPreviewHighQuality,
|
||||
};
|
||||
return this.sock.sendMessage(jid, message);
|
||||
const options = {
|
||||
messageId: this.generateMessageID(),
|
||||
};
|
||||
return this.sock.sendMessage(jid, message, options);
|
||||
}
|
||||
|
||||
async sendContactVCard(request: MessageContactVcardRequest) {
|
||||
const chatId = toJID(this.ensureSuffix(request.chatId));
|
||||
const contacts = request.contacts.map((el) => ({ vcard: toVcard(el) }));
|
||||
await this.sock.sendMessage(chatId, {
|
||||
contacts: {
|
||||
contacts: contacts,
|
||||
},
|
||||
});
|
||||
const options = await this.getMessageOptions(request);
|
||||
const msg = { contacts: { contacts: contacts } };
|
||||
return await this.sock.sendMessage(chatId, msg, options);
|
||||
}
|
||||
|
||||
async sendPoll(request: MessagePollRequest) {
|
||||
@@ -797,13 +801,15 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
);
|
||||
}
|
||||
|
||||
sendLocation(request: MessageLocationRequest) {
|
||||
return this.sock.sendMessage(request.chatId, {
|
||||
async sendLocation(request: MessageLocationRequest) {
|
||||
const msg = {
|
||||
location: {
|
||||
degreesLatitude: request.latitude,
|
||||
degreesLongitude: request.longitude,
|
||||
},
|
||||
});
|
||||
};
|
||||
const options = await this.getMessageOptions(request);
|
||||
return await this.sock.sendMessage(request.chatId, msg, options);
|
||||
}
|
||||
|
||||
async forwardMessage(request: MessageForwardRequest): Promise<WAMessage> {
|
||||
@@ -819,14 +825,17 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
forward: forwardMessage,
|
||||
force: true,
|
||||
};
|
||||
const result = await this.sock.sendMessage(chatId, message, {});
|
||||
const options = await this.getMessageOptions(request);
|
||||
const result = await this.sock.sendMessage(chatId, message, options);
|
||||
return this.toWAMessage(result);
|
||||
}
|
||||
|
||||
sendLinkPreview(request: MessageLinkPreviewRequest) {
|
||||
async sendLinkPreview(request: MessageLinkPreviewRequest) {
|
||||
const text = `${request.title}\n${request.url}`;
|
||||
const chatId = toJID(this.ensureSuffix(request.chatId));
|
||||
return this.sock.sendMessage(chatId, { text: text });
|
||||
const msg = { text: text };
|
||||
const options = await this.getMessageOptions(request);
|
||||
return this.sock.sendMessage(chatId, msg, options);
|
||||
}
|
||||
|
||||
async sendSeen(request: SendSeenRequest) {
|
||||
@@ -1322,14 +1331,19 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
* Status methods
|
||||
*/
|
||||
public async sendTextStatus(status: TextStatus) {
|
||||
const message = { text: status.text };
|
||||
const message = {
|
||||
text: status.text,
|
||||
linkPreview: this.getLinkPreview(status),
|
||||
};
|
||||
const jids = await this.prepareJidsForStatus(status.contacts);
|
||||
const options = {
|
||||
const messageId = this.generateMessageID();
|
||||
const options: MiscMessageGenerationOptions = {
|
||||
backgroundColor: status.backgroundColor,
|
||||
font: status.font,
|
||||
statusJidList: jids,
|
||||
linkPreviewHighQuality: status.linkPreviewHighQuality,
|
||||
messageId: messageId,
|
||||
};
|
||||
|
||||
return await this.sock.sendMessage(BROADCAST_ID, message, options);
|
||||
}
|
||||
|
||||
@@ -1356,8 +1370,10 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
key.fromMe = true;
|
||||
key.remoteJid = BROADCAST_ID;
|
||||
const jids = await this.prepareJidsForStatus(request.contacts);
|
||||
const newMessageId = this.generateMessageID();
|
||||
const options = {
|
||||
statusJidList: jids,
|
||||
messageId: newMessageId,
|
||||
};
|
||||
return await this.sock.sendMessage(BROADCAST_ID, { delete: key }, options);
|
||||
}
|
||||
@@ -1757,11 +1773,13 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
const fromToParticipant = getFromToParticipant(message);
|
||||
const reactionMessage = message.message.reactionMessage;
|
||||
const messageId = buildMessageId(reactionMessage.key);
|
||||
const source = this.getMessageSource(message.key.id);
|
||||
const reaction: WAMessageReaction = {
|
||||
id: id,
|
||||
timestamp: ensureNumber(message.messageTimestamp),
|
||||
from: toCusFormat(fromToParticipant.from),
|
||||
fromMe: message.key.fromMe,
|
||||
source: source,
|
||||
to: toCusFormat(fromToParticipant.to),
|
||||
participant: toCusFormat(fromToParticipant.participant),
|
||||
reaction: {
|
||||
@@ -1780,6 +1798,8 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
if (message.message.reactionMessage) return;
|
||||
// Ignore poll votes, we have dedicated handler for that
|
||||
if (message.message.pollUpdateMessage) return;
|
||||
// Ignore calls, we have dedicated handler for that
|
||||
if (message.message.call?.callKey) return;
|
||||
// Ignore revoke, we have a dedicated handler for that
|
||||
if (
|
||||
message.message.protocolMessage?.type ===
|
||||
@@ -1818,11 +1838,13 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
const replyTo = this.extractReplyTo(message.message);
|
||||
const ack = message.ack || message.status - 1;
|
||||
const mediaContent = extractMediaContent(message.message);
|
||||
const source = this.getMessageSource(message.key.id);
|
||||
return Promise.resolve({
|
||||
id: id,
|
||||
timestamp: ensureNumber(message.messageTimestamp),
|
||||
from: toCusFormat(fromToParticipant.from),
|
||||
fromMe: message.key.fromMe,
|
||||
source: source,
|
||||
body: body || null,
|
||||
to: toCusFormat(fromToParticipant.to),
|
||||
participant: toCusFormat(fromToParticipant.participant),
|
||||
@@ -2055,15 +2077,23 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
return this.mediaManager.processMedia(processor, message, this.name);
|
||||
}
|
||||
|
||||
protected async getMessageOptions(request: any): Promise<any> {
|
||||
protected async getMessageOptions(request: {
|
||||
chatId: string;
|
||||
reply_to?: string;
|
||||
}) {
|
||||
const jid = toJID(request.chatId);
|
||||
|
||||
let quoted;
|
||||
if (request.reply_to) {
|
||||
const key = parseMessageIdSerialized(request.reply_to, true);
|
||||
quoted = await this.store.loadMessage(toJID(request.chatId), key.id);
|
||||
quoted = await this.store.loadMessage(jid, key.id);
|
||||
}
|
||||
|
||||
const chat = await this.store.getChat(jid);
|
||||
const messageId = this.generateMessageID();
|
||||
return {
|
||||
quoted: quoted,
|
||||
ephemeralExpiration: chat?.ephemeralExpiration,
|
||||
messageId: messageId,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2082,6 +2112,12 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
}
|
||||
return linkPreview;
|
||||
}
|
||||
|
||||
protected generateMessageID() {
|
||||
const id = generateMessageIDV2(this.sock.user?.id);
|
||||
this.saveSentMessageId(id);
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
function hasPath(url: string) {
|
||||
|
||||
@@ -8,6 +8,8 @@ export interface IMessagesRepository {
|
||||
|
||||
upsertOne(message: any): Promise<void>;
|
||||
|
||||
getById(id: string): Promise<any | null>;
|
||||
|
||||
getAllByJid(
|
||||
jid: string,
|
||||
filter: GetChatMessagesFilter,
|
||||
|
||||
@@ -30,6 +30,8 @@ export interface INowebStore {
|
||||
|
||||
getChats(pagination: PaginationParams, broadcast: boolean): Promise<Chat[]>;
|
||||
|
||||
getChat(jid: string): Promise<Chat | null>;
|
||||
|
||||
getContacts(pagination: PaginationParams): Promise<Contact[]>;
|
||||
|
||||
getContactById(jid: string): Promise<Contact>;
|
||||
|
||||
@@ -65,6 +65,10 @@ export class NowebInMemoryStore implements INowebStore {
|
||||
throw new BadRequestException(this.errorMessage);
|
||||
}
|
||||
|
||||
getChat(jid: string): Promise<Chat | null> {
|
||||
return null;
|
||||
}
|
||||
|
||||
getContacts(pagination: PaginationParams): Promise<Contact[]> {
|
||||
throw new BadRequestException(this.errorMessage);
|
||||
}
|
||||
@@ -91,7 +95,7 @@ export class NowebInMemoryStore implements INowebStore {
|
||||
|
||||
async getGroups(pagination: PaginationParams): Promise<GroupMetadata[]> {
|
||||
const response = await this.socket?.groupFetchAllParticipating();
|
||||
const groups = Object.values(response);
|
||||
const groups: any[] = Object.values(response);
|
||||
const paginator = new PaginatorInMemory(pagination);
|
||||
return paginator.apply(groups);
|
||||
}
|
||||
|
||||
@@ -430,7 +430,12 @@ export class NowebPersistentStore implements INowebStore {
|
||||
}
|
||||
|
||||
async loadMessage(jid: string, id: string) {
|
||||
const data = await this.messagesRepo.getByJidById(jid, id);
|
||||
let data;
|
||||
if (!jid) {
|
||||
data = await this.messagesRepo.getById(id);
|
||||
} else {
|
||||
data = await this.messagesRepo.getByJidById(jid, id);
|
||||
}
|
||||
if (!data) {
|
||||
return null;
|
||||
}
|
||||
@@ -457,6 +462,10 @@ export class NowebPersistentStore implements INowebStore {
|
||||
return this.chatRepo.getAllWithMessages(pagination, broadcast);
|
||||
}
|
||||
|
||||
async getChat(jid: string): Promise<Chat | null> {
|
||||
return await this.chatRepo.getById(jid);
|
||||
}
|
||||
|
||||
private shouldFetchGroup(): boolean {
|
||||
const timePassed = new Date().getTime() - this.lastTimeGroupFetch.getTime();
|
||||
return timePassed > this.GROUP_METADATA_CACHE_TIME;
|
||||
|
||||
@@ -2,9 +2,11 @@ import { GetChatMessagesFilter } from '@waha/structures/chats.dto';
|
||||
import { Label } from '@waha/structures/labels.dto';
|
||||
import { PaginationParams } from '@waha/structures/pagination.dto';
|
||||
import { TextStatus } from '@waha/structures/status.dto';
|
||||
import { EventEmitter } from 'events';
|
||||
import * as lodash from 'lodash';
|
||||
import { Client, Events } from 'whatsapp-web.js';
|
||||
import { Message } from 'whatsapp-web.js/src/structures';
|
||||
import { exposeFunctionIfAbsent } from 'whatsapp-web.js/src/util/Puppeter';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const { LoadWAHA } = require('./_WAHA.js');
|
||||
@@ -19,10 +21,13 @@ const { LoadPaginator } = require('./_Paginator.js');
|
||||
const ChatFactory = require('whatsapp-web.js/src/factories/ChatFactory');
|
||||
|
||||
export class WebjsClientCore extends Client {
|
||||
public events = new EventEmitter();
|
||||
|
||||
constructor(options) {
|
||||
super(options);
|
||||
// Wait until it's READY and inject more utils
|
||||
this.on(Events.READY, async () => {
|
||||
await this.attachCustomEventListeners();
|
||||
await this.injectWaha();
|
||||
});
|
||||
}
|
||||
@@ -33,6 +38,22 @@ export class WebjsClientCore extends Client {
|
||||
await this.pupPage.evaluate(LoadWAHA);
|
||||
}
|
||||
|
||||
async attachCustomEventListeners() {
|
||||
await exposeFunctionIfAbsent(
|
||||
this.pupPage,
|
||||
'onNewMessageId',
|
||||
(messageId: string) => {
|
||||
this.events.emit('message.id', { id: messageId });
|
||||
return;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
async destroy() {
|
||||
this.events.removeAllListeners();
|
||||
await super.destroy();
|
||||
}
|
||||
|
||||
async setPushName(name: string) {
|
||||
await this.pupPage.evaluate(async (pushName) => {
|
||||
return await window['WAHA'].WAWebSetPushnameConnAction.setPushname(
|
||||
|
||||
@@ -73,7 +73,11 @@ import {
|
||||
import { Label, LabelDTO, LabelID } from '@waha/structures/labels.dto';
|
||||
import { ReplyToMessage } from '@waha/structures/message.dto';
|
||||
import { PaginationParams, SortOrder } from '@waha/structures/pagination.dto';
|
||||
import { WAMessage, WAMessageReaction } from '@waha/structures/responses.dto';
|
||||
import {
|
||||
MessageSource,
|
||||
WAMessage,
|
||||
WAMessageReaction,
|
||||
} from '@waha/structures/responses.dto';
|
||||
import { MeInfo } from '@waha/structures/sessions.dto';
|
||||
import { StatusRequest, TextStatus } from '@waha/structures/status.dto';
|
||||
import {
|
||||
@@ -510,6 +514,7 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
|
||||
const options = {
|
||||
// It's fine to sent just ids instead of Contact object
|
||||
mentions: request.mentions as unknown as string[],
|
||||
linkPreview: request.linkPreview,
|
||||
};
|
||||
return message.edit(request.text, options);
|
||||
}
|
||||
@@ -1047,7 +1052,7 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
|
||||
|
||||
// Exclude GUEST, browser saves the data
|
||||
// when we search channels or getting messages
|
||||
channels = channels.filter((channel) => channel.role === 'GUEST');
|
||||
channels = channels.filter((channel) => channel.role !== 'GUEST');
|
||||
|
||||
const promises = channels.map(async (channel) =>
|
||||
this.whatsapp.getProfilePicUrl(channel.id),
|
||||
@@ -1153,6 +1158,11 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
|
||||
* END - Methods for API
|
||||
*/
|
||||
subscribeEngineEvents2() {
|
||||
// Save sent message in cache
|
||||
this.whatsapp.events.on('message.id', (data) => {
|
||||
this.saveSentMessageId(data.id);
|
||||
});
|
||||
|
||||
//
|
||||
// All
|
||||
//
|
||||
@@ -1352,10 +1362,12 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
|
||||
}
|
||||
|
||||
private processMessageReaction(reaction: Reaction): WAMessageReaction {
|
||||
const source = this.getMessageSource(reaction.id.id);
|
||||
return {
|
||||
id: reaction.id._serialized,
|
||||
from: reaction.senderId,
|
||||
fromMe: reaction.id.fromMe,
|
||||
source: source,
|
||||
participant: reaction.senderId,
|
||||
to: reaction.id.remote,
|
||||
timestamp: reaction.timestamp,
|
||||
@@ -1368,12 +1380,14 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
|
||||
|
||||
protected toWAMessage(message: Message): WAMessage {
|
||||
const replyTo = this.extractReplyTo(message);
|
||||
const source = this.getMessageSource(message.id.id);
|
||||
// @ts-ignore
|
||||
return {
|
||||
id: message.id._serialized,
|
||||
timestamp: message.timestamp,
|
||||
from: message.from,
|
||||
fromMe: message.fromMe,
|
||||
source: source,
|
||||
to: message.to,
|
||||
body: message.body,
|
||||
// Media
|
||||
|
||||
@@ -66,7 +66,7 @@ export class WebhookSender {
|
||||
const headers = {
|
||||
'content-type': 'application/json',
|
||||
};
|
||||
Object.assign(headers, this.getWebhookHeader());
|
||||
Object.assign(headers, this.getWebhookHeader(json));
|
||||
Object.assign(headers, this.getHMACHeaders(body));
|
||||
const ctx = {
|
||||
id: headers['X-Webhook-Request-Id'],
|
||||
@@ -153,12 +153,13 @@ export class WebhookSender {
|
||||
};
|
||||
}
|
||||
|
||||
protected getWebhookHeader() {
|
||||
protected getWebhookHeader(json: any) {
|
||||
const timestamp = json.timestamp?.toString() || Date.now().toString();
|
||||
return {
|
||||
// UUID, no '-' in it
|
||||
'X-Webhook-Request-Id': ulid(),
|
||||
// unix timestamp with ms
|
||||
'X-Webhook-Timestamp': Date.now().toString(),
|
||||
'X-Webhook-Timestamp': timestamp,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -45,9 +45,11 @@ import { LocalSessionAuthRepository } from './storage/LocalSessionAuthRepository
|
||||
import { LocalStoreCore } from './storage/LocalStoreCore';
|
||||
|
||||
export class OnlyDefaultSessionIsAllowed extends UnprocessableEntityException {
|
||||
constructor() {
|
||||
constructor(name: string) {
|
||||
const encoded = Buffer.from(name, 'utf-8').toString('base64');
|
||||
super(
|
||||
`WAHA Core support only 'default' session. If you want to run more then one WhatsApp account - please get WAHA PLUS version. Check this out: ${DOCS_URL}`,
|
||||
`WAHA Core support only 'default' session. You tried to access '${name}' session (base64: ${encoded}). ` +
|
||||
`If you want to run more then one WhatsApp account - please get WAHA PLUS version. Check this out: ${DOCS_URL}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -115,7 +117,7 @@ export class SessionManagerCore extends SessionManager implements OnModuleInit {
|
||||
|
||||
private onlyDefault(name: string) {
|
||||
if (name !== this.DEFAULT) {
|
||||
throw new OnlyDefaultSessionIsAllowed();
|
||||
throw new OnlyDefaultSessionIsAllowed(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,9 +364,9 @@ export class SessionManagerCore extends SessionManager implements OnModuleInit {
|
||||
try {
|
||||
engineInfo = await promiseTimeout(1000, session.getEngineInfo());
|
||||
} catch (error) {
|
||||
this.log.warn(
|
||||
this.log.debug(
|
||||
{ session: session.name, error: `${error}` },
|
||||
'Error while getting engine info',
|
||||
'Can not get engine info',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ export const MessageIdApiParam = ApiParam({
|
||||
name: 'messageId',
|
||||
required: true,
|
||||
type: 'string',
|
||||
description: 'Message ID',
|
||||
description:
|
||||
'Message ID in format <code>{fromMe}_{chat}_{message_id}[_{participant}]</code>',
|
||||
example: 'true_123456789@c.us_BAE6A33293978B16',
|
||||
});
|
||||
@@ -22,3 +22,10 @@ export class SessionBaseRequest {
|
||||
export class Result {
|
||||
success: boolean = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Responses
|
||||
*/
|
||||
export class CountResponse {
|
||||
count: number = 0;
|
||||
}
|
||||
@@ -158,6 +158,7 @@ export class MessageTextRequest extends ChatRequest {
|
||||
reply_to?: string;
|
||||
|
||||
linkPreview?: boolean = true;
|
||||
linkPreviewHighQuality?: boolean = false;
|
||||
}
|
||||
|
||||
export class EditMessageRequest {
|
||||
@@ -165,6 +166,9 @@ export class EditMessageRequest {
|
||||
|
||||
@ApiHideProperty()
|
||||
mentions?: string[];
|
||||
|
||||
linkPreview?: boolean = true;
|
||||
linkPreviewHighQuality?: boolean = false;
|
||||
}
|
||||
|
||||
export class MessageReplyRequest extends MessageTextRequest {
|
||||
|
||||
@@ -11,6 +11,11 @@ export class WALocation {
|
||||
longitude: string;
|
||||
}
|
||||
|
||||
export enum MessageSource {
|
||||
API = 'api',
|
||||
APP = 'app',
|
||||
}
|
||||
|
||||
class WAMessageBase {
|
||||
@MessageIdProperty()
|
||||
id: string;
|
||||
@@ -33,6 +38,13 @@ class WAMessageBase {
|
||||
})
|
||||
fromMe: boolean;
|
||||
|
||||
@ApiProperty({
|
||||
description:
|
||||
'The device that sent the message - either API or APP. Available in events (webhooks/websockets) only and only "fromMe: true" messages.',
|
||||
example: MessageSource.API,
|
||||
})
|
||||
source: MessageSource;
|
||||
|
||||
@ChatIdProperty({
|
||||
description: `
|
||||
* ID for who this message is for.
|
||||
|
||||
@@ -28,6 +28,9 @@ export class TextStatus {
|
||||
|
||||
@ContactsProperty
|
||||
contacts?: string[];
|
||||
|
||||
linkPreview?: boolean = true;
|
||||
linkPreviewHighQuality?: boolean = false;
|
||||
}
|
||||
|
||||
@ApiExtraModels(RemoteFile, BinaryFile)
|
||||
|
||||
@@ -105,10 +105,18 @@ export class WASessionStatusBody {
|
||||
|
||||
export class WAHAWebhook {
|
||||
@ApiProperty({
|
||||
example: 'evt_01jcn4pjwwg47bwy2gsey6q5sx',
|
||||
example: 'evt_01aaaaaaaaaaaaaaaaaaaaaaaa',
|
||||
description:
|
||||
'Unique identifier for the event - lower case ULID format. https://github.com/ulid/spec',
|
||||
})
|
||||
id: string;
|
||||
|
||||
@ApiProperty({
|
||||
example: 1634567890123,
|
||||
description: 'Unix timestamp (ms) for when the event was created.',
|
||||
})
|
||||
timestamp: number;
|
||||
|
||||
@ApiProperty({
|
||||
example: 'default',
|
||||
})
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ export function getEngineName(): string {
|
||||
}
|
||||
|
||||
export const VERSION: WAHAEnvironment = {
|
||||
version: '2025.2.7',
|
||||
version: '2025.3.1',
|
||||
engine: getEngineName(),
|
||||
tier: getWAHAVersion(),
|
||||
browser: getBrowserExecutablePath(),
|
||||
|
||||
+2
-2
@@ -2,11 +2,11 @@
|
||||
"waha": {
|
||||
"gows": {
|
||||
"repo": "devlikeapro/gows",
|
||||
"ref": "v1.0.0"
|
||||
"ref": "v1.0.1"
|
||||
},
|
||||
"dashboard": {
|
||||
"repo": "devlikeapro/dashboard",
|
||||
"ref": "d6cd941f8d7621f401305e03ad2c1db8dc0a64f0"
|
||||
"ref": "d7440caaefc2e80c0a4a1a61386f448c09cceeab"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ __metadata:
|
||||
|
||||
"@adiwajshing/baileys@github:devlikeapro/Baileys#fork-master-channels-6712":
|
||||
version: 6.7.12
|
||||
resolution: "@adiwajshing/baileys@https://github.com/devlikeapro/Baileys.git#commit=dcc5d0ea0827c0d57ceda4f94b9cdb260760b77e"
|
||||
resolution: "@adiwajshing/baileys@https://github.com/devlikeapro/Baileys.git#commit=c1b8ab22ad5e6bf5fa52026657ad1e0fd626e860"
|
||||
dependencies:
|
||||
"@adiwajshing/keyed-db": ^0.2.4
|
||||
"@hapi/boom": ^9.1.3
|
||||
@@ -40,7 +40,7 @@ __metadata:
|
||||
optional: true
|
||||
sharp:
|
||||
optional: true
|
||||
checksum: 24e16d0b11dbb83a562e333fcc11f9489d4f3c6735c12f726eead983dd3bbc0f4dbce9c486d849b26ddcb0e2be68972d205d21837aabfcb42ebd8b115958f053
|
||||
checksum: fc11e18ac05383cbbda0e6a5c9e605858da84b4d105d702e7560433bd3ca383ddead85ddc09d7918a73643854ec7703e9acd6dc11c322a4fc0c958924bba9e4b
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -12931,7 +12931,7 @@ __metadata:
|
||||
|
||||
"whatsapp-web.js@github:devlikeapro/whatsapp-web.js#fork-main-channels":
|
||||
version: 1.26.0
|
||||
resolution: "whatsapp-web.js@https://github.com/devlikeapro/whatsapp-web.js.git#commit=5b4dd6dec206905e3aaa7b0461d7c6d4cc3126a8"
|
||||
resolution: "whatsapp-web.js@https://github.com/devlikeapro/whatsapp-web.js.git#commit=c73f3cfb4e1290103ee946ca7f56d5638f1a66bd"
|
||||
dependencies:
|
||||
"@pedroslopez/moduleraid": ^5.0.2
|
||||
archiver: ^5.3.1
|
||||
@@ -12949,7 +12949,7 @@ __metadata:
|
||||
optional: true
|
||||
unzipper:
|
||||
optional: true
|
||||
checksum: 441e54f450ed9ea5d5756c1ca4fd592e498ad79247d2c6508aee2a5c1b2608a9eb3f6360234f2f0ce563edb187a3d453d41773e745da9bebf657f575b9fa66b4
|
||||
checksum: 831a4a2819041f63c2a51a98e1ad7dd9ff8474b1005b11314b613c6dadac545f3c780e38081b7d260d32afa9ffd333a25f9c6407b630a0660bd08dadbc8ead89
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
||||
Reference in new issue
Block a user