Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions internal/api/icon.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,32 +135,24 @@ func (c *Client) uploadIcon(ctx context.Context, fs afero.Fs, token, appID, icon
var userAgent = fmt.Sprintf("slack-cli/%s (os: %s)", cliVersion, runtime.GOOS)
request.Header.Add("User-Agent", userAgent)

resp, err := c.httpClient.Do(request)
if err != nil {
return IconResult{}, err
}
defer resp.Body.Close()
c.io.PrintDebug(ctx, "HTTP Request: %v %v %v", request.Method, request.URL, request.Proto)
c.io.PrintDebug(ctx, "HTTP Request User-Agent: %s", request.Header.Get("User-Agent"))
c.io.PrintDebug(ctx, "HTTP Request Body: <binary image data, %d bytes>", body.Len())

span.SetTag("status_code", resp.StatusCode)

respBody, err := io.ReadAll(resp.Body)
respBytes, err := c.DoWithRetry(ctx, request, span, false, sURL)
if err != nil {
return IconResult{}, err
}

var result iconResponse
err = json.Unmarshal(respBody, &result)
err = json.Unmarshal(respBytes, &result)
if err != nil {
return IconResult{}, err
}

span.SetTag("ok", result.Ok)

if !result.Ok {
span.SetTag("error", result.Error)
return IconResult{}, fmt.Errorf("%s error: %s", sURL.String(), result.Error)
}

// return result
return IconResult{}, nil
}
3 changes: 0 additions & 3 deletions internal/pkg/apps/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,6 @@ func InstallLocalApp(ctx context.Context, clients *shared.ClientFactory, orgGran
}
}
if iconPath != "" {
clients.IO.PrintDebug(ctx, "uploading icon")
_, iconErr := clients.API().IconSet(ctx, clients.Fs, token, app.AppID, iconPath)
if iconErr != nil {
clients.IO.PrintDebug(ctx, "icon error: %s", iconErr)
Expand Down Expand Up @@ -656,8 +655,6 @@ func updateIcon(ctx context.Context, clients *shared.ClientFactory, iconPath, ap
span, ctx = opentracing.StartSpanFromContext(ctx, "updateIcon")
defer span.Finish()

clients.IO.PrintDebug(ctx, "uploading icon")

var err error
if clients.Config.WithExperimentOn(experiment.SetIcon) {
_, err = clients.API().IconSet(ctx, clients.Fs, token, appID, iconPath)
Expand Down
Loading