feat: add user-agent http header for thirdparty sdks

This commit is contained in:
Fu Diwei
2025-05-28 10:46:02 +08:00
parent ddb46f9dda
commit 829fa29cf1
30 changed files with 66 additions and 43 deletions

View File

@@ -52,8 +52,9 @@ func (n *NotifierProvider) Notify(ctx context.Context, subject string, message s
// REF: https://discord.com/developers/docs/resources/message#create-message
req := n.httpClient.R().
SetContext(ctx).
SetHeader("Content-Type", "application/json").
SetHeader("Authorization", "Bot "+n.config.BotToken).
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetBody(map[string]any{
"content": subject + "\n" + message,
})

View File

@@ -57,8 +57,9 @@ func (n *NotifierProvider) Notify(ctx context.Context, subject string, message s
// REF: https://gotify.net/api-docs#/message/createMessage
req := n.httpClient.R().
SetContext(ctx).
SetHeader("Content-Type", "application/json").
SetHeader("Authorization", "Bearer "+n.config.Token).
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetBody(map[string]any{
"title": subject,
"message": message,

View File

@@ -60,6 +60,7 @@ func (n *NotifierProvider) Notify(ctx context.Context, subject string, message s
loginReq := n.httpClient.R().
SetContext(ctx).
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetBody(map[string]any{
"login_id": n.config.Username,
"password": n.config.Password,
@@ -76,8 +77,9 @@ func (n *NotifierProvider) Notify(ctx context.Context, subject string, message s
// REF: https://developers.mattermost.com/api-documentation/#/operations/CreatePost
postReq := n.httpClient.R().
SetContext(ctx).
SetHeader("Content-Type", "application/json").
SetHeader("Authorization", "Bearer "+loginResp.Header().Get("Token")).
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetBody(map[string]any{
"channel_id": n.config.ChannelId,
"props": map[string]interface{}{

View File

@@ -53,6 +53,7 @@ func (n *NotifierProvider) Notify(ctx context.Context, subject string, message s
req := n.httpClient.R().
SetContext(ctx).
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetBody(map[string]any{
"title": subject,
"message": message,

View File

@@ -52,6 +52,7 @@ func (n *NotifierProvider) Notify(ctx context.Context, subject string, message s
req := n.httpClient.R().
SetContext(ctx).
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetBody(map[string]any{
"title": subject,
"content": message,

View File

@@ -51,6 +51,7 @@ func (n *NotifierProvider) Notify(ctx context.Context, subject string, message s
req := n.httpClient.R().
SetContext(ctx).
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetBody(map[string]any{
"text": subject,
"desp": message,

View File

@@ -52,8 +52,9 @@ func (n *NotifierProvider) Notify(ctx context.Context, subject string, message s
// REF: https://docs.slack.dev/messaging/sending-and-scheduling-messages#publishing
req := n.httpClient.R().
SetContext(ctx).
SetHeader("Content-Type", "application/json").
SetHeader("Authorization", "Bearer "+n.config.BotToken).
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetBody(map[string]any{
"token": n.config.BotToken,
"channel": n.config.ChannelId,

View File

@@ -53,6 +53,7 @@ func (n *NotifierProvider) Notify(ctx context.Context, subject string, message s
req := n.httpClient.R().
SetContext(ctx).
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetBody(map[string]any{
"chat_id": n.config.ChatId,
"text": subject + "\n" + message,

View File

@@ -51,6 +51,7 @@ func (n *NotifierProvider) Notify(ctx context.Context, subject string, message s
req := n.httpClient.R().
SetContext(ctx).
SetHeader("Content-Type", "application/json").
SetHeader("User-Agent", "certimate").
SetBody(map[string]any{
"msgtype": "text",
"text": map[string]string{