| 1 |
|
package service |
| 2 |
|
|
| 3 |
|
import ( |
| 4 |
|
"context" |
| 5 |
|
"fmt" |
| 6 |
|
) |
| 7 |
|
|
| 8 |
|
// EnsureOwnerUser seeds the owner's user row (username = the configured |
| 9 |
|
// owner-name) and caches its id for the webhook auth bridge. Call once at |
| 10 |
|
// startup. |
| 11 |
0 |
func (s *Service) EnsureOwnerUser(ctx context.Context) error { |
| 12 |
0 |
id, err := s.store.EnsureUser(ctx, s.cfg.Instance.OwnerName) |
| 13 |
0 |
if err != nil { |
| 14 |
0 |
return fmt.Errorf("service: ensure owner user: %w", err) |
| 15 |
0 |
} |
| 16 |
0 |
s.ownerUserID = id |
| 17 |
0 |
return nil |
| 18 |
|
} |
| 19 |
|
|
| 20 |
|
// OwnerUserID is the owner user row id, 0 until EnsureOwnerUser has run. |
| 21 |
0 |
func (s *Service) OwnerUserID() int { return s.ownerUserID } |