cf66ed7e26
Tests · Go / test (push) Successful in 7s
Tests · Integration / integration (push) Successful in 12s
Tests · Go / test (pull_request) Successful in 6s
Tests · Integration / integration (pull_request) Successful in 11s
Tests · UI / test (pull_request) Successful in 19s
New platform/telegram connector (own container, bot token only there): - go-telegram/bot long-poll loop: /start deep-links + Mini App launch button. - gRPC API pkg/proto/telegram/v1 (Telegram service): ValidateInitData, Notify (renders a localized message + deep-link button), SendToUser/SendToGameChannel (admin, wired in Stage 10). Generic methods are platform-agnostic (external_id). - Bot API base override for Telegram's test environment; Dockerfile + compose (VPN sidecar, no public ingress); README. Gateway: - initData validation relocated from the gateway into the connector; the gateway calls ValidateInitData over gRPC (GATEWAY_CONNECTOR_ADDR), drops the bot token, and deletes internal/auth. - Out-of-app push: runPushPump routes events whose recipient has no live in-app stream to connector.Notify, gated by /internal/push-target + the in-app-only flag (race-free de-dup); HasSubscribers added to the push hub. Backend: - Migration 00007 accounts.notifications_in_app_only (default true) + jetgen. - ProvisionTelegram seeds a new account's language/display name from the launch fields; IdentityExternalID reverse lookup; /internal/push-target handler. UI: - Telegram Mini App launch: detect initData, apply themeParams, authTelegram, route the deep-link start_param (g/i/f); /telegram/ guard redirects outside Telegram. Vite relative base + telegram-web-app.js. In-app-only profile toggle; share-to-Telegram link for a friend code. Vitest + Playwright coverage. Wire/docs/CI: fbs Profile/UpdateProfileRequest gain notifications_in_app_only (Go + TS); go.work uses ./platform/telegram; go-unit.yaml covers it; PLAN, ARCHITECTURE, FUNCTIONAL (+ru), UI_DESIGN, READMEs updated.
277 lines
12 KiB
Go
277 lines
12 KiB
Go
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
|
// versions:
|
|
// - protoc-gen-go-grpc v1.5.1
|
|
// - protoc (unknown)
|
|
// source: telegram/v1/telegram.proto
|
|
|
|
// Package scrabble.telegram.v1 is the RPC contract of the Telegram platform
|
|
// side-service (the "connector"). The connector holds the bot token and is the
|
|
// only component that talks to the Telegram Bot API; gateway and backend reach it
|
|
// over plain gRPC on the trusted internal network (ARCHITECTURE.md §1, §12).
|
|
//
|
|
// The generic delivery methods (Notify, SendToUser, SendToGameChannel) are
|
|
// platform-agnostic: they address a recipient by the identity external_id (as in
|
|
// the backend identities table), so a future VK / MAX connector can implement the
|
|
// same service. ValidateInitData is the one Telegram-specific method (it parses
|
|
// Telegram Web App launch data); it is kept here for now.
|
|
|
|
package telegramv1
|
|
|
|
import (
|
|
context "context"
|
|
grpc "google.golang.org/grpc"
|
|
codes "google.golang.org/grpc/codes"
|
|
status "google.golang.org/grpc/status"
|
|
)
|
|
|
|
// This is a compile-time assertion to ensure that this generated file
|
|
// is compatible with the grpc package it is being compiled against.
|
|
// Requires gRPC-Go v1.64.0 or later.
|
|
const _ = grpc.SupportPackageIsVersion9
|
|
|
|
const (
|
|
Telegram_ValidateInitData_FullMethodName = "/scrabble.telegram.v1.Telegram/ValidateInitData"
|
|
Telegram_Notify_FullMethodName = "/scrabble.telegram.v1.Telegram/Notify"
|
|
Telegram_SendToUser_FullMethodName = "/scrabble.telegram.v1.Telegram/SendToUser"
|
|
Telegram_SendToGameChannel_FullMethodName = "/scrabble.telegram.v1.Telegram/SendToGameChannel"
|
|
)
|
|
|
|
// TelegramClient is the client API for Telegram service.
|
|
//
|
|
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
|
//
|
|
// Telegram is the connector RPC surface.
|
|
type TelegramClient interface {
|
|
// ValidateInitData verifies Telegram Mini App launch data (HMAC) and returns
|
|
// the authenticated user. The gateway calls it during the auth.telegram edge
|
|
// operation, then provisions the session through the backend internal API.
|
|
ValidateInitData(ctx context.Context, in *ValidateInitDataRequest, opts ...grpc.CallOption) (*ValidateInitDataResponse, error)
|
|
// Notify delivers an out-of-app notification for a backend push event. The
|
|
// gateway calls it only for a recipient with no live in-app stream (so the
|
|
// platform push never duplicates in-app delivery). The connector renders a
|
|
// localized message with a Mini App deep-link button from the FlatBuffers
|
|
// payload; unrenderable kinds are skipped (delivered=false).
|
|
Notify(ctx context.Context, in *NotifyRequest, opts ...grpc.CallOption) (*NotifyResponse, error)
|
|
// SendToUser sends an arbitrary text message to one user (admin use, wired in
|
|
// Stage 10). delivered is false when the user has not started the bot.
|
|
SendToUser(ctx context.Context, in *SendToUserRequest, opts ...grpc.CallOption) (*SendResponse, error)
|
|
// SendToGameChannel posts an arbitrary text message to the bot's configured
|
|
// game channel (admin use, wired in Stage 10); the channel id lives only in the
|
|
// connector configuration.
|
|
SendToGameChannel(ctx context.Context, in *SendToGameChannelRequest, opts ...grpc.CallOption) (*SendResponse, error)
|
|
}
|
|
|
|
type telegramClient struct {
|
|
cc grpc.ClientConnInterface
|
|
}
|
|
|
|
func NewTelegramClient(cc grpc.ClientConnInterface) TelegramClient {
|
|
return &telegramClient{cc}
|
|
}
|
|
|
|
func (c *telegramClient) ValidateInitData(ctx context.Context, in *ValidateInitDataRequest, opts ...grpc.CallOption) (*ValidateInitDataResponse, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(ValidateInitDataResponse)
|
|
err := c.cc.Invoke(ctx, Telegram_ValidateInitData_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *telegramClient) Notify(ctx context.Context, in *NotifyRequest, opts ...grpc.CallOption) (*NotifyResponse, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(NotifyResponse)
|
|
err := c.cc.Invoke(ctx, Telegram_Notify_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *telegramClient) SendToUser(ctx context.Context, in *SendToUserRequest, opts ...grpc.CallOption) (*SendResponse, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(SendResponse)
|
|
err := c.cc.Invoke(ctx, Telegram_SendToUser_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (c *telegramClient) SendToGameChannel(ctx context.Context, in *SendToGameChannelRequest, opts ...grpc.CallOption) (*SendResponse, error) {
|
|
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
|
|
out := new(SendResponse)
|
|
err := c.cc.Invoke(ctx, Telegram_SendToGameChannel_FullMethodName, in, out, cOpts...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
// TelegramServer is the server API for Telegram service.
|
|
// All implementations must embed UnimplementedTelegramServer
|
|
// for forward compatibility.
|
|
//
|
|
// Telegram is the connector RPC surface.
|
|
type TelegramServer interface {
|
|
// ValidateInitData verifies Telegram Mini App launch data (HMAC) and returns
|
|
// the authenticated user. The gateway calls it during the auth.telegram edge
|
|
// operation, then provisions the session through the backend internal API.
|
|
ValidateInitData(context.Context, *ValidateInitDataRequest) (*ValidateInitDataResponse, error)
|
|
// Notify delivers an out-of-app notification for a backend push event. The
|
|
// gateway calls it only for a recipient with no live in-app stream (so the
|
|
// platform push never duplicates in-app delivery). The connector renders a
|
|
// localized message with a Mini App deep-link button from the FlatBuffers
|
|
// payload; unrenderable kinds are skipped (delivered=false).
|
|
Notify(context.Context, *NotifyRequest) (*NotifyResponse, error)
|
|
// SendToUser sends an arbitrary text message to one user (admin use, wired in
|
|
// Stage 10). delivered is false when the user has not started the bot.
|
|
SendToUser(context.Context, *SendToUserRequest) (*SendResponse, error)
|
|
// SendToGameChannel posts an arbitrary text message to the bot's configured
|
|
// game channel (admin use, wired in Stage 10); the channel id lives only in the
|
|
// connector configuration.
|
|
SendToGameChannel(context.Context, *SendToGameChannelRequest) (*SendResponse, error)
|
|
mustEmbedUnimplementedTelegramServer()
|
|
}
|
|
|
|
// UnimplementedTelegramServer must be embedded to have
|
|
// forward compatible implementations.
|
|
//
|
|
// NOTE: this should be embedded by value instead of pointer to avoid a nil
|
|
// pointer dereference when methods are called.
|
|
type UnimplementedTelegramServer struct{}
|
|
|
|
func (UnimplementedTelegramServer) ValidateInitData(context.Context, *ValidateInitDataRequest) (*ValidateInitDataResponse, error) {
|
|
return nil, status.Errorf(codes.Unimplemented, "method ValidateInitData not implemented")
|
|
}
|
|
func (UnimplementedTelegramServer) Notify(context.Context, *NotifyRequest) (*NotifyResponse, error) {
|
|
return nil, status.Errorf(codes.Unimplemented, "method Notify not implemented")
|
|
}
|
|
func (UnimplementedTelegramServer) SendToUser(context.Context, *SendToUserRequest) (*SendResponse, error) {
|
|
return nil, status.Errorf(codes.Unimplemented, "method SendToUser not implemented")
|
|
}
|
|
func (UnimplementedTelegramServer) SendToGameChannel(context.Context, *SendToGameChannelRequest) (*SendResponse, error) {
|
|
return nil, status.Errorf(codes.Unimplemented, "method SendToGameChannel not implemented")
|
|
}
|
|
func (UnimplementedTelegramServer) mustEmbedUnimplementedTelegramServer() {}
|
|
func (UnimplementedTelegramServer) testEmbeddedByValue() {}
|
|
|
|
// UnsafeTelegramServer may be embedded to opt out of forward compatibility for this service.
|
|
// Use of this interface is not recommended, as added methods to TelegramServer will
|
|
// result in compilation errors.
|
|
type UnsafeTelegramServer interface {
|
|
mustEmbedUnimplementedTelegramServer()
|
|
}
|
|
|
|
func RegisterTelegramServer(s grpc.ServiceRegistrar, srv TelegramServer) {
|
|
// If the following call pancis, it indicates UnimplementedTelegramServer was
|
|
// embedded by pointer and is nil. This will cause panics if an
|
|
// unimplemented method is ever invoked, so we test this at initialization
|
|
// time to prevent it from happening at runtime later due to I/O.
|
|
if t, ok := srv.(interface{ testEmbeddedByValue() }); ok {
|
|
t.testEmbeddedByValue()
|
|
}
|
|
s.RegisterService(&Telegram_ServiceDesc, srv)
|
|
}
|
|
|
|
func _Telegram_ValidateInitData_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(ValidateInitDataRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(TelegramServer).ValidateInitData(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: Telegram_ValidateInitData_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(TelegramServer).ValidateInitData(ctx, req.(*ValidateInitDataRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
func _Telegram_Notify_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(NotifyRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(TelegramServer).Notify(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: Telegram_Notify_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(TelegramServer).Notify(ctx, req.(*NotifyRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
func _Telegram_SendToUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(SendToUserRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(TelegramServer).SendToUser(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: Telegram_SendToUser_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(TelegramServer).SendToUser(ctx, req.(*SendToUserRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
func _Telegram_SendToGameChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
|
in := new(SendToGameChannelRequest)
|
|
if err := dec(in); err != nil {
|
|
return nil, err
|
|
}
|
|
if interceptor == nil {
|
|
return srv.(TelegramServer).SendToGameChannel(ctx, in)
|
|
}
|
|
info := &grpc.UnaryServerInfo{
|
|
Server: srv,
|
|
FullMethod: Telegram_SendToGameChannel_FullMethodName,
|
|
}
|
|
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
|
return srv.(TelegramServer).SendToGameChannel(ctx, req.(*SendToGameChannelRequest))
|
|
}
|
|
return interceptor(ctx, in, info, handler)
|
|
}
|
|
|
|
// Telegram_ServiceDesc is the grpc.ServiceDesc for Telegram service.
|
|
// It's only intended for direct use with grpc.RegisterService,
|
|
// and not to be introspected or modified (even as a copy)
|
|
var Telegram_ServiceDesc = grpc.ServiceDesc{
|
|
ServiceName: "scrabble.telegram.v1.Telegram",
|
|
HandlerType: (*TelegramServer)(nil),
|
|
Methods: []grpc.MethodDesc{
|
|
{
|
|
MethodName: "ValidateInitData",
|
|
Handler: _Telegram_ValidateInitData_Handler,
|
|
},
|
|
{
|
|
MethodName: "Notify",
|
|
Handler: _Telegram_Notify_Handler,
|
|
},
|
|
{
|
|
MethodName: "SendToUser",
|
|
Handler: _Telegram_SendToUser_Handler,
|
|
},
|
|
{
|
|
MethodName: "SendToGameChannel",
|
|
Handler: _Telegram_SendToGameChannel_Handler,
|
|
},
|
|
},
|
|
Streams: []grpc.StreamDesc{},
|
|
Metadata: "telegram/v1/telegram.proto",
|
|
}
|