MCPcopy Create free account
hub / github.com/msgbyte/tailchat / updateGroupRoleName

Method updateGroupRoleName

server/models/group/group.ts:244–264  ·  view source on GitHub ↗

* 修改群组角色名

(
    this: ReturnModelType<typeof Group>,
    groupId: string,
    roleId: string,
    roleName: string
  )

Source from the content-addressed store, hash-verified

242 * 修改群组角色名
243 */
244 static async updateGroupRoleName(
245 this: ReturnModelType<typeof Group>,
246 groupId: string,
247 roleId: string,
248 roleName: string
249 ): Promise<Group> {
250 const group = await this.findById(groupId);
251 if (!group) {
252 throw new Error('Not Found Group');
253 }
254
255 const modifyRole = group.roles.find((role) => String(role._id) === roleId);
256 if (!modifyRole) {
257 throw new Error('Not Found Role');
258 }
259
260 modifyRole.name = roleName;
261 await group.save();
262
263 return group;
264 }
265
266 /**
267 * 修改群组角色权限

Callers 1

useRoleActionsFunction · 0.45

Calls 3

findByIdMethod · 0.80
saveMethod · 0.80
findMethod · 0.65

Tested by

no test coverage detected