feat: Route to update the privacy settings

This commit is contained in:
Davidson Gomes
2023-06-11 11:38:26 -03:00
parent 55e36f24a5
commit ab28b4c0c5
6 changed files with 88 additions and 0 deletions

View File

@@ -29,6 +29,9 @@ import makeWASocket, {
WAMessage,
WAMessageUpdate,
WASocket,
WAReadReceiptsValue,
WAPrivacyValue,
WAPrivacyOnlineValue,
} from '@evolution/base';
import {
Auth,
@@ -81,6 +84,7 @@ import {
ArchiveChatDto,
DeleteMessage,
OnWhatsAppDto,
PrivacySettingDto,
ReadMessageDto,
WhatsAppNumberDto,
} from '../dto/chat.dto';
@@ -1479,6 +1483,23 @@ export class WAStartupService {
return await this.client.fetchPrivacySettings();
}
public async updatePrivacySettings(settings: PrivacySettingDto) {
try {
await this.client.updateReadReceiptsPrivacy(settings.privacySettings.readreceipts);
await this.client.updateProfilePicturePrivacy(settings.privacySettings.profile);
await this.client.updateStatusPrivacy(settings.privacySettings.status);
await this.client.updateOnlinePrivacy(settings.privacySettings.online);
await this.client.updateLastSeenPrivacy(settings.privacySettings.last);
await this.client.updateGroupsAddPrivacy(settings.privacySettings.groupadd);
return { update: 'success', data: await this.client.fetchPrivacySettings() };
} catch (error) {
throw new InternalServerErrorException(
'Error updating privacy settings',
error.toString(),
);
}
}
public async getBusinessProfile(number: string) {
try {
let jid;