MM-23816: Group Mentions: Add ability to rename group names (#14338)
* MM-23816: Group Mentions: Add ability to rename group names
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9dc64173dc
Коммит
41e58d9769
@@ -137,12 +137,32 @@ func patchGroup(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
auditRec.AddMeta("group", group)
|
||||
|
||||
if groupPatch.AllowReference != nil && *groupPatch.AllowReference {
|
||||
tmp := model.NewId()
|
||||
if groupPatch.Name == nil {
|
||||
tmp = strings.ReplaceAll(strings.ToLower(group.DisplayName), " ", "-")
|
||||
tmp := strings.ReplaceAll(strings.ToLower(group.DisplayName), " ", "-")
|
||||
groupPatch.Name = &tmp
|
||||
} else {
|
||||
if *groupPatch.Name == model.USER_NOTIFY_ALL || *groupPatch.Name == model.CHANNEL_MENTIONS_NOTIFY_PROP || *groupPatch.Name == model.USER_NOTIFY_HERE {
|
||||
c.Err = model.NewAppError("Api4.patchGroup", "api.ldap_groups.existing_reserved_name_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
//check if a user already has this group name
|
||||
user, _ := c.App.GetUserByUsername(*groupPatch.Name)
|
||||
if user != nil {
|
||||
c.Err = model.NewAppError("Api4.patchGroup", "api.ldap_groups.existing_user_name_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
//check if a mentionable group already has this name
|
||||
searchOpts := model.GroupSearchOpts{
|
||||
FilterAllowReference: true,
|
||||
}
|
||||
existingGroup, _ := c.App.GetGroupByName(*groupPatch.Name, searchOpts)
|
||||
if existingGroup != nil {
|
||||
c.Err = model.NewAppError("Api4.patchGroup", "api.ldap_groups.existing_group_name_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
}
|
||||
groupPatch.Name = &tmp
|
||||
}
|
||||
|
||||
group.Patch(groupPatch)
|
||||
|
||||
group, err = c.App.UpdateGroup(group)
|
||||
|
||||
Ссылка в новой задаче
Block a user