Compare commits
20
Commits
2024.10.11
...
2024.11.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
048c5dc2ec | ||
|
|
eb218da8fb | ||
|
|
65942a4ed4 | ||
|
|
1444155c09 | ||
|
|
84ac1d8cfc | ||
|
|
440e1e879a | ||
|
|
bcecf793d4 | ||
|
|
16c0d827e1 | ||
|
|
94f16a9583 | ||
|
|
4bdac3bbc2 | ||
|
|
2bc4a59aaf | ||
|
|
cf886de5ce | ||
|
|
9969966ac6 | ||
|
|
fb809338e3 | ||
|
|
c6284eb994 | ||
|
|
454bda4c82 | ||
|
|
26e21441a0 | ||
|
|
2edef0166e | ||
|
|
05cb89779b | ||
|
|
c0b2524952 |
No files matched your search
@@ -1,5 +1,6 @@
|
||||
Dockerfile
|
||||
.*sessions
|
||||
sessions
|
||||
files
|
||||
venv
|
||||
.wwebjs_auth
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
.yarn
|
||||
example.ts
|
||||
.*sessions
|
||||
sessions
|
||||
.secrets
|
||||
.minio
|
||||
.media
|
||||
|
||||
+14
-1
@@ -60,7 +60,20 @@ RUN if [ "$USE_BROWSER" = "chromium" ] || [ "$USE_BROWSER" = "chrome" ]; then \
|
||||
# Install fonts if using either chromium or chrome
|
||||
RUN if [ "$USE_BROWSER" = "chromium" ] || [ "$USE_BROWSER" = "chrome" ]; then \
|
||||
apt-get update \
|
||||
&& apt-get install -y fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst fonts-freefont-ttf \
|
||||
&& apt-get install -y \
|
||||
fontconfig \
|
||||
fonts-freefont-ttf \
|
||||
fonts-gfs-neohellenic \
|
||||
fonts-indic \
|
||||
fonts-ipafont-gothic \
|
||||
fonts-kacst \
|
||||
fonts-liberation \
|
||||
fonts-noto-cjk \
|
||||
fonts-noto-color-emoji \
|
||||
fonts-roboto \
|
||||
fonts-thai-tlwg \
|
||||
fonts-wqy-zenhei \
|
||||
fonts-open-sans \
|
||||
--no-install-recommends \
|
||||
&& rm -rf /var/lib/apt/lists/*; \
|
||||
fi
|
||||
|
||||
+2
-2
@@ -4,7 +4,7 @@ services:
|
||||
restart: always
|
||||
# https://waha.devlike.pro/docs/how-to/engines/#docker-images
|
||||
# https://portal.devlike.pro/docker-image
|
||||
image: devlikeapro/waha-plus:latest
|
||||
image: devlikeapro/waha-plus:chrome
|
||||
# WAHA Core
|
||||
# image: devlikeapro/waha:latest
|
||||
|
||||
@@ -13,7 +13,7 @@ services:
|
||||
|
||||
volumes:
|
||||
# Store sessions in the .sessions folder (comment it if you're using MongoDB)
|
||||
- './.sessions:/app/.sessions'
|
||||
- './sessions:/app/.sessions'
|
||||
|
||||
# Save media files
|
||||
# https://waha.devlike.pro/docs/how-to/storages/#save-media-files-between-the-container-restarts
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
Put,
|
||||
Query,
|
||||
UsePipes,
|
||||
ValidationPipe,
|
||||
} from '@nestjs/common';
|
||||
import { ApiOperation, ApiSecurity, ApiTags } from '@nestjs/swagger';
|
||||
import { WAHAValidationPipe } from '@waha/nestjs/pipes/WAHAValidationPipe';
|
||||
@@ -172,6 +173,7 @@ export class ChattingController {
|
||||
|
||||
@Get('/messages')
|
||||
@ApiOperation({ summary: 'Get messages in a chat' })
|
||||
@UsePipes(new ValidationPipe({ transform: true, whitelist: true }))
|
||||
async getMessages(
|
||||
@Query() query: GetMessageQuery,
|
||||
@Query() filter: GetChatMessagesFilter,
|
||||
|
||||
@@ -1,4 +1,16 @@
|
||||
import { Body, Controller, Get, Param, Put } from '@nestjs/common';
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
NotFoundException,
|
||||
Param,
|
||||
Post,
|
||||
Put,
|
||||
UnprocessableEntityException,
|
||||
UsePipes,
|
||||
ValidationPipe,
|
||||
} from '@nestjs/common';
|
||||
import { ApiOperation, ApiSecurity, ApiTags } from '@nestjs/swagger';
|
||||
import { WhatsappSession } from '@waha/core/abc/session.abc';
|
||||
import { ChatIdApiParam } from '@waha/nestjs/params/ChatIdApiParam';
|
||||
@@ -6,7 +18,12 @@ import {
|
||||
SessionApiParam,
|
||||
WorkingSessionParam,
|
||||
} from '@waha/nestjs/params/SessionApiParam';
|
||||
import { Label, SetLabelsRequest } from '@waha/structures/labels.dto';
|
||||
import {
|
||||
Label,
|
||||
LabelBody,
|
||||
SetLabelsRequest,
|
||||
} from '@waha/structures/labels.dto';
|
||||
import * as lodash from 'lodash';
|
||||
|
||||
import { SessionManager } from '../core/abc/manager.abc';
|
||||
|
||||
@@ -23,6 +40,78 @@ export class LabelsController {
|
||||
return session.getLabels();
|
||||
}
|
||||
|
||||
@Post('/')
|
||||
@SessionApiParam
|
||||
@ApiOperation({ summary: 'Create a new label' })
|
||||
@UsePipes(new ValidationPipe({ transform: true, whitelist: true }))
|
||||
async create(
|
||||
@WorkingSessionParam session: WhatsappSession,
|
||||
@Body() body: LabelBody,
|
||||
): Promise<Label> {
|
||||
const labelDto = body.toDTO();
|
||||
|
||||
const labels = await session.getLabels();
|
||||
if (labels.length >= 20) {
|
||||
throw new UnprocessableEntityException('Maximum 20 labels allowed');
|
||||
}
|
||||
|
||||
const labelByName = lodash.find(labels, { name: labelDto.name });
|
||||
if (labelByName) {
|
||||
throw new UnprocessableEntityException(
|
||||
`Label with '${labelByName.name}' already exists, id: ${labelByName.id}`,
|
||||
);
|
||||
}
|
||||
|
||||
return session.createLabel(labelDto);
|
||||
}
|
||||
|
||||
@Put('/:labelId')
|
||||
@SessionApiParam
|
||||
@ApiOperation({ summary: 'Update a label' })
|
||||
@UsePipes(new ValidationPipe({ transform: true, whitelist: true }))
|
||||
async update(
|
||||
@WorkingSessionParam session: WhatsappSession,
|
||||
@Param('labelId') labelId: string,
|
||||
@Body() body: LabelBody,
|
||||
): Promise<Label> {
|
||||
const label = await session.getLabel(labelId);
|
||||
if (!label) {
|
||||
throw new NotFoundException('Label not found');
|
||||
}
|
||||
|
||||
const labelDto = body.toDTO();
|
||||
const labels = await session.getLabels();
|
||||
|
||||
const labelByName = lodash.find(labels, { name: labelDto.name });
|
||||
if (labelByName) {
|
||||
throw new UnprocessableEntityException(
|
||||
`Label with '${labelByName.name}' already exists, id: ${labelByName.id}`,
|
||||
);
|
||||
}
|
||||
|
||||
label.name = labelDto.name;
|
||||
label.color = labelDto.color;
|
||||
label.colorHex = Label.toHex(label.color);
|
||||
await session.updateLabel(label);
|
||||
return label;
|
||||
}
|
||||
|
||||
@Delete('/:labelId')
|
||||
@SessionApiParam
|
||||
@ApiOperation({ summary: 'Delete a label' })
|
||||
@UsePipes(new ValidationPipe({ transform: true, whitelist: true }))
|
||||
async delete(
|
||||
@WorkingSessionParam session: WhatsappSession,
|
||||
@Param('labelId') labelId: string,
|
||||
): Promise<any> {
|
||||
const label = await session.getLabel(labelId);
|
||||
if (!label) {
|
||||
throw new NotFoundException('Label not found');
|
||||
}
|
||||
await session.deleteLabel(label);
|
||||
return { result: true };
|
||||
}
|
||||
|
||||
@Get('/chats/:chatId')
|
||||
@SessionApiParam
|
||||
@ChatIdApiParam
|
||||
|
||||
@@ -9,12 +9,13 @@ import {
|
||||
GetChatMessagesQuery,
|
||||
} from '@waha/structures/chats.dto';
|
||||
import { SendButtonsRequest } from '@waha/structures/chatting.buttons.dto';
|
||||
import { Label, LabelID } from '@waha/structures/labels.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 { LoggerBuilder } from '@waha/utils/logging';
|
||||
import { EventEmitter } from 'events';
|
||||
import * as fs from 'fs';
|
||||
import * as lodash from 'lodash';
|
||||
import { Logger } from 'pino';
|
||||
import { MessageId } from 'whatsapp-web.js';
|
||||
|
||||
@@ -66,7 +67,6 @@ import { NotImplementedByEngineError } from '../exceptions';
|
||||
import { IMediaManager } from '../media/IMediaManager';
|
||||
import { QR } from '../QR';
|
||||
import { DataStore } from './DataStore';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const qrcode = require('qrcode-terminal');
|
||||
|
||||
@@ -172,6 +172,9 @@ export abstract class WhatsappSession {
|
||||
'--disable-accelerated-2d-canvas',
|
||||
'--disable-application-cache',
|
||||
'--disable-background-networking',
|
||||
// DO NOT disable software rasterizer, it will break the video
|
||||
// https://github.com/devlikeapro/waha/issues/629
|
||||
// '--disable-software-rasterizer',
|
||||
'--disable-cache',
|
||||
'--disable-client-side-phishing-detection',
|
||||
'--disable-component-update',
|
||||
@@ -204,7 +207,7 @@ export abstract class WhatsappSession {
|
||||
'--password-store=basic',
|
||||
'--renderer-process-limit=2', // https://superuser.com/questions/654565/how-to-run-google-chrome-in-a-single-process
|
||||
'--safebrowsing-disable-auto-update',
|
||||
'--single-process',
|
||||
// '--single-process',
|
||||
'--use-mock-keychain',
|
||||
'--window-size=1280,720',
|
||||
];
|
||||
@@ -387,11 +390,27 @@ export abstract class WhatsappSession {
|
||||
/**
|
||||
* Labels methods
|
||||
*/
|
||||
public async getLabel(labelId: string): Promise<Label | undefined> {
|
||||
const labels = await this.getLabels();
|
||||
return lodash.find(labels, { id: labelId });
|
||||
}
|
||||
|
||||
public getLabels(): Promise<Label[]> {
|
||||
throw new NotImplementedByEngineError();
|
||||
}
|
||||
|
||||
public async createLabel(label: LabelDTO): Promise<Label> {
|
||||
throw new NotImplementedByEngineError();
|
||||
}
|
||||
|
||||
public async updateLabel(label: Label): Promise<Label> {
|
||||
throw new NotImplementedByEngineError();
|
||||
}
|
||||
|
||||
public async deleteLabel(label: Label): Promise<void> {
|
||||
throw new NotImplementedByEngineError();
|
||||
}
|
||||
|
||||
public getChatsByLabelId(labelId: string) {
|
||||
throw new NotImplementedByEngineError();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,10 @@ import makeWASocket, {
|
||||
WAMessageKey,
|
||||
} from '@adiwajshing/baileys';
|
||||
import { WACallEvent } from '@adiwajshing/baileys/lib/Types/Call';
|
||||
import { Label as NOWEBLabel } from '@adiwajshing/baileys/lib/Types/Label';
|
||||
import {
|
||||
Label as NOWEBLabel,
|
||||
LabelActionBody,
|
||||
} from '@adiwajshing/baileys/lib/Types/Label';
|
||||
import { LabelAssociationType } from '@adiwajshing/baileys/lib/Types/LabelAssociation';
|
||||
import { isLidUser } from '@adiwajshing/baileys/lib/WABinary/jid-utils';
|
||||
import { Logger as BaileysLogger } from '@adiwajshing/baileys/node_modules/pino';
|
||||
@@ -49,6 +52,7 @@ import { BinaryFile, RemoteFile } from '@waha/structures/files.dto';
|
||||
import {
|
||||
Label,
|
||||
LabelChatAssociation,
|
||||
LabelDTO,
|
||||
LabelID,
|
||||
} from '@waha/structures/labels.dto';
|
||||
import { ReplyToMessage } from '@waha/structures/message.dto';
|
||||
@@ -617,6 +621,7 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
const message = {
|
||||
text: request.text,
|
||||
mentions: request.mentions?.map(toJID),
|
||||
linkPreview: this.getLinkPreview(request),
|
||||
};
|
||||
const options = await this.getMessageOptions(request);
|
||||
return this.sock.sendMessage(chatId, message, options);
|
||||
@@ -875,6 +880,52 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
return labels.map(this.toLabel);
|
||||
}
|
||||
|
||||
public async createLabel(label: LabelDTO): Promise<Label> {
|
||||
const labels = await this.store.getLabels();
|
||||
const highestLabelId = lodash.max(
|
||||
labels.map((label) => parseInt(label.id)),
|
||||
);
|
||||
const labelId = highestLabelId ? highestLabelId + 1 : 1;
|
||||
const labelAction: LabelActionBody = {
|
||||
id: labelId.toString(),
|
||||
name: label.name,
|
||||
color: label.color,
|
||||
deleted: false,
|
||||
predefinedId: undefined,
|
||||
};
|
||||
await this.sock.addLabel(undefined, labelAction);
|
||||
|
||||
return {
|
||||
id: labelId.toString(),
|
||||
name: label.name,
|
||||
color: label.color,
|
||||
colorHex: Label.toHex(label.color),
|
||||
};
|
||||
}
|
||||
|
||||
public async updateLabel(label: Label): Promise<Label> {
|
||||
const labelAction: LabelActionBody = {
|
||||
id: label.id,
|
||||
name: label.name,
|
||||
color: label.color,
|
||||
deleted: false,
|
||||
predefinedId: undefined,
|
||||
};
|
||||
await this.sock.addLabel(undefined, labelAction);
|
||||
return label;
|
||||
}
|
||||
|
||||
public async deleteLabel(label: Label): Promise<void> {
|
||||
const labelAction: LabelActionBody = {
|
||||
id: label.id,
|
||||
name: label.name,
|
||||
color: label.color,
|
||||
deleted: true,
|
||||
predefinedId: undefined,
|
||||
};
|
||||
await this.sock.addLabel(undefined, labelAction);
|
||||
}
|
||||
|
||||
public async getChatsByLabelId(labelId: string) {
|
||||
const chats = await this.store.getChatsByLabelId(labelId);
|
||||
// Remove unreadCount, it's not ready yet
|
||||
@@ -1636,6 +1687,22 @@ export class WhatsappSessionNoWebCore extends WhatsappSession {
|
||||
quoted: quoted,
|
||||
};
|
||||
}
|
||||
|
||||
protected getLinkPreview(request): any {
|
||||
// NOWEB works this way
|
||||
// If it's undefined - it'll generate it
|
||||
// If it's false - it will not generate it
|
||||
let linkPreview: boolean | undefined;
|
||||
switch (request.linkPreview) {
|
||||
case false:
|
||||
linkPreview = false;
|
||||
break;
|
||||
case true:
|
||||
default:
|
||||
linkPreview = undefined;
|
||||
}
|
||||
return linkPreview;
|
||||
}
|
||||
}
|
||||
|
||||
function hasPath(url: string) {
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
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 * as lodash from 'lodash';
|
||||
import { Client } from 'whatsapp-web.js';
|
||||
import { Client, Events } from 'whatsapp-web.js';
|
||||
import { Message } from 'whatsapp-web.js/src/structures';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
@@ -17,16 +19,14 @@ const { LoadPaginator } = require('./_Paginator.js');
|
||||
const ChatFactory = require('whatsapp-web.js/src/factories/ChatFactory');
|
||||
|
||||
export class WebjsClient extends Client {
|
||||
async inject() {
|
||||
// Even tho this.inject is not defined as interface in Client.ts
|
||||
// We can still call and override it
|
||||
// @ts-ignore
|
||||
await super.inject();
|
||||
|
||||
// Load util functions (serializers, helper functions)
|
||||
await this.pupPage.evaluate(LoadLodash);
|
||||
await this.pupPage.evaluate(LoadPaginator);
|
||||
await this.pupPage.evaluate(LoadWAHA);
|
||||
constructor(options) {
|
||||
super(options);
|
||||
// Wait until it's READY and inject more utils
|
||||
this.on(Events.READY, async () => {
|
||||
await this.pupPage.evaluate(LoadLodash);
|
||||
await this.pupPage.evaluate(LoadPaginator);
|
||||
await this.pupPage.evaluate(LoadWAHA);
|
||||
});
|
||||
}
|
||||
|
||||
async unpair() {
|
||||
@@ -45,6 +45,44 @@ export class WebjsClient extends Client {
|
||||
});
|
||||
}
|
||||
|
||||
async createLabel(name: string, color: number): Promise<number> {
|
||||
const labelId: number = await this.pupPage.evaluate(
|
||||
async (name, color) => {
|
||||
// @ts-ignore
|
||||
return await window.WAHA.WAWebBizLabelEditingAction.labelAddAction(
|
||||
name,
|
||||
color,
|
||||
);
|
||||
},
|
||||
name,
|
||||
color,
|
||||
);
|
||||
return labelId;
|
||||
}
|
||||
|
||||
async deleteLabel(label: Label) {
|
||||
return await this.pupPage.evaluate(async (label) => {
|
||||
// @ts-ignore
|
||||
return await window.WAHA.WAWebBizLabelEditingAction.labelDeleteAction(
|
||||
label.id,
|
||||
label.name,
|
||||
label.color,
|
||||
);
|
||||
}, label);
|
||||
}
|
||||
|
||||
async updateLabel(label: Label) {
|
||||
return await this.pupPage.evaluate(async (label) => {
|
||||
// @ts-ignore
|
||||
return await window.WAHA.WAWebBizLabelEditingAction.labelEditAction(
|
||||
label.id,
|
||||
label.name,
|
||||
undefined, // predefinedId
|
||||
label.color,
|
||||
);
|
||||
}, label);
|
||||
}
|
||||
|
||||
async getChats(pagination?: PaginationParams) {
|
||||
if (lodash.isEmpty(pagination)) {
|
||||
return await super.getChats();
|
||||
@@ -62,6 +100,37 @@ export class WebjsClient extends Client {
|
||||
return chats.map((chat) => ChatFactory.create(this, chat));
|
||||
}
|
||||
|
||||
async sendTextStatus(status: TextStatus) {
|
||||
// Convert from hex to number
|
||||
const waColor = 'FF' + status.backgroundColor.replace('#', '');
|
||||
const color = parseInt(waColor, 16);
|
||||
|
||||
const textStatus = {
|
||||
text: status.text,
|
||||
color: color,
|
||||
font: status.font,
|
||||
};
|
||||
const sentMsg = await this.pupPage.evaluate(async (status) => {
|
||||
// @ts-ignore
|
||||
await window.Store.SendStatus.sendStatusTextMsgAction(status);
|
||||
// @ts-ignore
|
||||
const meUser = window.Store.User.getMeUser();
|
||||
// @ts-ignore
|
||||
const myStatus = window.Store.Status.getModelsArray().findLast(
|
||||
(x) => x.id == meUser,
|
||||
);
|
||||
if (!myStatus) {
|
||||
return undefined;
|
||||
}
|
||||
// @ts-ignore
|
||||
const msg = myStatus.msgs.last();
|
||||
// @ts-ignore
|
||||
return msg ? window.WWebJS.getMessageModel(msg) : undefined;
|
||||
}, textStatus);
|
||||
|
||||
return sentMsg ? new Message(this, sentMsg) : undefined;
|
||||
}
|
||||
|
||||
async getMessages(
|
||||
chatId: string,
|
||||
filter: GetChatMessagesFilter,
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
exports.LoadWAHA = () => {
|
||||
window.WAHA = {};
|
||||
window.WAHA.WAWebBizLabelEditingAction = window.require(
|
||||
'WAWebBizLabelEditingAction',
|
||||
);
|
||||
|
||||
window.WAHA.getChats = async (pagination) => {
|
||||
let chats = window.Store.Chat.getModelsArray().slice();
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { UnprocessableEntityException } from '@nestjs/common';
|
||||
import {
|
||||
getChannelInviteLink,
|
||||
WAHAInternalEvent,
|
||||
WhatsappSession,
|
||||
} from '@waha/core/abc/session.abc';
|
||||
import { toJID } from '@waha/core/engines/noweb/session.noweb.core';
|
||||
import { LocalAuth } from '@waha/core/engines/webjs/LocalAuth';
|
||||
import { WebjsClient } from '@waha/core/engines/webjs/WebjsClient';
|
||||
import {
|
||||
@@ -58,11 +60,16 @@ import {
|
||||
ParticipantsRequest,
|
||||
SettingsSecurityChangeInfo,
|
||||
} from '@waha/structures/groups.dto';
|
||||
import { Label, LabelID } from '@waha/structures/labels.dto';
|
||||
import { Label, LabelDTO, LabelID } from '@waha/structures/labels.dto';
|
||||
import { ReplyToMessage } from '@waha/structures/message.dto';
|
||||
import { PaginationParams } from '@waha/structures/pagination.dto';
|
||||
import { WAMessage, WAMessageReaction } from '@waha/structures/responses.dto';
|
||||
import { MeInfo } from '@waha/structures/sessions.dto';
|
||||
import {
|
||||
BROADCAST_ID,
|
||||
StatusRequest,
|
||||
TextStatus,
|
||||
} from '@waha/structures/status.dto';
|
||||
import { WAMessageRevokedBody } from '@waha/structures/webhooks.dto';
|
||||
import { PaginatorInMemory } from '@waha/utils/Paginator';
|
||||
import { sleep, waitUntil } from '@waha/utils/promiseTimeout';
|
||||
@@ -336,7 +343,6 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
|
||||
});
|
||||
|
||||
this.whatsapp.on(Events.AUTHENTICATED, (args) => {
|
||||
this.status = WAHASessionStatus.WORKING;
|
||||
this.qr.save('');
|
||||
this.logger.info({ args: args }, `Session has been authenticated!`);
|
||||
});
|
||||
@@ -632,6 +638,24 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
|
||||
return labels.map(this.toLabel);
|
||||
}
|
||||
|
||||
public async createLabel(label: LabelDTO): Promise<Label> {
|
||||
const labelId = await this.whatsapp.createLabel(label.name, label.color);
|
||||
return {
|
||||
id: labelId.toString(),
|
||||
name: label.name,
|
||||
color: label.color,
|
||||
colorHex: Label.toHex(label.color),
|
||||
};
|
||||
}
|
||||
|
||||
public async updateLabel(label: Label): Promise<Label> {
|
||||
return await this.whatsapp.updateLabel(label);
|
||||
}
|
||||
|
||||
public deleteLabel(label: Label): Promise<void> {
|
||||
return this.whatsapp.deleteLabel(label);
|
||||
}
|
||||
|
||||
public getChatsByLabelId(labelId: string) {
|
||||
return this.whatsapp.getChatsByLabelId(labelId);
|
||||
}
|
||||
@@ -950,6 +974,22 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Status methods
|
||||
*/
|
||||
protected checkStatusRequest(request: StatusRequest) {
|
||||
if (request.contacts?.length > 0) {
|
||||
const msg =
|
||||
"WEBJS doesn't accept 'contacts'. Remove the field to send status to all contacts.";
|
||||
throw new UnprocessableEntityException(msg);
|
||||
}
|
||||
}
|
||||
|
||||
public sendTextStatus(status: TextStatus) {
|
||||
this.checkStatusRequest(status);
|
||||
return this.whatsapp.sendTextStatus(status);
|
||||
}
|
||||
|
||||
/**
|
||||
* END - Methods for API
|
||||
*/
|
||||
@@ -1129,6 +1169,7 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {
|
||||
return {
|
||||
mentions: mentions,
|
||||
quotedMessageId: quotedMessageId,
|
||||
linkPreview: request.linkPreview,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ export class LocalStoreCore extends LocalStore {
|
||||
const engineDir = this.getEngineDirectory();
|
||||
const database = path.join(engineDir, 'waha.sqlite3');
|
||||
this.db = new Database(database);
|
||||
this.db.pragma('journal_mode = WAL;');
|
||||
}
|
||||
return this.db;
|
||||
}
|
||||
|
||||
@@ -49,9 +49,11 @@ export class ChatQuery extends SessionQuery {
|
||||
|
||||
export class GetMessageQuery extends GetChatMessagesQuery {
|
||||
@IsNotEmpty()
|
||||
@IsString()
|
||||
session: string = WHATSAPP_DEFAULT_SESSION_NAME;
|
||||
|
||||
@ChatIdProperty()
|
||||
@IsString()
|
||||
chatId: string;
|
||||
}
|
||||
|
||||
@@ -154,6 +156,8 @@ export class MessageTextRequest extends ChatRequest {
|
||||
|
||||
@ReplyToProperty()
|
||||
reply_to?: string;
|
||||
|
||||
linkPreview?: boolean = true;
|
||||
}
|
||||
|
||||
export class EditMessageRequest {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { UnprocessableEntityException } from '@nestjs/common';
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
import { ChatIdProperty } from '@waha/structures/properties.dto';
|
||||
import { IsHexColor, IsNumber, IsOptional, IsString } from 'class-validator';
|
||||
|
||||
const Colors = [
|
||||
'#ff9485',
|
||||
@@ -24,6 +26,65 @@ const Colors = [
|
||||
'#9368cf',
|
||||
];
|
||||
|
||||
export class LabelBody {
|
||||
@ApiProperty({
|
||||
example: 'Lead',
|
||||
description: 'Label name',
|
||||
})
|
||||
@IsString()
|
||||
name: string;
|
||||
|
||||
@ApiProperty({
|
||||
example: '#ff9485',
|
||||
description: 'Color in hex',
|
||||
})
|
||||
@IsHexColor()
|
||||
@IsOptional()
|
||||
colorHex?: string;
|
||||
|
||||
@ApiProperty({
|
||||
example: null,
|
||||
description: 'Color number, not hex',
|
||||
})
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
color?: number;
|
||||
|
||||
toDTO(): LabelDTO {
|
||||
if (this.color != null && this.colorHex != null) {
|
||||
throw new UnprocessableEntityException(
|
||||
"Use either 'color' or 'colorHex'",
|
||||
);
|
||||
}
|
||||
|
||||
if (this.color == null && this.colorHex == null) {
|
||||
throw new UnprocessableEntityException(
|
||||
"'color' or 'colorHex' is required",
|
||||
);
|
||||
}
|
||||
|
||||
if (this.colorHex) {
|
||||
const color = Colors.indexOf(this.colorHex);
|
||||
if (color == -1) {
|
||||
throw new UnprocessableEntityException(
|
||||
"Invalid 'colorHex'. Possible values: " + Colors.join(', '),
|
||||
);
|
||||
}
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
return {
|
||||
name: this.name,
|
||||
color: this.color,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export class LabelDTO {
|
||||
name: string;
|
||||
color: number;
|
||||
}
|
||||
|
||||
export class Label {
|
||||
@ApiProperty({
|
||||
example: '1',
|
||||
@@ -39,7 +100,7 @@ export class Label {
|
||||
|
||||
@ApiProperty({
|
||||
example: 0,
|
||||
description: 'Internal color number, not hex',
|
||||
description: 'Color number, not hex',
|
||||
})
|
||||
color: number;
|
||||
|
||||
|
||||
@@ -11,10 +11,9 @@ import {
|
||||
|
||||
export const BROADCAST_ID = 'status@broadcast';
|
||||
|
||||
class StatusRequest {
|
||||
export class StatusRequest {
|
||||
@ApiProperty({
|
||||
description:
|
||||
'it is always necessary to inform the list of contacts that will have access to the posted status',
|
||||
description: 'Contact list to send the status to.',
|
||||
example: ['55xxxxxxxxxxx@c.us'],
|
||||
})
|
||||
contacts = ['55xxxxxxxxxxx@c.us'];
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ export function getEngineName(): string {
|
||||
}
|
||||
|
||||
export const VERSION: WAHAEnvironment = {
|
||||
version: '2024.10.11',
|
||||
version: '2024.11.3',
|
||||
engine: getEngineName(),
|
||||
tier: getWAHAVersion(),
|
||||
browser: getBrowserExecutablePath(),
|
||||
|
||||
@@ -7,7 +7,7 @@ __metadata:
|
||||
|
||||
"@adiwajshing/baileys@github:devlikeapro/Baileys#fork-master-channels-678":
|
||||
version: 6.7.8
|
||||
resolution: "@adiwajshing/baileys@https://github.com/devlikeapro/Baileys.git#commit=1a3d827b5d9633e0b82d95362fc07cf1060aa32f"
|
||||
resolution: "@adiwajshing/baileys@https://github.com/devlikeapro/Baileys.git#commit=c44cb586e9860ae97f6b3cf206e51fa13edfe7ba"
|
||||
dependencies:
|
||||
"@adiwajshing/keyed-db": ^0.2.4
|
||||
"@hapi/boom": ^9.1.3
|
||||
@@ -39,7 +39,7 @@ __metadata:
|
||||
optional: true
|
||||
sharp:
|
||||
optional: true
|
||||
checksum: fd4053af48069c3cdd6017075490d2061302e8006acbcf4d9a831159a1ae213548d135acbc4f2b8217c48bf989dbdc5c96a904df71becf2b0576a7a61998cc83
|
||||
checksum: a98a8bead0b14df2abe21de47bdcde22378fc8425cf189f5a96ac57a9946646c1bb7aedc400dcf9913b1dd61d1e5bc1c6f149743ff54f6503691a9c0ccfaa1f9
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -12384,7 +12384,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=76329eedc27b07c11e38bf1b60e6c2476c11dd73"
|
||||
resolution: "whatsapp-web.js@https://github.com/devlikeapro/whatsapp-web.js.git#commit=aa90f7378659a237f30cda6d368359a1f81904dc"
|
||||
dependencies:
|
||||
"@pedroslopez/moduleraid": ^5.0.2
|
||||
archiver: ^5.3.1
|
||||
@@ -12402,7 +12402,7 @@ __metadata:
|
||||
optional: true
|
||||
unzipper:
|
||||
optional: true
|
||||
checksum: b8d4fcb1fd1365a38f07f95dd2eb1fd743c6c406fc7ac679662ddeded80c441720bc8400222a37d61765ebcbb5c6799f169d5ac45f12f58b5421c55bb9f2ab7e
|
||||
checksum: 7c914e9cdd4a25c967e057d0cb5019973f0556f6220320e4bcbc0666669801b92abf97c2cc783762ef462d0006123953e233136f457689ebac395260fe69a5fc
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
||||
Reference in new issue
Block a user