microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
core/src/Microsoft.Teams.Bot.Core/Schema/ConversationAccount.cs
57lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | namespace Microsoft.Teams.Bot.Core.Schema; |
| 5 | |
| 6 | /// <summary> |
| 7 | /// Represents a conversation account, including its unique identifier, display name, and any additional properties |
| 8 | /// associated with the conversation. |
| 9 | /// </summary> |
| 10 | /// <remarks>This class is typically used to model the account information for a conversation in messaging or chat |
| 11 | /// applications. The additional properties dictionary allows for extensibility to support custom metadata or |
| 12 | /// protocol-specific fields.</remarks> |
| 13 | public class ConversationAccount() |
| 14 | { |
| 15 | /// <summary> |
| 16 | /// Gets or sets the unique identifier for the object. |
| 17 | /// </summary> |
| 18 | [JsonPropertyName("id")] |
| 19 | public string? Id { get; set; } |
| 20 | |
| 21 | /// <summary> |
| 22 | /// Gets or sets the display name of the conversation account. |
| 23 | /// </summary> |
| 24 | [JsonPropertyName("name")] |
| 25 | public string? Name { get; set; } |
| 26 | |
| 27 | /// <summary> |
| 28 | /// Gets the extension data dictionary for storing additional properties not defined in the schema. |
| 29 | /// </summary> |
| 30 | [JsonExtensionData] |
| 31 | #pragma warning disable CA2227 // Collection properties should be read only |
| 32 | public ExtendedPropertiesDictionary Properties { get; set; } = []; |
| 33 | #pragma warning restore CA2227 // Collection properties should be read only |
| 34 | |
| 35 | /// <summary> |
| 36 | /// Gets the agentic identity from the account properties. |
| 37 | /// </summary> |
| 38 | /// <returns>An AgenticIdentity instance if properties contain agentic identity information; otherwise, null.</returns> |
| 39 | internal AgenticIdentity? GetAgenticIdentity() |
| 40 | { |
| 41 | Properties.TryGetValue("agenticAppId", out object? appIdObj); |
| 42 | Properties.TryGetValue("agenticUserId", out object? userIdObj); |
| 43 | Properties.TryGetValue("agenticAppBlueprintId", out object? bluePrintObj); |
| 44 | |
| 45 | if (appIdObj is null && userIdObj is null && bluePrintObj is null) |
| 46 | { |
| 47 | return null; |
| 48 | } |
| 49 | |
| 50 | return new AgenticIdentity |
| 51 | { |
| 52 | AgenticAppId = appIdObj?.ToString(), |
| 53 | AgenticUserId = userIdObj?.ToString(), |
| 54 | AgenticAppBlueprintId = bluePrintObj?.ToString() |
| 55 | }; |
| 56 | } |
| 57 | } |
| 58 | |