merged from gramsrv upstream

This commit is contained in:
onysd 2026-09-01 12:06:31 +03:00
parent 79c64ee916
commit 21a0856587
651 changed files with 54774 additions and 4590 deletions

View file

@ -13,6 +13,25 @@ import (
"telesrv/internal/domain"
)
func (s *PasswordStore) HasBusinessAutomation(ctx context.Context, userID int64) (bool, error) {
var exists bool
err := s.db.QueryRow(ctx, `
SELECT EXISTS (
SELECT 1
FROM user_business_profiles
WHERE user_id = $1
AND (greeting_message <> '{}'::jsonb OR away_message <> '{}'::jsonb)
UNION ALL
SELECT 1
FROM business_connected_bots
WHERE owner_user_id = $1
)`, userID).Scan(&exists)
if err != nil {
return false, fmt.Errorf("check business automation: %w", err)
}
return exists, nil
}
func (s *PasswordStore) GetBusinessProfile(ctx context.Context, userID int64) (domain.BusinessProfile, bool, error) {
row := s.db.QueryRow(ctx, `
SELECT