refactored notificatoin / tgsettle responsibility boundaries

This commit is contained in:
Stephan D
2026-02-19 18:56:59 +01:00
parent 47f0a3d890
commit 2fd8a6ebb7
73 changed files with 3705 additions and 681 deletions

View File

@@ -26,6 +26,40 @@ func telegramReactionEvent() model.NotificationEvent {
return model.NewNotification(mservice.Notifications, nm.NATelegramReaction)
}
type TelegramTextNotification struct {
messaging.Envelope
payload model.TelegramTextRequest
}
func (ttn *TelegramTextNotification) Serialize() ([]byte, error) {
data, err := json.Marshal(ttn.payload)
if err != nil {
return nil, err
}
return ttn.Envelope.Wrap(data)
}
func telegramTextEvent() model.NotificationEvent {
return model.NewNotification(mservice.Notifications, nm.NATelegramText)
}
type TelegramUpdateNotification struct {
messaging.Envelope
payload model.TelegramWebhookUpdate
}
func (tun *TelegramUpdateNotification) Serialize() ([]byte, error) {
data, err := json.Marshal(tun.payload)
if err != nil {
return nil, err
}
return tun.Envelope.Wrap(data)
}
func telegramUpdateEvent() model.NotificationEvent {
return model.NewNotification(mservice.Notifications, nm.NATelegramUpdate)
}
func NewTelegramReactionEnvelope(sender string, request *model.TelegramReactionRequest) messaging.Envelope {
var payload model.TelegramReactionRequest
if request != nil {
@@ -36,3 +70,25 @@ func NewTelegramReactionEnvelope(sender string, request *model.TelegramReactionR
payload: payload,
}
}
func NewTelegramTextEnvelope(sender string, request *model.TelegramTextRequest) messaging.Envelope {
var payload model.TelegramTextRequest
if request != nil {
payload = *request
}
return &TelegramTextNotification{
Envelope: messaging.CreateEnvelope(sender, telegramTextEvent()),
payload: payload,
}
}
func NewTelegramUpdateEnvelope(sender string, update *model.TelegramWebhookUpdate) messaging.Envelope {
var payload model.TelegramWebhookUpdate
if update != nil {
payload = *update
}
return &TelegramUpdateNotification{
Envelope: messaging.CreateEnvelope(sender, telegramUpdateEvent()),
payload: payload,
}
}