mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 12:12:55 -06:00
feat: Route to update group description
This commit is contained in:
parent
a28bbce1f9
commit
ea9ba27f22
@ -8,6 +8,7 @@
|
|||||||
* Route to fetch all privacy settings
|
* Route to fetch all privacy settings
|
||||||
* Route to update the privacy settings
|
* Route to update the privacy settings
|
||||||
* Route to update group subject
|
* Route to update group subject
|
||||||
|
* Route to update group description
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
@ -702,6 +702,17 @@ export const updateGroupSubjectSchema: JSONSchema7 = {
|
|||||||
...isNotEmpty('groupJid', 'subject'),
|
...isNotEmpty('groupJid', 'subject'),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const updateGroupDescriptionSchema: JSONSchema7 = {
|
||||||
|
$id: v4(),
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
groupJid: { type: 'string' },
|
||||||
|
description: { type: 'string' },
|
||||||
|
},
|
||||||
|
required: ['groupJid', 'description'],
|
||||||
|
...isNotEmpty('groupJid', 'description'),
|
||||||
|
};
|
||||||
|
|
||||||
// Webhook Schema
|
// Webhook Schema
|
||||||
export const webhookSchema: JSONSchema7 = {
|
export const webhookSchema: JSONSchema7 = {
|
||||||
$id: v4(),
|
$id: v4(),
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
CreateGroupDto,
|
CreateGroupDto,
|
||||||
|
GroupDescriptionDto,
|
||||||
GroupInvite,
|
GroupInvite,
|
||||||
GroupJid,
|
GroupJid,
|
||||||
GroupPictureDto,
|
GroupPictureDto,
|
||||||
@ -30,6 +31,15 @@ export class GroupController {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async updateGroupDescription(
|
||||||
|
instance: InstanceDto,
|
||||||
|
update: GroupDescriptionDto,
|
||||||
|
) {
|
||||||
|
return await this.waMonitor.waInstances[instance.instanceName].updateGroupDescription(
|
||||||
|
update,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public async findGroupInfo(instance: InstanceDto, groupJid: GroupJid) {
|
public async findGroupInfo(instance: InstanceDto, groupJid: GroupJid) {
|
||||||
return await this.waMonitor.waInstances[instance.instanceName].findGroup(groupJid);
|
return await this.waMonitor.waInstances[instance.instanceName].findGroup(groupJid);
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,11 @@ export class GroupSubjectDto {
|
|||||||
subject: string;
|
subject: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class GroupDescriptionDto {
|
||||||
|
groupJid: string;
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
|
|
||||||
export class GroupJid {
|
export class GroupJid {
|
||||||
groupJid: string;
|
groupJid: string;
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import {
|
|||||||
toggleEphemeralSchema,
|
toggleEphemeralSchema,
|
||||||
updateGroupPictureSchema,
|
updateGroupPictureSchema,
|
||||||
updateGroupSubjectSchema,
|
updateGroupSubjectSchema,
|
||||||
|
updateGroupDescriptionSchema,
|
||||||
groupInviteSchema,
|
groupInviteSchema,
|
||||||
} from '../../validate/validate.schema';
|
} from '../../validate/validate.schema';
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
import { RouterBroker } from '../abstract/abstract.router';
|
||||||
@ -16,6 +17,7 @@ import {
|
|||||||
GroupJid,
|
GroupJid,
|
||||||
GroupPictureDto,
|
GroupPictureDto,
|
||||||
GroupSubjectDto,
|
GroupSubjectDto,
|
||||||
|
GroupDescriptionDto,
|
||||||
GroupUpdateParticipantDto,
|
GroupUpdateParticipantDto,
|
||||||
GroupUpdateSettingDto,
|
GroupUpdateSettingDto,
|
||||||
GroupToggleEphemeralDto,
|
GroupToggleEphemeralDto,
|
||||||
@ -57,6 +59,17 @@ export class GroupRouter extends RouterBroker {
|
|||||||
|
|
||||||
res.status(HttpStatus.CREATED).json(response);
|
res.status(HttpStatus.CREATED).json(response);
|
||||||
})
|
})
|
||||||
|
.put(this.routerPath('updateGroupDescription'), ...guards, async (req, res) => {
|
||||||
|
const response = await this.groupValidate<GroupDescriptionDto>({
|
||||||
|
request: req,
|
||||||
|
schema: updateGroupDescriptionSchema,
|
||||||
|
ClassRef: GroupDescriptionDto,
|
||||||
|
execute: (instance, data) =>
|
||||||
|
groupController.updateGroupDescription(instance, data),
|
||||||
|
});
|
||||||
|
|
||||||
|
res.status(HttpStatus.CREATED).json(response);
|
||||||
|
})
|
||||||
.get(this.routerPath('findGroupInfos'), ...guards, async (req, res) => {
|
.get(this.routerPath('findGroupInfos'), ...guards, async (req, res) => {
|
||||||
const response = await this.groupValidate<GroupJid>({
|
const response = await this.groupValidate<GroupJid>({
|
||||||
request: req,
|
request: req,
|
||||||
|
@ -101,6 +101,7 @@ import {
|
|||||||
GroupUpdateSettingDto,
|
GroupUpdateSettingDto,
|
||||||
GroupToggleEphemeralDto,
|
GroupToggleEphemeralDto,
|
||||||
GroupSubjectDto,
|
GroupSubjectDto,
|
||||||
|
GroupDescriptionDto,
|
||||||
} from '../dto/group.dto';
|
} from '../dto/group.dto';
|
||||||
import { MessageUpQuery } from '../repository/messageUp.repository';
|
import { MessageUpQuery } from '../repository/messageUp.repository';
|
||||||
import { useMultiFileAuthStateDb } from '../../utils/use-multi-file-auth-state-db';
|
import { useMultiFileAuthStateDb } from '../../utils/use-multi-file-auth-state-db';
|
||||||
@ -1652,6 +1653,19 @@ export class WAStartupService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async updateGroupDescription(data: GroupDescriptionDto) {
|
||||||
|
try {
|
||||||
|
await this.client.groupUpdateDescription(data.groupJid, data.description);
|
||||||
|
|
||||||
|
return { update: 'success' };
|
||||||
|
} catch (error) {
|
||||||
|
throw new InternalServerErrorException(
|
||||||
|
'Error updating group description',
|
||||||
|
error.toString(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async findGroup(id: GroupJid, reply: 'inner' | 'out' = 'out') {
|
public async findGroup(id: GroupJid, reply: 'inner' | 'out' = 'out') {
|
||||||
try {
|
try {
|
||||||
return await this.client.groupMetadata(id.groupJid);
|
return await this.client.groupMetadata(id.groupJid);
|
||||||
|
Loading…
Reference in New Issue
Block a user