mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2026-01-10 22:02:21 -06:00
Merge branch 'develop' of github.com:EvolutionAPI/evolution-api into develop
This commit is contained in:
@@ -64,6 +64,7 @@ import { useMultiFileAuthStateDb } from '../../utils/use-multi-file-auth-state-d
|
||||
import { useMultiFileAuthStateRedisDb } from '../../utils/use-multi-file-auth-state-redis-db';
|
||||
import {
|
||||
ArchiveChatDto,
|
||||
BlockUserDto,
|
||||
DeleteMessage,
|
||||
getBase64FromMediaMessageDto,
|
||||
LastMessage,
|
||||
@@ -2817,6 +2818,29 @@ export class BaileysStartupService extends WAStartupService {
|
||||
}
|
||||
}
|
||||
|
||||
public async blockUser(data: BlockUserDto) {
|
||||
this.logger.verbose('Blocking user: ' + data.number);
|
||||
try {
|
||||
const { number } = data;
|
||||
|
||||
this.logger.verbose(`Check if number "${number}" is WhatsApp`);
|
||||
const isWA = (await this.whatsappNumber({ numbers: [number] }))?.shift();
|
||||
|
||||
this.logger.verbose(`Exists: "${isWA.exists}" | jid: ${isWA.jid}`);
|
||||
if (!isWA.exists && !isJidGroup(isWA.jid) && !isWA.jid.includes('@broadcast')) {
|
||||
throw new BadRequestException(isWA);
|
||||
}
|
||||
|
||||
const sender = isWA.jid;
|
||||
|
||||
await this.client.updateBlockStatus(sender, data.status);
|
||||
|
||||
return { block: 'success' };
|
||||
} catch (error) {
|
||||
throw new InternalServerErrorException('Error blocking user', error.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public async updateMessage(data: UpdateMessageDto) {
|
||||
try {
|
||||
const jid = this.createJid(data.number);
|
||||
|
||||
Reference in New Issue
Block a user