fix(clients): store client group names trimmed

The groups page lists clients.group_name as stored, while every group
action trims the name it is given. A name with surrounding white space,
saved by a node snapshot or by a client edit, was listed as a separate
group, and deleting, renaming or resetting that row acted on the real
group of the trimmed name instead.

Group names are trimmed wherever a client record is built or updated,
and a one-time seeder folds stored names onto their trimmed form.
This commit is contained in:
MHSanaei
2026-11-01 00:03:48 +01:00
parent 376ab34c0f
commit d114845e44
5 changed files with 79 additions and 3 deletions
+1 -1
View File
@@ -923,7 +923,7 @@ func (s *ClientService) Update(inboundSvc *InboundService, id int, updated model
// including the empty string that removes the client from its group.
if err := database.GetDB().Model(&model.ClientRecord{}).
Where("id = ?", id).
UpdateColumn("group_name", updated.Group).Error; err != nil {
UpdateColumn("group_name", strings.TrimSpace(updated.Group)).Error; err != nil {
return needRestart, err
}