Skip to content

Commit d05fba6

Browse files
Michael McNeesclaude
authored andcommitted
fix(connector): remove unused ElasticsearchSearch.apiURL, pass Client through discordPostMessage
Fixes lint: func (*ElasticsearchSearchConnector).apiURL is unused. Addresses Codex feedback: discordPostMessage now receives the connector's http.Client instead of always using the default client. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9d2f418 commit d05fba6

2 files changed

Lines changed: 4 additions & 11 deletions

File tree

packages/engine/internal/connector/discord.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (c *DiscordSendConnector) Execute(ctx context.Context, params map[string]an
4646
body["tts"] = tts
4747
}
4848

49-
return discordPostMessage(ctx, c.apiURL(fmt.Sprintf("/channels/%s/messages", url.PathEscape(channelID))), token, body, "discord/send")
49+
return discordPostMessage(ctx, c.Client, c.apiURL(fmt.Sprintf("/channels/%s/messages", url.PathEscape(channelID))), token, body, "discord/send")
5050
}
5151

5252
// DiscordEmbedConnector sends an embed message to a Discord channel.
@@ -99,10 +99,10 @@ func (c *DiscordEmbedConnector) Execute(ctx context.Context, params map[string]a
9999
body["content"] = content
100100
}
101101

102-
return discordPostMessage(ctx, c.apiURL(fmt.Sprintf("/channels/%s/messages", url.PathEscape(channelID))), token, body, "discord/embed")
102+
return discordPostMessage(ctx, c.Client, c.apiURL(fmt.Sprintf("/channels/%s/messages", url.PathEscape(channelID))), token, body, "discord/embed")
103103
}
104104

105-
func discordPostMessage(ctx context.Context, endpoint, token string, body map[string]any, action string) (map[string]any, error) {
105+
func discordPostMessage(ctx context.Context, client *http.Client, endpoint, token string, body map[string]any, action string) (map[string]any, error) {
106106
reqJSON, err := json.Marshal(body)
107107
if err != nil {
108108
return nil, fmt.Errorf("%s: marshaling request: %w", action, err)
@@ -115,7 +115,7 @@ func discordPostMessage(ctx context.Context, endpoint, token string, body map[st
115115
req.Header.Set("Authorization", "Bot "+token)
116116
req.Header.Set("Content-Type", "application/json")
117117

118-
resp, err := httpClient(nil).Do(req)
118+
resp, err := httpClient(client).Do(req)
119119
if err != nil {
120120
return nil, fmt.Errorf("%s: %w", action, err)
121121
}

packages/engine/internal/connector/elasticsearch.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,6 @@ type ElasticsearchSearchConnector struct {
1616
baseURL string // override for testing
1717
}
1818

19-
func (c *ElasticsearchSearchConnector) apiURL(base, path string) string {
20-
if base == "" {
21-
base = c.baseURL
22-
}
23-
return base + path
24-
}
25-
2619
func (c *ElasticsearchSearchConnector) Execute(ctx context.Context, params map[string]any) (map[string]any, error) {
2720
baseURL, auth, err := extractElasticsearchCredential(params)
2821
if err != nil {

0 commit comments

Comments
 (0)