Adopt upstream owpengram/owpengram-server's branding.Config/Configure/ Current in place of the old package-level constants. This is the piece the earlier merge attempt was blocked on (internal/branding failed to import during that merge). The default identity is unchanged -- every existing ProductName/ProductUsername/... default still reads "OwpenGram" -- so this is a pure capability add: nothing currently calls Configure, and every call site now reads the current snapshot via a function instead of a compile-time constant. Five string templates that concatenated branding.ProductName into a `const` had to become `var`, since a func call is no longer a valid const operand. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
55 lines
2.1 KiB
Go
55 lines
2.1 KiB
Go
package botverification
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"fmt"
|
|
|
|
"telesrv/internal/branding"
|
|
"telesrv/internal/domain"
|
|
)
|
|
|
|
// SeedDefaultVerifier idempotently grants @marksbot (domain.VerifierBotUserID)
|
|
// verifier status on first boot, using a custom-emoji icon the ordinary
|
|
// sticker-seed import already writes (domain.VerifierBotDefaultIconDocumentID)
|
|
// -- so the reference third-party verifier has something to demonstrate right
|
|
// away instead of an empty icon catalogue and a bot that can only explain
|
|
// itself.
|
|
//
|
|
// Runs at most once: if a bot_verifier_settings row for @marksbot already
|
|
// exists -- granted by this seed on a previous boot, or hand-configured by an
|
|
// operator who pointed it at a different icon/company -- it is left
|
|
// completely untouched. This must never overwrite an operator's own decision
|
|
// about their own verifier.
|
|
// Returns true if it actually granted verifier status.
|
|
func (s *Service) SeedDefaultVerifier(ctx context.Context) (bool, error) {
|
|
if s == nil || !s.enabled {
|
|
return false, nil
|
|
}
|
|
if _, err := s.VerifierSettings(ctx, domain.VerifierBotUserID); err == nil {
|
|
return false, nil
|
|
} else if !errors.Is(err, domain.ErrVerifierNotFound) {
|
|
return false, err
|
|
}
|
|
icon, err := s.UpsertIcon(ctx, domain.VerificationIcon{
|
|
DocumentID: domain.VerifierBotDefaultIconDocumentID,
|
|
Name: "Default (bundled)",
|
|
Active: true,
|
|
})
|
|
if err != nil {
|
|
return false, fmt.Errorf("seed default verifier icon: %w", err)
|
|
}
|
|
if _, err := s.GrantVerifier(ctx, domain.BotVerifierSettings{
|
|
BotID: domain.VerifierBotUserID,
|
|
IconDocumentID: icon.DocumentID,
|
|
CompanyName: branding.ProductName(),
|
|
DefaultDescription: "Bundled reference verifier -- auto-granted on first boot.",
|
|
CanModifyCustomDescription: false,
|
|
Enabled: true,
|
|
GrantedBy: "startup-seed",
|
|
GrantReason: "Reference verifier auto-granted on first boot so third-party verification has something to demonstrate out of the box.",
|
|
}); err != nil {
|
|
return false, fmt.Errorf("seed default verifier grant: %w", err)
|
|
}
|
|
return true, nil
|
|
}
|