Commit badfa91
Eric Bower
·
2026-07-23 11:29:57 -0400 EDT
parent 4902f05
chore(pgs): service now requires pico+
1 files changed,
+12,
-18
+12,
-18
| ... | ... | @@ -255,24 +255,15 @@ func (h *UploadAssetHandler) findDenylist(bucket storage.Bucket, project *db.Pro | |
| 255 | 255 | return str, nil | |
| 256 | 256 | } | |
| 257 | 257 | ||
| 258 | - | func findPlusFF(dbpool pgsdb.PgsDB, cfg *PgsConfig, userID string) *db.FeatureFlag { | |
| 259 | - | ff, _ := dbpool.FindFeature(userID, "plus") | |
| 260 | - | // we have free tiers so users might not have a feature flag | |
| 261 | - | // in which case we set sane defaults | |
| 262 | - | if ff == nil { | |
| 263 | - | ff = db.NewFeatureFlag( | |
| 264 | - | userID, | |
| 265 | - | "plus", | |
| 266 | - | cfg.MaxSize, | |
| 267 | - | cfg.MaxAssetSize, | |
| 268 | - | cfg.MaxSpecialFileSize, | |
| 269 | - | ) | |
| 258 | + | func findPlusFF(dbpool pgsdb.PgsDB, userID string) (*db.FeatureFlag, error) { | |
| 259 | + | ff, err := dbpool.FindFeature(userID, "plus") | |
| 260 | + | if err != nil { | |
| 261 | + | return nil, err | |
| 262 | + | } | |
| 263 | + | if !ff.IsValid() { | |
| 264 | + | return nil, fmt.Errorf("your pico+ has expired") | |
| 270 | 265 | } | |
| 271 | - | // this is jank | |
| 272 | - | ff.Data.StorageMax = ff.FindStorageMax(cfg.MaxSize) | |
| 273 | - | ff.Data.FileMax = ff.FindFileMax(cfg.MaxAssetSize) | |
| 274 | - | ff.Data.SpecialFileMax = ff.FindSpecialFileMax(cfg.MaxSpecialFileSize) | |
| 275 | - | return ff | |
| 266 | + | return ff, nil | |
| 276 | 267 | } | |
| 277 | 268 | ||
| 278 | 269 | func mtimeToTime(entry *sendutils.FileEntry) time.Time { |
| ... | ... | @@ -343,7 +334,10 @@ func (h *UploadAssetHandler) Write(s *pssh.SSHServerConnSession, entry *sendutil | |
| 343 | 334 | return "", err | |
| 344 | 335 | } | |
| 345 | 336 | ||
| 346 | - | featureFlag := findPlusFF(h.Cfg.DB, h.Cfg, user.ID) | |
| 337 | + | featureFlag, err := findPlusFF(h.Cfg.DB, user.ID) | |
| 338 | + | if err != nil { | |
| 339 | + | return "", err | |
| 340 | + | } | |
| 347 | 341 | if !featureFlag.IsValid() && pgsdb.IsProjectPrivate(projectName) { | |
| 348 | 342 | return "", fmt.Errorf("private projects are only allowed for pico+ users") | |
| 349 | 343 | } |