feat: sync admin stars grant support

This commit is contained in:
A 2026-07-08 02:30:01 +08:00
parent 23fa1cad21
commit e0cabb4930
14 changed files with 286 additions and 11 deletions

View file

@ -3,6 +3,8 @@ package rpc
import (
"context"
"github.com/gotd/td/tg"
"telesrv/internal/domain"
)
@ -31,3 +33,16 @@ func (r *Router) NotifyChannelChanged(ctx context.Context, ch domain.Channel) er
r.channelStateMutationUpdates(ctx, ch.CreatorUserID, ch)
return nil
}
// NotifyStarsBalanceChanged is the domain-only hook used by the internal Admin
// API after the local Stars ledger balance has changed outside a client RPC.
func (r *Router) NotifyStarsBalanceChanged(ctx context.Context, balance domain.StarsBalance) error {
if r == nil || balance.UserID == 0 {
return nil
}
r.pushUserUpdates(ctx, balance.UserID, &tg.Updates{
Updates: []tg.UpdateClass{&tg.UpdateStarsBalance{Balance: &tg.StarsAmount{Amount: balance.Balance}}},
Date: int(r.clock.Now().Unix()),
})
return nil
}