microsoft/teams.net

Public

mirrored from https://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
kavin/conversation-fix

Branches

Tags

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

Clone

HTTPS

Download ZIP

core/src/Microsoft.Teams.Bot.Apps/Schema/Invokes/MessageExtensionAction.cs

345lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4using System.Text.Json.Serialization;
5
6namespace Microsoft.Teams.Bot.Apps.Schema;
7
8/// <summary>
9/// Message extension command context values.
10/// </summary>
11public static class MessageExtensionCommandContext
12{
13 /// <summary>
14 /// Command invoked from a message (message action).
15 /// </summary>
16 public const string Message = "message";
17
18 /// <summary>
19 /// Command invoked from the compose box.
20 /// </summary>
21 public const string Compose = "compose";
22
23 /// <summary>
24 /// Command invoked from the command box.
25 /// </summary>
26 public const string CommandBox = "commandbox";
27}
28
29/// <summary>
30/// Bot message preview action values.
31/// </summary>
32public static class BotMessagePreviewAction
33{
34 /// <summary>
35 /// User clicked edit on the preview.
36 /// </summary>
37 public const string Edit = "edit";
38
39 /// <summary>
40 /// User clicked send on the preview.
41 /// </summary>
42 public const string Send = "send";
43}
44
45/// <summary>
46/// Context information for message extension actions.
47/// </summary>
48public class MessageExtensionContext
49{
50 /// <summary>
51 /// The theme of the Teams client. Common values: "default", "dark", "contrast".
52 /// </summary>
53 [JsonPropertyName("theme")]
54 public string? Theme { get; set; }
55}
56
57/// <summary>
58/// Message extension action payload for submit action and fetch task activities.
59/// </summary>
60public class MessageExtensionAction
61{
62 /// <summary>
63 /// Id of the command assigned by the bot.
64 /// </summary>
65 [JsonPropertyName("commandId")]
66 public required string CommandId { get; set; }
67
68 /// <summary>
69 /// The context from which the command originates.
70 /// See <see cref="MessageExtensionCommandContext"/> for common values.
71 /// </summary>
72 [JsonPropertyName("commandContext")]
73 public required string CommandContext { get; set; }
74
75 /// <summary>
76 /// Bot message preview action taken by user.
77 /// See <see cref="BotMessagePreviewAction"/> for common values.
78 /// </summary>
79 [JsonPropertyName("botMessagePreviewAction")]
80 public string? BotMessagePreviewAction { get; set; }
81
82 /// <summary>
83 /// The activity preview that was originally sent to Teams when showing the bot message preview.
84 /// This is sent back by Teams when the user clicks 'edit' or 'send' on the preview.
85 /// </summary>
86 // TODO : this needs to be activity type or something else - format is type, attachments[]
87 [JsonPropertyName("botActivityPreview")]
88 public IList<TeamsActivity>? BotActivityPreview { get; set; }
89
90 /// <summary>
91 /// Data included with the submit action.
92 /// </summary>
93 [JsonPropertyName("data")]
94 public object? Data { get; set; }
95
96 /// <summary>
97 /// Message content sent as part of the command request when the command is invoked from a message.
98 /// </summary>
99 [JsonPropertyName("messagePayload")]
100 public MessagePayload? MessagePayload { get; set; }
101
102 /// <summary>
103 /// Context information for the action.
104 /// </summary>
105 [JsonPropertyName("context")]
106 public MessageExtensionContext? Context { get; set; }
107}
108
109/// <summary>
110/// Represents the individual message within a chat or channel where a message
111/// action is taken.
112/// </summary>
113public class MessagePayload
114{
115 /// <summary>
116 /// Unique id of the message.
117 /// </summary>
118 [JsonPropertyName("id")]
119 public required string Id { get; set; }
120
121 /// <summary>
122 /// Timestamp of when the message was created.
123 /// </summary>
124 [JsonPropertyName("createdDateTime")]
125 public string? CreatedDateTime { get; set; }
126
127 /// <summary>
128 /// Indicates whether a message has been soft deleted.
129 /// </summary>
130 [JsonPropertyName("deleted")]
131 public bool? Deleted { get; set; }
132
133 /// <summary>
134 /// Subject line of the message.
135 /// </summary>
136 [JsonPropertyName("subject")]
137 public string? Subject { get; set; }
138
139 /// <summary>
140 /// The importance of the message.
141 /// </summary>
142 /// <remarks>
143 /// See <see cref="MessagePayloadImportance"/> for common values.
144 /// </remarks>
145 [JsonPropertyName("importance")]
146 public string? Importance { get; set; }
147
148 /// <summary>
149 /// Locale of the message set by the client.
150 /// </summary>
151 [JsonPropertyName("locale")]
152 public string? Locale { get; set; }
153
154 /// <summary>
155 /// Link back to the message.
156 /// </summary>
157 [JsonPropertyName("linkToMessage")]
158 public string? LinkToMessage { get; set; }
159
160 /// <summary>
161 /// Sender of the message.
162 /// </summary>
163 [JsonPropertyName("from")]
164 public MessageFrom? From { get; set; }
165
166 /// <summary>
167 /// Plaintext/HTML representation of the content of the message.
168 /// </summary>
169 [JsonPropertyName("body")]
170 public MessagePayloadBody? Body { get; set; }
171
172 /// <summary>
173 /// How the attachment(s) are displayed in the message.
174 /// </summary>
175 [JsonPropertyName("attachmentLayout")]
176 public string? AttachmentLayout { get; set; }
177
178 /// <summary>
179 /// Attachments in the message - card, image, file, etc.
180 /// </summary>
181 [JsonPropertyName("attachments")]
182 public IList<MessagePayloadAttachment>? Attachments { get; set; }
183
184 /// <summary>
185 /// List of entities mentioned in the message.
186 /// </summary>
187 [JsonPropertyName("mentions")]
188 public IList<MentionEntity>? Mentions { get; set; }
189
190 /// <summary>
191 /// Reactions for the message.
192 /// </summary>
193 [JsonPropertyName("reactions")]
194 public IList<MessageReaction>? Reactions { get; set; }
195}
196
197/// <summary>
198/// Sender of the message.
199/// </summary>
200public class MessageFrom
201{
202 /// <summary>
203 /// User information of the sender.
204 /// </summary>
205 [JsonPropertyName("user")]
206 public User? User { get; set; }
207}
208
209/// <summary>
210/// String constants for message importance levels.
211/// </summary>
212public static class MessagePayloadImportance
213{
214 /// <summary>
215 /// Normal importance.
216 /// </summary>
217 public const string Normal = "normal";
218
219 /// <summary>
220 /// High importance.
221 /// </summary>
222 public const string High = "high";
223
224 /// <summary>
225 /// Urgent importance.
226 /// </summary>
227 public const string Urgent = "urgent";
228}
229
230/// <summary>
231/// Message body content.
232/// </summary>
233public class MessagePayloadBody
234{
235 /// <summary>
236 /// Type of content. Common values: "text", "html".
237 /// </summary>
238 [JsonPropertyName("contentType")]
239 public string? ContentType { get; set; }
240
241 /// <summary>
242 /// The content of the message.
243 /// </summary>
244 [JsonPropertyName("content")]
245 public string? Content { get; set; }
246}
247
248/// <summary>
249/// Attachment in a message payload.
250/// </summary>
251public class MessagePayloadAttachment
252{
253 /// <summary>
254 /// Unique identifier for the attachment.
255 /// </summary>
256 [JsonPropertyName("id")]
257 public string? Id { get; set; }
258
259 /// <summary>
260 /// Type of attachment content. See <see cref="AttachmentContentType"/> for common values.
261 /// </summary>
262 [JsonPropertyName("contentType")]
263 public string? ContentType { get; set; }
264
265 /// <summary>
266 /// The attachment content.
267 /// </summary>
268 [JsonPropertyName("content")]
269 public object? Content { get; set; }
270}
271
272/// <summary>
273/// Reaction to a message.
274/// </summary>
275public class MessagePayloadReaction
276{
277 /// <summary>
278 /// Type of reaction
279 /// See <see cref="ReactionTypes"/> for common values.
280 /// </summary>
281 [JsonPropertyName("reactionType")]
282 public string? ReactionType { get; set; }
283
284 /// <summary>
285 /// Timestamp when the reaction was created.
286 /// </summary>
287 [JsonPropertyName("createdDateTime")]
288 public string? CreatedDateTime { get; set; }
289
290 /// <summary>
291 /// User who reacted.
292 /// </summary>
293 [JsonPropertyName("user")]
294 public User? User { get; set; }
295}
296
297/// <summary>
298/// Represents a user who created a reaction.
299/// </summary>
300public class User
301{
302 /// <summary>
303 /// Gets or sets the user identifier.
304 /// </summary>
305 [JsonPropertyName("id")]
306 public string? Id { get; set; }
307
308 /// <summary>
309 /// Gets or sets the user identity type.
310 /// </summary>
311 [JsonPropertyName("userIdentityType")]
312 public string? UserIdentityType { get; set; }
313
314 /// <summary>
315 /// Gets or sets the display name of the user.
316 /// </summary>
317 [JsonPropertyName("displayName")]
318 public string? DisplayName { get; set; }
319}
320
321/// <summary>
322/// String constants for user identity types.
323/// </summary>
324public static class UserIdentityTypes
325{
326 /// <summary>
327 /// Azure Active Directory user.
328 /// </summary>
329 public const string AadUser = "aadUser";
330
331 /// <summary>
332 /// On-premise Azure Active Directory user.
333 /// </summary>
334 public const string OnPremiseAadUser = "onPremiseAadUser";
335
336 /// <summary>
337 /// Anonymous guest user.
338 /// </summary>
339 public const string AnonymousGuest = "anonymousGuest";
340
341 /// <summary>
342 /// Federated user.
343 /// </summary>
344 public const string FederatedUser = "federatedUser";
345}
346