TG settlement service

This commit is contained in:
Stephan D
2026-01-02 14:54:18 +01:00
parent ea1c69f14a
commit 743f683d92
82 changed files with 4693 additions and 503 deletions

View File

@@ -0,0 +1,30 @@
package notificationimp
import (
"encoding/json"
"io"
"net/http"
"github.com/tech/sendico/notification/internal/server/notificationimp/telegram"
"go.uber.org/zap"
)
const telegramWebhookMaxBody = 1 << 20
func (a *NotificationAPI) handleTelegramWebhook(w http.ResponseWriter, r *http.Request) {
if a == nil || a.confirm == nil {
w.WriteHeader(http.StatusNoContent)
return
}
var update telegram.Update
dec := json.NewDecoder(io.LimitReader(r.Body, telegramWebhookMaxBody))
if err := dec.Decode(&update); err != nil {
if a.logger != nil {
a.logger.Warn("Failed to decode telegram webhook update", zap.Error(err))
}
w.WriteHeader(http.StatusBadRequest)
return
}
a.confirm.HandleUpdate(r.Context(), &update)
w.WriteHeader(http.StatusOK)
}