mirror of
https://github.com/go-gitea/gitea.git
synced 2026-04-04 18:56:28 +02:00
* move error-related code for groups to its own file * update group avatar logic remove unused/duplicate logic * update `FindGroupsOptions.ToConds()` allow passing `-1` as the `ParentGroupID`, meaning "find matching groups regardless of the parent group id" * add `DedupeBy` function to container module this removes duplicate items from a slice using a custom function * add `SliceMap` util works like javascripts's `Array.prototoype.map`, taking in a slice and transforming each element with the provided function * add group service functions included so far: - avatar uploading/deletion - group deletion - group creation - group moving (including moving item inside a group) - group update - team management - add team - remove team - update team permissions - recalculating team access (in event of group move) - group searching (only used in frontend/web components for now)
32 lines
756 B
Go
32 lines
756 B
Go
package group
|
|
|
|
import (
|
|
"code.gitea.io/gitea/models/db"
|
|
group_model "code.gitea.io/gitea/models/group"
|
|
"code.gitea.io/gitea/modules/optional"
|
|
"code.gitea.io/gitea/modules/structs"
|
|
"context"
|
|
"strings"
|
|
)
|
|
|
|
type UpdateOptions struct {
|
|
Name optional.Option[string]
|
|
Description optional.Option[string]
|
|
Visibility optional.Option[structs.VisibleType]
|
|
}
|
|
|
|
func UpdateGroup(ctx context.Context, g *group_model.Group, opts *UpdateOptions) error {
|
|
if opts.Name.Has() {
|
|
g.Name = opts.Name.Value()
|
|
g.LowerName = strings.ToLower(g.Name)
|
|
}
|
|
if opts.Description.Has() {
|
|
g.Description = opts.Description.Value()
|
|
}
|
|
if opts.Visibility.Has() {
|
|
g.Visibility = opts.Visibility.Value()
|
|
}
|
|
_, err := db.GetEngine(ctx).ID(g.ID).Update(g)
|
|
return err
|
|
}
|