Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 25 additions & 10 deletions src/core/engines/webjs/session.webjs.core.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { UnprocessableEntityException } from '@nestjs/common';
import {
NotFoundException,
UnprocessableEntityException,
} from '@nestjs/common';
import {
getChannelInviteLink,
WhatsappSession,
Expand Down Expand Up @@ -882,25 +885,37 @@ export class WhatsappSessionWebJSCore extends WhatsappSession {

@Activity()
async sendSeen(request: SendSeenRequest) {
const chat: Chat = await this.whatsapp.getChatById(
this.ensureSuffix(request.chatId),
);
const chatId = this.ensureSuffix(request.chatId);
const chat: Chat = await this.whatsapp.getChatById(chatId);
if (!chat) {
throw new NotFoundException(
`Chat '${request.chatId}' not found. The number may not have WhatsApp.`,
);
}
await chat.sendSeen();
}

@Activity()
async startTyping(request: ChatRequest): Promise<void> {
const chat: Chat = await this.whatsapp.getChatById(
this.ensureSuffix(request.chatId),
);
const chatId = this.ensureSuffix(request.chatId);
const chat: Chat = await this.whatsapp.getChatById(chatId);
if (!chat) {
throw new NotFoundException(
`Chat '${request.chatId}' not found. The number may not have WhatsApp.`,
);
}
await chat.sendStateTyping();
}

@Activity()
async stopTyping(request: ChatRequest) {
const chat: Chat = await this.whatsapp.getChatById(
this.ensureSuffix(request.chatId),
);
const chatId = this.ensureSuffix(request.chatId);
const chat: Chat = await this.whatsapp.getChatById(chatId);
if (!chat) {
throw new NotFoundException(
`Chat '${request.chatId}' not found. The number may not have WhatsApp.`,
);
}
await chat.clearState();
}

Expand Down