feat(server/reward): TG 绑定 token 签发/消费 + GET /v1/tasks/telegram/start
This commit is contained in:
@@ -5,7 +5,10 @@ import (
|
||||
"crypto/rand"
|
||||
"database/sql"
|
||||
"log/slog"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
||||
type Granter interface {
|
||||
@@ -20,6 +23,11 @@ type Service struct {
|
||||
g Granter
|
||||
cfg Config
|
||||
now func() time.Time
|
||||
|
||||
rdb *redis.Client
|
||||
tg tgConfig
|
||||
memMu sync.Mutex
|
||||
memTok map[string]int64
|
||||
}
|
||||
|
||||
func NewService(db *sql.DB, st *Store, g Granter, cfg Config, now func() time.Time) *Service {
|
||||
@@ -134,3 +142,8 @@ func (s *Service) OnFirstPaidTx(ctx context.Context, tx *sql.Tx, inviteeID int64
|
||||
}
|
||||
return s.st.MarkPaidRewardedTx(ctx, tx, inviteeID, now)
|
||||
}
|
||||
|
||||
// TelegramDeepLink 拼 t.me 深链,携带绑定 token。
|
||||
func (s *Service) TelegramDeepLink(tok string) string {
|
||||
return "https://t.me/" + s.tg.botUser + "?start=" + tok
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user