Skip to content

Commit

Permalink
Adding database function to edit the avatar only
Browse files Browse the repository at this point in the history
  • Loading branch information
COMTOP1 committed Feb 16, 2025
1 parent 3a100f5 commit 682f0df
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions user/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type (
EditUserPassword(context.Context, User) error
EditUser(context.Context, User, int) error
SetUserLoggedIn(context.Context, User) error
EditUserAvatar(context.Context, User) error
DeleteUser(context.Context, User, int) error
GetPermissionsForUser(context.Context, User) ([]permission.Permission, error)
GetRolesForUser(context.Context, User) ([]role.Role, error)
Expand Down Expand Up @@ -361,6 +362,20 @@ func (s *Store) SetUserLoggedIn(ctx context.Context, u User) error {
return s.editUser(ctx, u)
}

func (s *Store) EditUserAvatar(ctx context.Context, userParam User) error {
user, err := s.getUser(ctx, userParam)
if err != nil {
return fmt.Errorf("failed to get user: %w", err)
}
user.UseGravatar = userParam.UseGravatar
user.Avatar = userParam.Avatar
err = s.editUser(ctx, user)
if err != nil {
return fmt.Errorf("failed to edit user for edit user password: %w", err)
}
return nil
}

// DeleteUser will soft delete a user
func (s *Store) DeleteUser(ctx context.Context, u User, userID int) error {
now := null.TimeFrom(time.Now())
Expand Down

0 comments on commit 682f0df

Please sign in to comment.