mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-15 19:52:54 -06:00
feat: Added update message endpoint
This commit is contained in:
parent
a446df4620
commit
7373eea842
@ -1,5 +1,9 @@
|
|||||||
# 1.6.2 (develop)
|
# 1.6.2 (develop)
|
||||||
|
|
||||||
|
### Feature
|
||||||
|
|
||||||
|
* Added update message endpoint
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
* Proxy configuration improvements
|
* Proxy configuration improvements
|
||||||
|
@ -592,6 +592,26 @@ export const profileStatusSchema: JSONSchema7 = {
|
|||||||
...isNotEmpty('status'),
|
...isNotEmpty('status'),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const updateMessageSchema: JSONSchema7 = {
|
||||||
|
$id: v4(),
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
number: { type: 'string' },
|
||||||
|
text: { type: 'string' },
|
||||||
|
key: {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
id: { type: 'string' },
|
||||||
|
remoteJid: { type: 'string' },
|
||||||
|
fromMe: { type: 'boolean', enum: [true, false] },
|
||||||
|
},
|
||||||
|
required: ['id', 'fromMe', 'remoteJid'],
|
||||||
|
...isNotEmpty('id', 'remoteJid'),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
...isNotEmpty('number', 'text', 'key'),
|
||||||
|
};
|
||||||
|
|
||||||
export const profilePictureSchema: JSONSchema7 = {
|
export const profilePictureSchema: JSONSchema7 = {
|
||||||
$id: v4(),
|
$id: v4(),
|
||||||
type: 'object',
|
type: 'object',
|
||||||
|
@ -10,6 +10,7 @@ import {
|
|||||||
ProfileStatusDto,
|
ProfileStatusDto,
|
||||||
ReadMessageDto,
|
ReadMessageDto,
|
||||||
SendPresenceDto,
|
SendPresenceDto,
|
||||||
|
UpdateMessageDto,
|
||||||
WhatsAppNumberDto,
|
WhatsAppNumberDto,
|
||||||
} from '../dto/chat.dto';
|
} from '../dto/chat.dto';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
@ -117,4 +118,9 @@ export class ChatController {
|
|||||||
logger.verbose('requested removeProfilePicture from ' + instanceName + ' instance');
|
logger.verbose('requested removeProfilePicture from ' + instanceName + ' instance');
|
||||||
return await this.waMonitor.waInstances[instanceName].removeProfilePicture();
|
return await this.waMonitor.waInstances[instanceName].removeProfilePicture();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async updateMessage({ instanceName }: InstanceDto, data: UpdateMessageDto) {
|
||||||
|
logger.verbose('requested updateMessage from ' + instanceName + ' instance');
|
||||||
|
return await this.waMonitor.waInstances[instanceName].updateMessage(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,3 +100,9 @@ export class SendPresenceDto extends Metadata {
|
|||||||
delay: number;
|
delay: number;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class UpdateMessageDto extends Metadata {
|
||||||
|
number: string;
|
||||||
|
key: proto.IMessageKey;
|
||||||
|
text: string;
|
||||||
|
}
|
||||||
|
@ -14,6 +14,7 @@ import {
|
|||||||
profileSchema,
|
profileSchema,
|
||||||
profileStatusSchema,
|
profileStatusSchema,
|
||||||
readMessageSchema,
|
readMessageSchema,
|
||||||
|
updateMessageSchema,
|
||||||
whatsappNumberSchema,
|
whatsappNumberSchema,
|
||||||
} from '../../validate/validate.schema';
|
} from '../../validate/validate.schema';
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
import { RouterBroker } from '../abstract/abstract.router';
|
||||||
@ -28,6 +29,7 @@ import {
|
|||||||
ProfileStatusDto,
|
ProfileStatusDto,
|
||||||
ReadMessageDto,
|
ReadMessageDto,
|
||||||
SendPresenceDto,
|
SendPresenceDto,
|
||||||
|
UpdateMessageDto,
|
||||||
WhatsAppNumberDto,
|
WhatsAppNumberDto,
|
||||||
} from '../dto/chat.dto';
|
} from '../dto/chat.dto';
|
||||||
import { InstanceDto } from '../dto/instance.dto';
|
import { InstanceDto } from '../dto/instance.dto';
|
||||||
@ -364,6 +366,23 @@ export class ChatRouter extends RouterBroker {
|
|||||||
execute: (instance) => chatController.removeProfilePicture(instance),
|
execute: (instance) => chatController.removeProfilePicture(instance),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return res.status(HttpStatus.OK).json(response);
|
||||||
|
})
|
||||||
|
.put(this.routerPath('updateMessage'), ...guards, async (req, res) => {
|
||||||
|
logger.verbose('request received in updateMessage');
|
||||||
|
logger.verbose('request body: ');
|
||||||
|
logger.verbose(req.body);
|
||||||
|
|
||||||
|
logger.verbose('request query: ');
|
||||||
|
logger.verbose(req.query);
|
||||||
|
|
||||||
|
const response = await this.dataValidate<UpdateMessageDto>({
|
||||||
|
request: req,
|
||||||
|
schema: updateMessageSchema,
|
||||||
|
ClassRef: UpdateMessageDto,
|
||||||
|
execute: (instance, data) => chatController.updateMessage(instance, data),
|
||||||
|
});
|
||||||
|
|
||||||
return res.status(HttpStatus.OK).json(response);
|
return res.status(HttpStatus.OK).json(response);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -85,6 +85,7 @@ import {
|
|||||||
PrivacySettingDto,
|
PrivacySettingDto,
|
||||||
ReadMessageDto,
|
ReadMessageDto,
|
||||||
SendPresenceDto,
|
SendPresenceDto,
|
||||||
|
UpdateMessageDto,
|
||||||
WhatsAppNumberDto,
|
WhatsAppNumberDto,
|
||||||
} from '../dto/chat.dto';
|
} from '../dto/chat.dto';
|
||||||
import {
|
import {
|
||||||
@ -3529,6 +3530,21 @@ export class WAStartupService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async updateMessage(data: UpdateMessageDto) {
|
||||||
|
try {
|
||||||
|
const jid = this.createJid(data.number);
|
||||||
|
|
||||||
|
this.logger.verbose('Updating message');
|
||||||
|
return await this.client.sendMessage(jid, {
|
||||||
|
text: data.text,
|
||||||
|
edit: data.key,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
this.logger.error(error);
|
||||||
|
throw new BadRequestException(error.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Group
|
// Group
|
||||||
public async createGroup(create: CreateGroupDto) {
|
public async createGroup(create: CreateGroupDto) {
|
||||||
this.logger.verbose('Creating group: ' + create.subject);
|
this.logger.verbose('Creating group: ' + create.subject);
|
||||||
|
Loading…
Reference in New Issue
Block a user