MCPcopy Create free account
hub / github.com/bytebase/bytebase / getChatIDForUser

Method getChatIDForUser

backend/plugin/webhook/teams/app.go:351–365  ·  view source on GitHub ↗

getChatIDForUser gets the chat ID for a user's app installation.

(ctx context.Context, userAADID, installationID string)

Source from the content-addressed store, hash-verified

349
350// getChatIDForUser gets the chat ID for a user's app installation.
351func (p *provider) getChatIDForUser(ctx context.Context, userAADID, installationID string) (string, error) {
352 apiURL := fmt.Sprintf("https://graph.microsoft.com/v1.0/users/%s/teamwork/installedApps/%s/chat", userAADID, installationID)
353
354 b, err := p.doGraphRequest(ctx, http.MethodGet, apiURL, nil)
355 if err != nil {
356 return "", errors.Wrapf(err, "failed to get chat for installation")
357 }
358
359 var resp chatResponse
360 if err := json.Unmarshal(b, &resp); err != nil {
361 return "", errors.Wrapf(err, "failed to unmarshal chat response")
362 }
363
364 return resp.ID, nil
365}
366
367func (p *provider) doGraphRequest(ctx context.Context, method, apiURL string, data []byte) ([]byte, error) {
368 const maxRetries = 3

Callers 1

sendMessageMethod · 0.95

Calls 2

doGraphRequestMethod · 0.95
UnmarshalMethod · 0.80

Tested by

no test coverage detected