diff options
| author | 2025-04-22 12:20:45 +0200 | |
|---|---|---|
| committer | 2025-04-22 12:20:45 +0200 | |
| commit | 0992ffc0571561f354e05c8f12784cbb5c00ccc8 (patch) | |
| tree | d38a9bdf2bdd82d0ce889bb8fa96937f6b96bb9c | |
| parent | [feature/frontend] add autocomplete + other helpful attributes to auth html p... (diff) | |
| download | gotosocial-0992ffc0571561f354e05c8f12784cbb5c00ccc8.tar.xz | |
[bugfix] Use util.IsNil for checking DomainPermission (#4040)
| -rw-r--r-- | internal/processing/admin/domainpermission.go | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/internal/processing/admin/domainpermission.go b/internal/processing/admin/domainpermission.go index 04ee2ab26..9b8c88030 100644 --- a/internal/processing/admin/domainpermission.go +++ b/internal/processing/admin/domainpermission.go @@ -267,7 +267,7 @@ func (p *Processor) importOrUpdateDomainPerm( } var errWithCode gtserror.WithCode - if domainPerm != nil { + if !util.IsNil(domainPerm) { // Permission already exists, update it. apiDomainPerm, errWithCode = p.DomainPermissionUpdate( ctx, @@ -394,15 +394,21 @@ func (p *Processor) DomainPermissionGet( err = gtserror.New("unrecognized permission type") } - if err != nil { - if errors.Is(err, db.ErrNoEntries) { - err = fmt.Errorf("no domain %s exists with id %s", permissionType.String(), id) - return nil, gtserror.NewErrorNotFound(err, err.Error()) - } - - err = gtserror.Newf("error getting domain %s with id %s: %w", permissionType.String(), id, err) + if err != nil && errors.Is(err, db.ErrNoEntries) { + err = gtserror.Newf( + "db error getting domain %s with id %s: %w", + permissionType.String(), id, err, + ) return nil, gtserror.NewErrorInternalError(err) } + if util.IsNil(domainPerm) { + errText := fmt.Sprintf( + "no domain %s exists with id %s", + permissionType.String(), id, + ) + return nil, gtserror.NewErrorNotFound(errors.New(errText), errText) + } + return p.apiDomainPerm(ctx, domainPerm, export) } |
