mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-13 15:14:49 -06:00
feat: Route to update group subject
This commit is contained in:
parent
75b48aa8ac
commit
a28bbce1f9
@ -7,6 +7,7 @@
|
||||
* Route to fetch all groups that the connection is part of
|
||||
* Route to fetch all privacy settings
|
||||
* Route to update the privacy settings
|
||||
* Route to update group subject
|
||||
|
||||
### Fixed
|
||||
|
||||
|
@ -680,7 +680,7 @@ export const toggleEphemeralSchema: JSONSchema7 = {
|
||||
...isNotEmpty('groupJid', 'expiration'),
|
||||
};
|
||||
|
||||
export const updateGroupPicture: JSONSchema7 = {
|
||||
export const updateGroupPictureSchema: JSONSchema7 = {
|
||||
$id: v4(),
|
||||
type: 'object',
|
||||
properties: {
|
||||
@ -691,6 +691,17 @@ export const updateGroupPicture: JSONSchema7 = {
|
||||
...isNotEmpty('groupJid', 'image'),
|
||||
};
|
||||
|
||||
export const updateGroupSubjectSchema: JSONSchema7 = {
|
||||
$id: v4(),
|
||||
type: 'object',
|
||||
properties: {
|
||||
groupJid: { type: 'string' },
|
||||
subject: { type: 'string' },
|
||||
},
|
||||
required: ['groupJid', 'subject'],
|
||||
...isNotEmpty('groupJid', 'subject'),
|
||||
};
|
||||
|
||||
// Webhook Schema
|
||||
export const webhookSchema: JSONSchema7 = {
|
||||
$id: v4(),
|
||||
|
@ -3,6 +3,7 @@ import {
|
||||
GroupInvite,
|
||||
GroupJid,
|
||||
GroupPictureDto,
|
||||
GroupSubjectDto,
|
||||
GroupToggleEphemeralDto,
|
||||
GroupUpdateParticipantDto,
|
||||
GroupUpdateSettingDto,
|
||||
@ -23,6 +24,12 @@ export class GroupController {
|
||||
);
|
||||
}
|
||||
|
||||
public async updateGroupSubject(instance: InstanceDto, update: GroupSubjectDto) {
|
||||
return await this.waMonitor.waInstances[instance.instanceName].updateGroupSubject(
|
||||
update,
|
||||
);
|
||||
}
|
||||
|
||||
public async findGroupInfo(instance: InstanceDto, groupJid: GroupJid) {
|
||||
return await this.waMonitor.waInstances[instance.instanceName].findGroup(groupJid);
|
||||
}
|
||||
|
@ -1,4 +1,8 @@
|
||||
import { WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from "@evolution/base";
|
||||
import {
|
||||
WAPrivacyOnlineValue,
|
||||
WAPrivacyValue,
|
||||
WAReadReceiptsValue,
|
||||
} from '@evolution/base';
|
||||
|
||||
export class OnWhatsAppDto {
|
||||
constructor(
|
||||
|
@ -9,6 +9,11 @@ export class GroupPictureDto {
|
||||
image: string;
|
||||
}
|
||||
|
||||
export class GroupSubjectDto {
|
||||
groupJid: string;
|
||||
subject: string;
|
||||
}
|
||||
|
||||
export class GroupJid {
|
||||
groupJid: string;
|
||||
}
|
||||
|
@ -5,7 +5,8 @@ import {
|
||||
updateParticipantsSchema,
|
||||
updateSettingsSchema,
|
||||
toggleEphemeralSchema,
|
||||
updateGroupPicture,
|
||||
updateGroupPictureSchema,
|
||||
updateGroupSubjectSchema,
|
||||
groupInviteSchema,
|
||||
} from '../../validate/validate.schema';
|
||||
import { RouterBroker } from '../abstract/abstract.router';
|
||||
@ -14,6 +15,7 @@ import {
|
||||
GroupInvite,
|
||||
GroupJid,
|
||||
GroupPictureDto,
|
||||
GroupSubjectDto,
|
||||
GroupUpdateParticipantDto,
|
||||
GroupUpdateSettingDto,
|
||||
GroupToggleEphemeralDto,
|
||||
@ -35,10 +37,20 @@ export class GroupRouter extends RouterBroker {
|
||||
|
||||
res.status(HttpStatus.CREATED).json(response);
|
||||
})
|
||||
.put(this.routerPath('updateGroupSubject'), ...guards, async (req, res) => {
|
||||
const response = await this.groupValidate<GroupSubjectDto>({
|
||||
request: req,
|
||||
schema: updateGroupSubjectSchema,
|
||||
ClassRef: GroupSubjectDto,
|
||||
execute: (instance, data) => groupController.updateGroupSubject(instance, data),
|
||||
});
|
||||
|
||||
res.status(HttpStatus.CREATED).json(response);
|
||||
})
|
||||
.put(this.routerPath('updateGroupPicture'), ...guards, async (req, res) => {
|
||||
const response = await this.groupValidate<GroupPictureDto>({
|
||||
request: req,
|
||||
schema: updateGroupPicture,
|
||||
schema: updateGroupPictureSchema,
|
||||
ClassRef: GroupPictureDto,
|
||||
execute: (instance, data) => groupController.updateGroupPicture(instance, data),
|
||||
});
|
||||
|
@ -100,6 +100,7 @@ import {
|
||||
GroupUpdateParticipantDto,
|
||||
GroupUpdateSettingDto,
|
||||
GroupToggleEphemeralDto,
|
||||
GroupSubjectDto,
|
||||
} from '../dto/group.dto';
|
||||
import { MessageUpQuery } from '../repository/messageUp.repository';
|
||||
import { useMultiFileAuthStateDb } from '../../utils/use-multi-file-auth-state-db';
|
||||
@ -1631,7 +1632,23 @@ export class WAStartupService {
|
||||
|
||||
return { update: 'success' };
|
||||
} catch (error) {
|
||||
throw new InternalServerErrorException('Error creating group', error.toString());
|
||||
throw new InternalServerErrorException(
|
||||
'Error update group picture',
|
||||
error.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public async updateGroupSubject(data: GroupSubjectDto) {
|
||||
try {
|
||||
await this.client.groupUpdateSubject(data.groupJid, data.subject);
|
||||
|
||||
return { update: 'success' };
|
||||
} catch (error) {
|
||||
throw new InternalServerErrorException(
|
||||
'Error updating group subject',
|
||||
error.toString(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user