microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
core/integration-test-au

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Libraries/Microsoft.Teams.Apps/Contexts/Client/ClientContext.cs

102lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4namespace Microsoft.Teams.Apps;
5
6/// <summary>
7/// context that comes from client (tab/embed) requests
8/// </summary>
9public interface IClientContext
10{
11 /// <summary>
12 /// This ID is the unique identifier assigned to the app after deployment and is critical for ensuring the correct app instance is recognized across hosts.
13 /// </summary>
14 public string? AppId { get; }
15
16 /// <summary>
17 /// Unique ID for the current session for use in correlating telemetry data. A session corresponds to the lifecycle of an app. A new session begins upon the creation of a webview (on Teams mobile) or iframe (in Teams desktop) hosting the app, and ends when it is destroyed.
18 /// </summary>
19 public string AppSessionId { get; }
20
21 /// <summary>
22 /// The Microsoft Entra tenant ID of the current user, extracted from request auth token.
23 /// </summary>
24 public string TenantId { get; }
25
26 /// <summary>
27 /// The Microsoft Entra object id of the current user, extracted from the request auth token.
28 /// </summary>
29 public string UserId { get; }
30
31 /// <summary>
32 /// The name of the current user, extracted from the request auth token.
33 /// </summary>
34 public string UserName { get; }
35
36 /// <summary>
37 /// The Microsoft Teams ID for the team with which the content is associated.
38 /// </summary>
39 public string? TeamId { get; }
40
41 /// <summary>
42 /// The ID of the parent message from which this task module was launched.
43 /// This is only available in task modules launched from bot cards.
44 /// </summary>
45 public string? MessageId { get; }
46
47 /// <summary>
48 /// The Microsoft Teams ID for the channel with which the content is associated.
49 /// </summary>
50 public string? ChannelId { get; }
51
52 /// <summary>
53 /// The Microsoft Teams ID for the chat with which the content is associated.
54 /// </summary>
55 public string? ChatId { get; }
56
57 /// <summary>
58 /// The Microsoft Teams ID for the conversation with which the content is associated.
59 /// A conversation can be a personal/group chat or channel
60 /// </summary>
61 public string? ConversationId { get; }
62
63 /// <summary>
64 /// Meeting ID used by tab when running in meeting context
65 /// </summary>
66 public string? MeetingId { get; }
67
68 /// <summary>
69 /// The developer-defined unique ID for the page this content points to.
70 /// </summary>
71 public string PageId { get; }
72
73 /// <summary>
74 /// The developer-defined unique ID for the sub-page this content points to.
75 /// This field should be used to restore to a specific state within a page,
76 /// such as scrolling to or activating a specific piece of content.
77 /// </summary>
78 public string? SubPageId { get; }
79
80 /// <summary>
81 /// The MSAL entra token.
82 /// </summary>
83 public string AuthToken { get; }
84}
85
86public class ClientContext : IClientContext
87{
88 public string? AppId { get; set; }
89 public required string AppSessionId { get; set; }
90 public required string TenantId { get; set; }
91 public required string UserId { get; set; }
92 public required string UserName { get; set; }
93 public string? TeamId { get; set; }
94 public string? MessageId { get; set; }
95 public string? ChannelId { get; set; }
96 public string? ChatId { get; set; }
97 public string? MeetingId { get; set; }
98 public required string PageId { get; set; }
99 public string? SubPageId { get; set; }
100 public required string AuthToken { get; set; }
101 public string? ConversationId => ChatId ?? ChannelId;
102}