Phase 14, part 1: plans, each team's account, and their limits
The multi-tenant edition's plans (Free and Paid as decided, or a plans file) and each team's billing account, with a 14-day trial of Paid. A team's plan caps what its people and agents may change: modules outside it stay readable, a lapsed team changes nothing, and agents, Market entries, crawls and background jobs keep to it. Without a Stripe key, no billing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -86,7 +86,11 @@ func (s *Server) inventorySave(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
e := entryFromForm(r)
|
||||
if err := inventory.Save(s.DB, e); err != nil {
|
||||
err := s.marketRoom(e)
|
||||
if err == nil {
|
||||
err = inventory.Save(s.DB, e)
|
||||
}
|
||||
if err != nil {
|
||||
title := e.Name
|
||||
if title == "" {
|
||||
title = "New entry"
|
||||
@@ -296,3 +300,20 @@ func (s *Server) subredditCheck(ctx context.Context) inventory.SubredditCheck {
|
||||
return info, nil
|
||||
}
|
||||
}
|
||||
|
||||
// marketRoom says why a new entry can't be added (the plan's limit), or nil.
|
||||
func (s *Server) marketRoom(e *inventory.Entry) error {
|
||||
if e.ID != 0 {
|
||||
return nil
|
||||
}
|
||||
list, err := inventory.List(s.DB, "")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, x := range list {
|
||||
if strings.EqualFold(x.Name, strings.TrimSpace(e.Name)) {
|
||||
return nil // the same name: Save says so
|
||||
}
|
||||
}
|
||||
return s.limitSources(len(list))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user