54 lines
989 B
Go
54 lines
989 B
Go
package mattermost
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
)
|
|
|
|
type Config struct {
|
|
BaseURL string
|
|
Token string
|
|
}
|
|
|
|
type Client struct {
|
|
cfg Config
|
|
logger *slog.Logger
|
|
}
|
|
|
|
type MessageInput struct {
|
|
ChannelID string
|
|
Text string
|
|
}
|
|
|
|
type TaskNotificationInput struct {
|
|
TaskID string
|
|
Title string
|
|
Status string
|
|
Message string
|
|
}
|
|
|
|
func NewClient(cfg Config, logger *slog.Logger) *Client {
|
|
return &Client{cfg: cfg, logger: logger}
|
|
}
|
|
|
|
func (c *Client) SendMessage(ctx context.Context, input MessageInput) error {
|
|
_ = ctx
|
|
if c.logger != nil {
|
|
c.logger.Info("mattermost send message skipped", "channel_id", input.ChannelID, "text", input.Text)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (c *Client) SendTaskNotification(ctx context.Context, input TaskNotificationInput) error {
|
|
_ = ctx
|
|
if c.logger != nil {
|
|
c.logger.Info(
|
|
"mattermost task notification skipped",
|
|
"task_id", input.TaskID,
|
|
"title", input.Title,
|
|
"status", input.Status,
|
|
"message", input.Message,
|
|
)
|
|
}
|
|
return nil
|
|
}
|