mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 12:12:55 -06:00
change sendPresence from sendMessage to chat
This commit is contained in:
parent
4222c0e53b
commit
42dd280aca
4
.vscode/settings.json
vendored
4
.vscode/settings.json
vendored
@ -5,8 +5,8 @@
|
|||||||
"editor.smoothScrolling": true,
|
"editor.smoothScrolling": true,
|
||||||
"editor.tabSize": 2,
|
"editor.tabSize": 2,
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.fixAll.eslint": true,
|
"source.fixAll.eslint": "explicit",
|
||||||
"source.fixAll": true
|
"source.fixAll": "explicit"
|
||||||
},
|
},
|
||||||
"prisma-smart-formatter.typescript.defaultFormatter": "esbenp.prettier-vscode",
|
"prisma-smart-formatter.typescript.defaultFormatter": "esbenp.prettier-vscode",
|
||||||
"prisma-smart-formatter.prisma.defaultFormatter": "Prisma.prisma"
|
"prisma-smart-formatter.prisma.defaultFormatter": "Prisma.prisma"
|
||||||
|
@ -9,6 +9,7 @@ import {
|
|||||||
ProfilePictureDto,
|
ProfilePictureDto,
|
||||||
ProfileStatusDto,
|
ProfileStatusDto,
|
||||||
ReadMessageDto,
|
ReadMessageDto,
|
||||||
|
SendPresenceDto,
|
||||||
WhatsAppNumberDto,
|
WhatsAppNumberDto,
|
||||||
} from '../dto/chat.dto';
|
} from '../dto/chat.dto';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
@ -77,6 +78,11 @@ export class ChatController {
|
|||||||
return await this.waMonitor.waInstances[instanceName].fetchChats();
|
return await this.waMonitor.waInstances[instanceName].fetchChats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async sendPresence({ instanceName }: InstanceDto, data: SendPresenceDto) {
|
||||||
|
logger.verbose('requested sendPresence from ' + instanceName + ' instance');
|
||||||
|
return await this.waMonitor.waInstances[instanceName].sendPresence(data);
|
||||||
|
}
|
||||||
|
|
||||||
public async fetchPrivacySettings({ instanceName }: InstanceDto) {
|
public async fetchPrivacySettings({ instanceName }: InstanceDto) {
|
||||||
logger.verbose('requested fetchPrivacySettings from ' + instanceName + ' instance');
|
logger.verbose('requested fetchPrivacySettings from ' + instanceName + ' instance');
|
||||||
return await this.waMonitor.waInstances[instanceName].fetchPrivacySettings();
|
return await this.waMonitor.waInstances[instanceName].fetchPrivacySettings();
|
||||||
|
@ -11,7 +11,6 @@ import {
|
|||||||
SendLocationDto,
|
SendLocationDto,
|
||||||
SendMediaDto,
|
SendMediaDto,
|
||||||
SendPollDto,
|
SendPollDto,
|
||||||
SendPresenceDto,
|
|
||||||
SendReactionDto,
|
SendReactionDto,
|
||||||
SendStatusDto,
|
SendStatusDto,
|
||||||
SendStickerDto,
|
SendStickerDto,
|
||||||
@ -24,11 +23,6 @@ const logger = new Logger('MessageRouter');
|
|||||||
export class SendMessageController {
|
export class SendMessageController {
|
||||||
constructor(private readonly waMonitor: WAMonitoringService) {}
|
constructor(private readonly waMonitor: WAMonitoringService) {}
|
||||||
|
|
||||||
public async sendPresence({ instanceName }: InstanceDto, data: SendPresenceDto) {
|
|
||||||
logger.verbose('requested sendPresence from ' + instanceName + ' instance');
|
|
||||||
return await this.waMonitor.waInstances[instanceName].sendPresence(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async sendText({ instanceName }: InstanceDto, data: SendTextDto) {
|
public async sendText({ instanceName }: InstanceDto, data: SendTextDto) {
|
||||||
logger.verbose('requested sendText from ' + instanceName + ' instance');
|
logger.verbose('requested sendText from ' + instanceName + ' instance');
|
||||||
return await this.waMonitor.waInstances[instanceName].textMessage(data);
|
return await this.waMonitor.waInstances[instanceName].textMessage(data);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { proto, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '@whiskeysockets/baileys';
|
import { proto, WAPresence, WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from '@whiskeysockets/baileys';
|
||||||
|
|
||||||
export class OnWhatsAppDto {
|
export class OnWhatsAppDto {
|
||||||
constructor(public readonly jid: string, public readonly exists: boolean, public readonly name?: string) {}
|
constructor(public readonly jid: string, public readonly exists: boolean, public readonly name?: string) {}
|
||||||
@ -83,3 +83,20 @@ export class DeleteMessage {
|
|||||||
remoteJid: string;
|
remoteJid: string;
|
||||||
participant?: string;
|
participant?: string;
|
||||||
}
|
}
|
||||||
|
export class Options {
|
||||||
|
delay?: number;
|
||||||
|
presence?: WAPresence;
|
||||||
|
}
|
||||||
|
class OptionsMessage {
|
||||||
|
options: Options;
|
||||||
|
}
|
||||||
|
export class Metadata extends OptionsMessage {
|
||||||
|
number: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class SendPresenceDto extends Metadata {
|
||||||
|
options: {
|
||||||
|
presence: WAPresence;
|
||||||
|
delay: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@ -46,12 +46,7 @@ class PollMessage {
|
|||||||
values: string[];
|
values: string[];
|
||||||
messageSecret?: Uint8Array;
|
messageSecret?: Uint8Array;
|
||||||
}
|
}
|
||||||
export class SendPresenceDto extends Metadata {
|
|
||||||
options: {
|
|
||||||
presence: WAPresence;
|
|
||||||
delay: number;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
export class SendTextDto extends Metadata {
|
export class SendTextDto extends Metadata {
|
||||||
textMessage: TextMessage;
|
textMessage: TextMessage;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import {
|
|||||||
deleteMessageSchema,
|
deleteMessageSchema,
|
||||||
messageUpSchema,
|
messageUpSchema,
|
||||||
messageValidateSchema,
|
messageValidateSchema,
|
||||||
|
presenceSchema,
|
||||||
privacySettingsSchema,
|
privacySettingsSchema,
|
||||||
profileNameSchema,
|
profileNameSchema,
|
||||||
profilePictureSchema,
|
profilePictureSchema,
|
||||||
@ -26,6 +27,7 @@ import {
|
|||||||
ProfilePictureDto,
|
ProfilePictureDto,
|
||||||
ProfileStatusDto,
|
ProfileStatusDto,
|
||||||
ReadMessageDto,
|
ReadMessageDto,
|
||||||
|
SendPresenceDto,
|
||||||
WhatsAppNumberDto,
|
WhatsAppNumberDto,
|
||||||
} from '../dto/chat.dto';
|
} from '../dto/chat.dto';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
@ -228,6 +230,22 @@ export class ChatRouter extends RouterBroker {
|
|||||||
|
|
||||||
return res.status(HttpStatus.OK).json(response);
|
return res.status(HttpStatus.OK).json(response);
|
||||||
})
|
})
|
||||||
|
.post(this.routerPath('sendPresence'), ...guards, async (req, res) => {
|
||||||
|
logger.verbose('request received in sendPresence');
|
||||||
|
logger.verbose('request body: ');
|
||||||
|
logger.verbose(req.body);
|
||||||
|
|
||||||
|
logger.verbose('request query: ');
|
||||||
|
logger.verbose(req.query);
|
||||||
|
const response = await this.dataValidate<null>({
|
||||||
|
request: req,
|
||||||
|
schema: presenceSchema,
|
||||||
|
ClassRef: SendPresenceDto,
|
||||||
|
execute: (instance, data) => chatController.sendPresence(instance, data),
|
||||||
|
});
|
||||||
|
|
||||||
|
return res.status(HttpStatus.CREATED).json(response);
|
||||||
|
})
|
||||||
// Profile routes
|
// Profile routes
|
||||||
.get(this.routerPath('fetchPrivacySettings'), ...guards, async (req, res) => {
|
.get(this.routerPath('fetchPrivacySettings'), ...guards, async (req, res) => {
|
||||||
logger.verbose('request received in fetchPrivacySettings');
|
logger.verbose('request received in fetchPrivacySettings');
|
||||||
|
@ -9,7 +9,6 @@ import {
|
|||||||
locationMessageSchema,
|
locationMessageSchema,
|
||||||
mediaMessageSchema,
|
mediaMessageSchema,
|
||||||
pollMessageSchema,
|
pollMessageSchema,
|
||||||
presenceSchema,
|
|
||||||
reactionMessageSchema,
|
reactionMessageSchema,
|
||||||
statusMessageSchema,
|
statusMessageSchema,
|
||||||
stickerMessageSchema,
|
stickerMessageSchema,
|
||||||
@ -24,7 +23,6 @@ import {
|
|||||||
SendLocationDto,
|
SendLocationDto,
|
||||||
SendMediaDto,
|
SendMediaDto,
|
||||||
SendPollDto,
|
SendPollDto,
|
||||||
SendPresenceDto,
|
|
||||||
SendReactionDto,
|
SendReactionDto,
|
||||||
SendStatusDto,
|
SendStatusDto,
|
||||||
SendStickerDto,
|
SendStickerDto,
|
||||||
@ -39,22 +37,6 @@ export class MessageRouter extends RouterBroker {
|
|||||||
constructor(...guards: RequestHandler[]) {
|
constructor(...guards: RequestHandler[]) {
|
||||||
super();
|
super();
|
||||||
this.router
|
this.router
|
||||||
.post(this.routerPath('sendPresence'), ...guards, async (req, res) => {
|
|
||||||
logger.verbose('request received in sendPresence');
|
|
||||||
logger.verbose('request body: ');
|
|
||||||
logger.verbose(req.body);
|
|
||||||
|
|
||||||
logger.verbose('request query: ');
|
|
||||||
logger.verbose(req.query);
|
|
||||||
const response = await this.dataValidate<null>({
|
|
||||||
request: req,
|
|
||||||
schema: presenceSchema,
|
|
||||||
ClassRef: SendPresenceDto,
|
|
||||||
execute: (instance, data) => sendMessageController.sendPresence(instance, data),
|
|
||||||
});
|
|
||||||
|
|
||||||
return res.status(HttpStatus.CREATED).json(response);
|
|
||||||
})
|
|
||||||
.post(this.routerPath('sendText'), ...guards, async (req, res) => {
|
.post(this.routerPath('sendText'), ...guards, async (req, res) => {
|
||||||
logger.verbose('request received in sendText');
|
logger.verbose('request received in sendText');
|
||||||
logger.verbose('request body: ');
|
logger.verbose('request body: ');
|
||||||
|
@ -83,6 +83,7 @@ import {
|
|||||||
OnWhatsAppDto,
|
OnWhatsAppDto,
|
||||||
PrivacySettingDto,
|
PrivacySettingDto,
|
||||||
ReadMessageDto,
|
ReadMessageDto,
|
||||||
|
SendPresenceDto,
|
||||||
WhatsAppNumberDto,
|
WhatsAppNumberDto,
|
||||||
} from '../dto/chat.dto';
|
} from '../dto/chat.dto';
|
||||||
import {
|
import {
|
||||||
@ -109,7 +110,6 @@ import {
|
|||||||
SendLocationDto,
|
SendLocationDto,
|
||||||
SendMediaDto,
|
SendMediaDto,
|
||||||
SendPollDto,
|
SendPollDto,
|
||||||
SendPresenceDto,
|
|
||||||
SendReactionDto,
|
SendReactionDto,
|
||||||
SendStatusDto,
|
SendStatusDto,
|
||||||
SendStickerDto,
|
SendStickerDto,
|
||||||
|
Loading…
Reference in New Issue
Block a user