🐛 Fix panic on get status from cache
This commit is contained in:
		| @@ -3,9 +3,10 @@ package services | |||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
| 	"fmt" | 	"fmt" | ||||||
|  | 	"time" | ||||||
|  |  | ||||||
| 	"git.solsynth.dev/hypernet/nexus/pkg/proto" | 	"git.solsynth.dev/hypernet/nexus/pkg/proto" | ||||||
| 	"git.solsynth.dev/hypernet/passport/pkg/authkit/models" | 	"git.solsynth.dev/hypernet/passport/pkg/authkit/models" | ||||||
| 	"time" |  | ||||||
|  |  | ||||||
| 	localCache "git.solsynth.dev/hypernet/passport/pkg/internal/cache" | 	localCache "git.solsynth.dev/hypernet/passport/pkg/internal/cache" | ||||||
| 	"git.solsynth.dev/hypernet/passport/pkg/internal/gap" | 	"git.solsynth.dev/hypernet/passport/pkg/internal/gap" | ||||||
| @@ -27,11 +28,11 @@ func GetStatus(uid uint) (models.Status, error) { | |||||||
| 	contx := context.Background() | 	contx := context.Background() | ||||||
|  |  | ||||||
| 	if val, err := marshal.Get(contx, GetStatusCacheKey(uid), new(models.Status)); err == nil { | 	if val, err := marshal.Get(contx, GetStatusCacheKey(uid), new(models.Status)); err == nil { | ||||||
| 		status := val.(models.Status) | 		status := val.(*models.Status) | ||||||
| 		if status.ClearAt != nil && status.ClearAt.Before(time.Now()) { | 		if status.ClearAt != nil && status.ClearAt.Before(time.Now()) { | ||||||
| 			marshal.Delete(contx, GetStatusCacheKey(uid)) | 			marshal.Delete(contx, GetStatusCacheKey(uid)) | ||||||
| 		} else { | 		} else { | ||||||
| 			return status, nil | 			return *status, nil | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	var status models.Status | 	var status models.Status | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user