getChatIDForUser gets the chat ID for a user's app installation.
(ctx context.Context, userAADID, installationID string)
| 349 | |
| 350 | // getChatIDForUser gets the chat ID for a user's app installation. |
| 351 | func (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 | |
| 367 | func (p *provider) doGraphRequest(ctx context.Context, method, apiURL string, data []byte) ([]byte, error) { |
| 368 | const maxRetries = 3 |
no test coverage detected