| 321 | const DefaultMaxWebhooks = 50 |
| 322 | |
| 323 | func (s *Store) MaxWebhooksForUser(ctx context.Context, userID string) (int, error) { |
| 324 | var n *int |
| 325 | err := s.pool.QueryRow(ctx, |
| 326 | `SELECT max_webhooks FROM account_limits WHERE user_id = $1`, userID, |
| 327 | ).Scan(&n) |
| 328 | if err != nil { |
| 329 | if errors.Is(err, pgx.ErrNoRows) { |
| 330 | return DefaultMaxWebhooks, nil |
| 331 | } |
| 332 | return 0, err |
| 333 | } |
| 334 | if n == nil { |
| 335 | return DefaultMaxWebhooks, nil |
| 336 | } |
| 337 | return *n, nil |
| 338 | } |
| 339 | |
| 340 | // WebhookUpdate carries the fields a PATCH can change. All fields are |
| 341 | // pointers (or "set-or-leave" flags) so handlers can distinguish |