OfficeDev / microsoft-teams-library-js

JavaScript library for use by Microsoft Teams apps
https://docs.microsoft.com/microsoftteams/platform/
Other
430 stars 199 forks source link

Teams app context returning channel instead of chat info for direct chats on Android #2003

Open seanmc86 opened 1 year ago

seanmc86 commented 1 year ago

Using the latest versions of microsoft/teams-js SDK (2.16.0), microsoft-graph-client (3.0.7) and the Teams app (1416/1.0.0.2023183501/1009), the following code is used to get app context:

import * as microsoftTeams from "@microsoft/teams-js";
microsoftTeams.app.getContext()

This has been working on all platforms for some time, but now returns the incorrect payload on Android devices (for comparison, it works just fine on desktop & iOS)

For a direct (one-on-one) chat, we would expect "chats" data to be contained in the response. However, the response instead contains "channel" data on Android. And in this data, the team.internalId equals the channel.id, with no other IDs present related to the channel or team. When querying the MS graph endpoint "/teams/{id}/channels/{channel_id}" using these IDs, we get the error "teamId needs to be a valid GUID" which makes sense because this isn't actually in a team.

Without the "chats" data it is impossible to get info on this chat at the regular "/chats/{id}" endpoint. (this does not work when using the channel.id in its place, obviously)

Sample from Android context:

"app": {
    "locale": "en-gb",
    "sessionId": "<hidden>",
    "theme": "dark",
    "parentMessageId": "",
    "userClickTime": 1698063884300,
    "host": {
      "name": "Teams",
      "clientType": "android",
      "sessionId": "<hidden>",
      "ringId": "general"
    },
  },
"page": {
  "id": "",
  "frameContext": "settings",
  "subPageId": "",
  "isFullScreen": false,
  "sourceOrigin": "TEAMS-ANDROID..settings"
},
"user": [redacted],
"channel": {
  "id": "[redacted]@unq.gbl.spaces",
  "displayName": "General",
  "relativeUrl": "",
  "membershipType": "",
  "ownerGroupId": "",
  "ownerTenantId": ""
},
"meeting": {
  "id": [redacted]
},
"team": {
  "internalId": "[redacted]@unq.gbl.spaces",
  "displayName": "",
  "type": 0,
  "groupId": "",
  "isArchived": false,
  "userRole": 0
}

Snippet of missing data in working context on other platforms:

 "page": {
    "id": [redacted],
    "frameContext": "content",
    "subPageId": [redacted],
    "isFullScreen": false,
    "isMultiWindow": false,
    "sourceOrigin": null
  },
  "chat": {
    "id": "[redacted]@unq.gbl.spaces"
  }
nwojod-MSFT commented 1 year ago

Hi @seanmc86 thank you for reporting this issue, and apologies for any inconvenience this may have caused. We will investigate this on our end and get back to you. Thanks

Nivedipa-MSFT commented 1 year ago

@seanmc86 - Thanks for reporting your issue. We have tested this using TeamsJS version 2.16.0, Android Teams version 1416/1.0.0.2023183501/1009, and Android version 12. We were able to obtain the chat ID for direct chats on Android.

image

Could you please test this again and confirm once?

seanmc86 commented 1 year ago

I can still reproduce the error for all direct and group chats. Note that the issue occurs when installing this tab for the first time in these chats. It's the same every time:

Teams 1416/1.0.0.2023183501/1009, teams-js 2.16.0

seanmc86 commented 1 year ago

Please see my latest feedback @Nivedipa-MSFT

ChetanSharma-msft commented 1 year ago

@seanmc86 - We are able to repro that issue, we have raised bug for the same. We will inform you once we get any update.

Teams 1416/1.0.0.2023183501/1009 teams-js 2.16.0