mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-14 09:51:24 -06:00
Merge branch 'release/1.4.2'
This commit is contained in:
commit
f95f3126c3
@ -1,3 +1,11 @@
|
|||||||
|
# 1.4.2 (2023-07-24 20:52)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
* Fixed validation is set settings
|
||||||
|
* Adjusts in group validations
|
||||||
|
* Ajusts in sticker message to chatwoot
|
||||||
|
|
||||||
# 1.4.1 (2023-07-24 18:28)
|
# 1.4.1 (2023-07-24 18:28)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "evolution-api",
|
"name": "evolution-api",
|
||||||
"version": "1.4.1",
|
"version": "1.4.2",
|
||||||
"description": "Rest api for communication with WhatsApp",
|
"description": "Rest api for communication with WhatsApp",
|
||||||
"main": "./dist/src/main.js",
|
"main": "./dist/src/main.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -667,6 +667,7 @@ export const createGroupSchema: JSONSchema7 = {
|
|||||||
subject: { type: 'string' },
|
subject: { type: 'string' },
|
||||||
description: { type: 'string' },
|
description: { type: 'string' },
|
||||||
profilePicture: { type: 'string' },
|
profilePicture: { type: 'string' },
|
||||||
|
promoteParticipants: { type: 'boolean', enum: [true, false] },
|
||||||
participants: {
|
participants: {
|
||||||
type: 'array',
|
type: 'array',
|
||||||
minItems: 1,
|
minItems: 1,
|
||||||
|
@ -41,6 +41,7 @@ export class InstanceController {
|
|||||||
chatwoot_url,
|
chatwoot_url,
|
||||||
chatwoot_sign_msg,
|
chatwoot_sign_msg,
|
||||||
}: InstanceDto) {
|
}: InstanceDto) {
|
||||||
|
try {
|
||||||
this.logger.verbose('requested createInstance from ' + instanceName + ' instance');
|
this.logger.verbose('requested createInstance from ' + instanceName + ' instance');
|
||||||
|
|
||||||
if (instanceName !== instanceName.toLowerCase().replace(/[^a-z0-9]/g, '')) {
|
if (instanceName !== instanceName.toLowerCase().replace(/[^a-z0-9]/g, '')) {
|
||||||
@ -189,6 +190,10 @@ export class InstanceController {
|
|||||||
webhook_url: `${urlServer}/chatwoot/webhook/${instance.instanceName}`,
|
webhook_url: `${urlServer}/chatwoot/webhook/${instance.instanceName}`,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
return { error: true, message: error.toString() };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async connectToWhatsapp({ instanceName, number = null }: InstanceDto) {
|
public async connectToWhatsapp({ instanceName, number = null }: InstanceDto) {
|
||||||
|
@ -15,10 +15,6 @@ export class SettingsController {
|
|||||||
'requested createSettings from ' + instance.instanceName + ' instance',
|
'requested createSettings from ' + instance.instanceName + ' instance',
|
||||||
);
|
);
|
||||||
|
|
||||||
if (data.reject_call && data.msg_call.trim() == '') {
|
|
||||||
throw new BadRequestException('msg_call is required');
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.settingsService.create(instance, data);
|
return this.settingsService.create(instance, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
export class CreateGroupDto {
|
export class CreateGroupDto {
|
||||||
subject: string;
|
subject: string;
|
||||||
description?: string;
|
|
||||||
participants: string[];
|
participants: string[];
|
||||||
|
description?: string;
|
||||||
|
promoteParticipants?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GroupPictureDto {
|
export class GroupPictureDto {
|
||||||
|
@ -102,7 +102,12 @@ export class RepositoryBroker {
|
|||||||
this.logger.verbose('creating store path: ' + storePath);
|
this.logger.verbose('creating store path: ' + storePath);
|
||||||
|
|
||||||
const tempDir = join(storePath, 'temp');
|
const tempDir = join(storePath, 'temp');
|
||||||
|
const chatwootDir = join(storePath, 'chatwoot');
|
||||||
|
|
||||||
|
if (!fs.existsSync(chatwootDir)) {
|
||||||
|
this.logger.verbose('creating chatwoot dir: ' + chatwootDir);
|
||||||
|
fs.mkdirSync(chatwootDir, { recursive: true });
|
||||||
|
}
|
||||||
if (!fs.existsSync(tempDir)) {
|
if (!fs.existsSync(tempDir)) {
|
||||||
this.logger.verbose('creating temp dir: ' + tempDir);
|
this.logger.verbose('creating temp dir: ' + tempDir);
|
||||||
fs.mkdirSync(tempDir, { recursive: true });
|
fs.mkdirSync(tempDir, { recursive: true });
|
||||||
|
@ -1179,7 +1179,7 @@ export class ChatwootService {
|
|||||||
videoMessage: msg.videoMessage?.caption,
|
videoMessage: msg.videoMessage?.caption,
|
||||||
extendedTextMessage: msg.extendedTextMessage?.text,
|
extendedTextMessage: msg.extendedTextMessage?.text,
|
||||||
messageContextInfo: msg.messageContextInfo?.stanzaId,
|
messageContextInfo: msg.messageContextInfo?.stanzaId,
|
||||||
stickerMessage: msg.stickerMessage?.fileSha256.toString('base64'),
|
stickerMessage: undefined,
|
||||||
documentMessage: msg.documentMessage?.caption,
|
documentMessage: msg.documentMessage?.caption,
|
||||||
documentWithCaptionMessage:
|
documentWithCaptionMessage:
|
||||||
msg.documentWithCaptionMessage?.message?.documentMessage?.caption,
|
msg.documentWithCaptionMessage?.message?.documentMessage?.caption,
|
||||||
@ -1199,10 +1199,6 @@ export class ChatwootService {
|
|||||||
|
|
||||||
const result = typeKey ? types[typeKey] : undefined;
|
const result = typeKey ? types[typeKey] : undefined;
|
||||||
|
|
||||||
if (typeKey === 'stickerMessage') {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeKey === 'contactMessage') {
|
if (typeKey === 'contactMessage') {
|
||||||
const vCardData = result.split('\n');
|
const vCardData = result.split('\n');
|
||||||
const contactInfo = {};
|
const contactInfo = {};
|
||||||
|
@ -116,16 +116,15 @@ import { useMultiFileAuthStateDb } from '../../utils/use-multi-file-auth-state-d
|
|||||||
import Long from 'long';
|
import Long from 'long';
|
||||||
import { WebhookRaw } from '../models/webhook.model';
|
import { WebhookRaw } from '../models/webhook.model';
|
||||||
import { ChatwootRaw } from '../models/chatwoot.model';
|
import { ChatwootRaw } from '../models/chatwoot.model';
|
||||||
|
import { SettingsRaw } from '../models';
|
||||||
import { dbserver } from '../../db/db.connect';
|
import { dbserver } from '../../db/db.connect';
|
||||||
import NodeCache from 'node-cache';
|
import NodeCache from 'node-cache';
|
||||||
import { useMultiFileAuthStateRedisDb } from '../../utils/use-multi-file-auth-state-redis-db';
|
import { useMultiFileAuthStateRedisDb } from '../../utils/use-multi-file-auth-state-redis-db';
|
||||||
import sharp from 'sharp';
|
import sharp from 'sharp';
|
||||||
import { RedisCache } from '../../db/redis.client';
|
import { RedisCache } from '../../db/redis.client';
|
||||||
import { Log } from '../../config/env.config';
|
import { Log } from '../../config/env.config';
|
||||||
import ProxyAgent from 'proxy-agent';
|
|
||||||
import { ChatwootService } from './chatwoot.service';
|
import { ChatwootService } from './chatwoot.service';
|
||||||
import { waMonitor } from '../whatsapp.module';
|
import { waMonitor } from '../whatsapp.module';
|
||||||
import { SettingsRaw } from '../models';
|
|
||||||
|
|
||||||
export class WAStartupService {
|
export class WAStartupService {
|
||||||
constructor(
|
constructor(
|
||||||
@ -382,7 +381,7 @@ export class WAStartupService {
|
|||||||
|
|
||||||
if (!data) {
|
if (!data) {
|
||||||
this.logger.verbose('Settings not found');
|
this.logger.verbose('Settings not found');
|
||||||
throw new NotFoundException('Settings not found');
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.verbose(`Settings url: ${data.reject_call}`);
|
this.logger.verbose(`Settings url: ${data.reject_call}`);
|
||||||
@ -1129,7 +1128,7 @@ export class WAStartupService {
|
|||||||
received.messageTimestamp = received.messageTimestamp?.toNumber();
|
received.messageTimestamp = received.messageTimestamp?.toNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.groups_ignore && received.key.remoteJid.includes('@g.us')) {
|
if (settings?.groups_ignore && received.key.remoteJid.includes('@g.us')) {
|
||||||
this.logger.verbose('group ignored');
|
this.logger.verbose('group ignored');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1517,7 +1516,7 @@ export class WAStartupService {
|
|||||||
.split(/\:/)[0]
|
.split(/\:/)[0]
|
||||||
.split('@')[0];
|
.split('@')[0];
|
||||||
|
|
||||||
if (number.length >= 18) {
|
if (number.includes('-') && number.length >= 24) {
|
||||||
this.logger.verbose('Jid created is group: ' + `${number}@g.us`);
|
this.logger.verbose('Jid created is group: ' + `${number}@g.us`);
|
||||||
number = number.replace(/[^\d-]/g, '');
|
number = number.replace(/[^\d-]/g, '');
|
||||||
return `${number}@g.us`;
|
return `${number}@g.us`;
|
||||||
@ -1525,6 +1524,12 @@ export class WAStartupService {
|
|||||||
|
|
||||||
number = number.replace(/\D/g, '');
|
number = number.replace(/\D/g, '');
|
||||||
|
|
||||||
|
if (number.length >= 18) {
|
||||||
|
this.logger.verbose('Jid created is group: ' + `${number}@g.us`);
|
||||||
|
number = number.replace(/[^\d-]/g, '');
|
||||||
|
return `${number}@g.us`;
|
||||||
|
}
|
||||||
|
|
||||||
this.logger.verbose('Jid created is whatsapp: ' + `${number}@s.whatsapp.net`);
|
this.logger.verbose('Jid created is whatsapp: ' + `${number}@s.whatsapp.net`);
|
||||||
return `${number}@s.whatsapp.net`;
|
return `${number}@s.whatsapp.net`;
|
||||||
}
|
}
|
||||||
@ -1686,20 +1691,13 @@ export class WAStartupService {
|
|||||||
if (options?.mentions) {
|
if (options?.mentions) {
|
||||||
this.logger.verbose('Mentions defined');
|
this.logger.verbose('Mentions defined');
|
||||||
|
|
||||||
if (
|
if (options.mentions?.everyOne) {
|
||||||
!Array.isArray(options.mentions.mentioned) &&
|
|
||||||
!options.mentions.everyOne
|
|
||||||
) {
|
|
||||||
throw new BadRequestException('Mentions must be an array');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.mentions.everyOne) {
|
|
||||||
this.logger.verbose('Mentions everyone');
|
this.logger.verbose('Mentions everyone');
|
||||||
|
|
||||||
this.logger.verbose('Getting group metadata');
|
this.logger.verbose('Getting group metadata');
|
||||||
mentions = groupMetadata.participants.map((participant) => participant.id);
|
mentions = groupMetadata.participants.map((participant) => participant.id);
|
||||||
this.logger.verbose('Getting group metadata for mentions');
|
this.logger.verbose('Getting group metadata for mentions');
|
||||||
} else {
|
} else if (options.mentions?.mentioned?.length) {
|
||||||
this.logger.verbose('Mentions manually defined');
|
this.logger.verbose('Mentions manually defined');
|
||||||
mentions = options.mentions.mentioned.map((mention) => {
|
mentions = options.mentions.mentioned.map((mention) => {
|
||||||
const jid = this.createJid(mention);
|
const jid = this.createJid(mention);
|
||||||
@ -2782,10 +2780,19 @@ export class WAStartupService {
|
|||||||
await this.client.groupUpdateDescription(id, create.description);
|
await this.client.groupUpdateDescription(id, create.description);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (create?.promoteParticipants) {
|
||||||
|
this.logger.verbose('Prometing group participants: ' + create.description);
|
||||||
|
await this.updateGParticipant({
|
||||||
|
groupJid: id,
|
||||||
|
action: 'promote',
|
||||||
|
participants: participants,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const group = await this.client.groupMetadata(id);
|
const group = await this.client.groupMetadata(id);
|
||||||
this.logger.verbose('Getting group metadata');
|
this.logger.verbose('Getting group metadata');
|
||||||
|
|
||||||
return { groupMetadata: group };
|
return group;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.logger.error(error);
|
this.logger.error(error);
|
||||||
throw new InternalServerErrorException('Error creating group', error.toString());
|
throw new InternalServerErrorException('Error creating group', error.toString());
|
||||||
|
Loading…
Reference in New Issue
Block a user