mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2025-07-16 12:12:55 -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 groups that the connection is part of
|
||||||
* 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
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
@ -680,7 +680,7 @@ export const toggleEphemeralSchema: JSONSchema7 = {
|
|||||||
...isNotEmpty('groupJid', 'expiration'),
|
...isNotEmpty('groupJid', 'expiration'),
|
||||||
};
|
};
|
||||||
|
|
||||||
export const updateGroupPicture: JSONSchema7 = {
|
export const updateGroupPictureSchema: JSONSchema7 = {
|
||||||
$id: v4(),
|
$id: v4(),
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
@ -691,6 +691,17 @@ export const updateGroupPicture: JSONSchema7 = {
|
|||||||
...isNotEmpty('groupJid', 'image'),
|
...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
|
// Webhook Schema
|
||||||
export const webhookSchema: JSONSchema7 = {
|
export const webhookSchema: JSONSchema7 = {
|
||||||
$id: v4(),
|
$id: v4(),
|
||||||
|
@ -3,6 +3,7 @@ import {
|
|||||||
GroupInvite,
|
GroupInvite,
|
||||||
GroupJid,
|
GroupJid,
|
||||||
GroupPictureDto,
|
GroupPictureDto,
|
||||||
|
GroupSubjectDto,
|
||||||
GroupToggleEphemeralDto,
|
GroupToggleEphemeralDto,
|
||||||
GroupUpdateParticipantDto,
|
GroupUpdateParticipantDto,
|
||||||
GroupUpdateSettingDto,
|
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) {
|
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);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
import { WAPrivacyOnlineValue, WAPrivacyValue, WAReadReceiptsValue } from "@evolution/base";
|
import {
|
||||||
|
WAPrivacyOnlineValue,
|
||||||
|
WAPrivacyValue,
|
||||||
|
WAReadReceiptsValue,
|
||||||
|
} from '@evolution/base';
|
||||||
|
|
||||||
export class OnWhatsAppDto {
|
export class OnWhatsAppDto {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -9,6 +9,11 @@ export class GroupPictureDto {
|
|||||||
image: string;
|
image: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class GroupSubjectDto {
|
||||||
|
groupJid: string;
|
||||||
|
subject: string;
|
||||||
|
}
|
||||||
|
|
||||||
export class GroupJid {
|
export class GroupJid {
|
||||||
groupJid: string;
|
groupJid: string;
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,8 @@ import {
|
|||||||
updateParticipantsSchema,
|
updateParticipantsSchema,
|
||||||
updateSettingsSchema,
|
updateSettingsSchema,
|
||||||
toggleEphemeralSchema,
|
toggleEphemeralSchema,
|
||||||
updateGroupPicture,
|
updateGroupPictureSchema,
|
||||||
|
updateGroupSubjectSchema,
|
||||||
groupInviteSchema,
|
groupInviteSchema,
|
||||||
} from '../../validate/validate.schema';
|
} from '../../validate/validate.schema';
|
||||||
import { RouterBroker } from '../abstract/abstract.router';
|
import { RouterBroker } from '../abstract/abstract.router';
|
||||||
@ -14,6 +15,7 @@ import {
|
|||||||
GroupInvite,
|
GroupInvite,
|
||||||
GroupJid,
|
GroupJid,
|
||||||
GroupPictureDto,
|
GroupPictureDto,
|
||||||
|
GroupSubjectDto,
|
||||||
GroupUpdateParticipantDto,
|
GroupUpdateParticipantDto,
|
||||||
GroupUpdateSettingDto,
|
GroupUpdateSettingDto,
|
||||||
GroupToggleEphemeralDto,
|
GroupToggleEphemeralDto,
|
||||||
@ -35,10 +37,20 @@ export class GroupRouter extends RouterBroker {
|
|||||||
|
|
||||||
res.status(HttpStatus.CREATED).json(response);
|
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) => {
|
.put(this.routerPath('updateGroupPicture'), ...guards, async (req, res) => {
|
||||||
const response = await this.groupValidate<GroupPictureDto>({
|
const response = await this.groupValidate<GroupPictureDto>({
|
||||||
request: req,
|
request: req,
|
||||||
schema: updateGroupPicture,
|
schema: updateGroupPictureSchema,
|
||||||
ClassRef: GroupPictureDto,
|
ClassRef: GroupPictureDto,
|
||||||
execute: (instance, data) => groupController.updateGroupPicture(instance, data),
|
execute: (instance, data) => groupController.updateGroupPicture(instance, data),
|
||||||
});
|
});
|
||||||
|
@ -100,6 +100,7 @@ import {
|
|||||||
GroupUpdateParticipantDto,
|
GroupUpdateParticipantDto,
|
||||||
GroupUpdateSettingDto,
|
GroupUpdateSettingDto,
|
||||||
GroupToggleEphemeralDto,
|
GroupToggleEphemeralDto,
|
||||||
|
GroupSubjectDto,
|
||||||
} 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';
|
||||||
@ -1631,7 +1632,23 @@ export class WAStartupService {
|
|||||||
|
|
||||||
return { update: 'success' };
|
return { update: 'success' };
|
||||||
} catch (error) {
|
} 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