Team Ai
Apppublic

oex2003/evolution-api

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
chat.controller.ts117 linesDownload Raw Back to controllers
1import {2  ArchiveChatDto,3  BlockUserDto,4  DeleteMessage,5  getBase64FromMediaMessageDto,6  MarkChatUnreadDto,7  NumberDto,8  PrivacySettingDto,9  ProfileNameDto,10  ProfilePictureDto,11  ProfileStatusDto,12  ReadMessageDto,13  SendPresenceDto,14  UpdateMessageDto,15  WhatsAppNumberDto,16} from '@api/dto/chat.dto';17import { InstanceDto } from '@api/dto/instance.dto';18import { Query } from '@api/repository/repository.service';19import { WAMonitoringService } from '@api/services/monitor.service';20import { Contact, Message, MessageUpdate } from '@prisma/client';21 22export class ChatController {23  constructor(private readonly waMonitor: WAMonitoringService) {}24 25  public async whatsappNumber({ instanceName }: InstanceDto, data: WhatsAppNumberDto) {26    return await this.waMonitor.waInstances[instanceName].whatsappNumber(data);27  }28 29  public async readMessage({ instanceName }: InstanceDto, data: ReadMessageDto) {30    return await this.waMonitor.waInstances[instanceName].markMessageAsRead(data);31  }32 33  public async archiveChat({ instanceName }: InstanceDto, data: ArchiveChatDto) {34    return await this.waMonitor.waInstances[instanceName].archiveChat(data);35  }36 37  public async markChatUnread({ instanceName }: InstanceDto, data: MarkChatUnreadDto) {38    return await this.waMonitor.waInstances[instanceName].markChatUnread(data);39  }40 41  public async deleteMessage({ instanceName }: InstanceDto, data: DeleteMessage) {42    return await this.waMonitor.waInstances[instanceName].deleteMessage(data);43  }44 45  public async fetchProfilePicture({ instanceName }: InstanceDto, data: NumberDto) {46    return await this.waMonitor.waInstances[instanceName].profilePicture(data.number);47  }48 49  public async fetchProfile({ instanceName }: InstanceDto, data: NumberDto) {50    return await this.waMonitor.waInstances[instanceName].fetchProfile(instanceName, data.number);51  }52 53  public async fetchContacts({ instanceName }: InstanceDto, query: Query<Contact>) {54    return await this.waMonitor.waInstances[instanceName].fetchContacts(query);55  }56 57  public async getBase64FromMediaMessage({ instanceName }: InstanceDto, data: getBase64FromMediaMessageDto) {58    return await this.waMonitor.waInstances[instanceName].getBase64FromMediaMessage(data);59  }60 61  public async fetchMessages({ instanceName }: InstanceDto, query: Query<Message>) {62    return await this.waMonitor.waInstances[instanceName].fetchMessages(query);63  }64 65  public async fetchStatusMessage({ instanceName }: InstanceDto, query: Query<MessageUpdate>) {66    return await this.waMonitor.waInstances[instanceName].fetchStatusMessage(query);67  }68 69  public async fetchChats({ instanceName }: InstanceDto, query: Query<Contact>) {70    return await this.waMonitor.waInstances[instanceName].fetchChats(query);71  }72 73  public async findChatByRemoteJid({ instanceName }: InstanceDto, remoteJid: string) {74    return await this.waMonitor.waInstances[instanceName].findChatByRemoteJid(remoteJid);75  }76 77  public async sendPresence({ instanceName }: InstanceDto, data: SendPresenceDto) {78    return await this.waMonitor.waInstances[instanceName].sendPresence(data);79  }80 81  public async fetchPrivacySettings({ instanceName }: InstanceDto) {82    return await this.waMonitor.waInstances[instanceName].fetchPrivacySettings();83  }84 85  public async updatePrivacySettings({ instanceName }: InstanceDto, data: PrivacySettingDto) {86    return await this.waMonitor.waInstances[instanceName].updatePrivacySettings(data);87  }88 89  public async fetchBusinessProfile({ instanceName }: InstanceDto, data: ProfilePictureDto) {90    return await this.waMonitor.waInstances[instanceName].fetchBusinessProfile(data.number);91  }92 93  public async updateProfileName({ instanceName }: InstanceDto, data: ProfileNameDto) {94    return await this.waMonitor.waInstances[instanceName].updateProfileName(data.name);95  }96 97  public async updateProfileStatus({ instanceName }: InstanceDto, data: ProfileStatusDto) {98    return await this.waMonitor.waInstances[instanceName].updateProfileStatus(data.status);99  }100 101  public async updateProfilePicture({ instanceName }: InstanceDto, data: ProfilePictureDto) {102    return await this.waMonitor.waInstances[instanceName].updateProfilePicture(data.picture);103  }104 105  public async removeProfilePicture({ instanceName }: InstanceDto) {106    return await this.waMonitor.waInstances[instanceName].removeProfilePicture();107  }108 109  public async updateMessage({ instanceName }: InstanceDto, data: UpdateMessageDto) {110    return await this.waMonitor.waInstances[instanceName].updateMessage(data);111  }112 113  public async blockUser({ instanceName }: InstanceDto, data: BlockUserDto) {114    return await this.waMonitor.waInstances[instanceName].blockUser(data);115  }116}117