mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-31 04:02:26 -05:00 
			
		
		
		
	[bugfix] Use util.IsNil for checking DomainPermission (#4040)
This commit is contained in:
		
					parent
					
						
							
								a87be80c90
							
						
					
				
			
			
				commit
				
					
						0992ffc057
					
				
			
		
					 1 changed files with 14 additions and 8 deletions
				
			
		|  | @ -267,7 +267,7 @@ func (p *Processor) importOrUpdateDomainPerm( | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	var errWithCode gtserror.WithCode | 	var errWithCode gtserror.WithCode | ||||||
| 	if domainPerm != nil { | 	if !util.IsNil(domainPerm) { | ||||||
| 		// Permission already exists, update it. | 		// Permission already exists, update it. | ||||||
| 		apiDomainPerm, errWithCode = p.DomainPermissionUpdate( | 		apiDomainPerm, errWithCode = p.DomainPermissionUpdate( | ||||||
| 			ctx, | 			ctx, | ||||||
|  | @ -394,14 +394,20 @@ func (p *Processor) DomainPermissionGet( | ||||||
| 		err = gtserror.New("unrecognized permission type") | 		err = gtserror.New("unrecognized permission type") | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if err != nil { | 	if err != nil && errors.Is(err, db.ErrNoEntries) { | ||||||
| 		if errors.Is(err, db.ErrNoEntries) { | 		err = gtserror.Newf( | ||||||
| 			err = fmt.Errorf("no domain %s exists with id %s", permissionType.String(), id) | 			"db error getting domain %s with id %s: %w", | ||||||
| 			return nil, gtserror.NewErrorNotFound(err, err.Error()) | 			permissionType.String(), id, err, | ||||||
|  | 		) | ||||||
|  | 		return nil, gtserror.NewErrorInternalError(err) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 		err = gtserror.Newf("error getting domain %s with id %s: %w", permissionType.String(), id, err) | 	if util.IsNil(domainPerm) { | ||||||
| 		return nil, gtserror.NewErrorInternalError(err) | 		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) | 	return p.apiDomainPerm(ctx, domainPerm, export) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue