39 lines
1000 B
Go
39 lines
1000 B
Go
package notifications
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
messaging "github.com/tech/sendico/pkg/messaging/envelope"
|
|
"github.com/tech/sendico/pkg/model"
|
|
nm "github.com/tech/sendico/pkg/model/notification"
|
|
"github.com/tech/sendico/pkg/mservice"
|
|
)
|
|
|
|
type TelegramReactionNotification struct {
|
|
messaging.Envelope
|
|
payload model.TelegramReactionRequest
|
|
}
|
|
|
|
func (trn *TelegramReactionNotification) Serialize() ([]byte, error) {
|
|
data, err := json.Marshal(trn.payload)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return trn.Envelope.Wrap(data)
|
|
}
|
|
|
|
func telegramReactionEvent() model.NotificationEvent {
|
|
return model.NewNotification(mservice.Notifications, nm.NATelegramReaction)
|
|
}
|
|
|
|
func NewTelegramReactionEnvelope(sender string, request *model.TelegramReactionRequest) messaging.Envelope {
|
|
var payload model.TelegramReactionRequest
|
|
if request != nil {
|
|
payload = *request
|
|
}
|
|
return &TelegramReactionNotification{
|
|
Envelope: messaging.CreateEnvelope(sender, telegramReactionEvent()),
|
|
payload: payload,
|
|
}
|
|
}
|