// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Text.Json.Serialization;
using Microsoft.Teams.Apps.Schema;
using Microsoft.Teams.Apps.Schema.Entities;
namespace Microsoft.Teams.Apps.Handlers.MessageExtension;
///
/// Message extension command context values.
///
public static class MessageExtensionCommandContexts
{
///
/// Command invoked from a message (message action).
///
public const string Message = "message";
///
/// Command invoked from the compose box.
///
public const string Compose = "compose";
///
/// Command invoked from the command box.
///
public const string CommandBox = "commandbox";
}
///
/// Bot message preview action values.
///
public static class BotMessagePreviewActionTypes
{
///
/// User clicked edit on the preview.
///
public const string Edit = "edit";
///
/// User clicked send on the preview.
///
public const string Send = "send";
}
///
/// Context information for message extension actions.
///
public class MessageExtensionContext
{
///
/// The theme of the Teams client. Common values: "default", "dark", "contrast".
///
[JsonPropertyName("theme")]
public string? Theme { get; set; }
}
///
/// Message extension action payload for submit action and fetch task activities.
///
public class MessageExtensionAction
{
///
/// Id of the command assigned by the bot.
///
[JsonPropertyName("commandId")]
public required string CommandId { get; set; }
///
/// The context from which the command originates.
/// See for common values.
///
[JsonPropertyName("commandContext")]
public required string CommandContext { get; set; }
///
/// Bot message preview action taken by user.
/// See for common values.
///
[JsonPropertyName("botMessagePreviewAction")]
public string? BotMessagePreviewAction { get; set; }
///
/// The activity preview that was originally sent to Teams when showing the bot message preview.
/// This is sent back by Teams when the user clicks 'edit' or 'send' on the preview.
///
// TODO : this needs to be activity type or something else - format is type, attachments[]
[JsonPropertyName("botActivityPreview")]
public IList? BotActivityPreview { get; set; }
///
/// Data included with the submit action.
///
[JsonPropertyName("data")]
public object? Data { get; set; }
///
/// Message content sent as part of the command request when the command is invoked from a message.
///
[JsonPropertyName("messagePayload")]
public MessagePayload? MessagePayload { get; set; }
///
/// Context information for the action.
///
[JsonPropertyName("context")]
public MessageExtensionContext? Context { get; set; }
}
///
/// Represents the individual message within a chat or channel where a message
/// action is taken.
///
public class MessagePayload
{
///
/// Unique id of the message.
///
[JsonPropertyName("id")]
public required string Id { get; set; }
///
/// Timestamp of when the message was created.
///
[JsonPropertyName("createdDateTime")]
public string? CreatedDateTime { get; set; }
///
/// Indicates whether a message has been soft deleted.
///
[JsonPropertyName("deleted")]
public bool? Deleted { get; set; }
///
/// Subject line of the message.
///
[JsonPropertyName("subject")]
public string? Subject { get; set; }
///
/// The importance of the message.
///
///
/// See for common values.
///
[JsonPropertyName("importance")]
public string? Importance { get; set; }
///
/// Locale of the message set by the client.
///
[JsonPropertyName("locale")]
public string? Locale { get; set; }
///
/// Link back to the message.
///
[JsonPropertyName("linkToMessage")]
public string? LinkToMessage { get; set; }
///
/// Sender of the message.
///
[JsonPropertyName("from")]
public MessageFrom? From { get; set; }
///
/// Plaintext/HTML representation of the content of the message.
///
[JsonPropertyName("body")]
public MessagePayloadBody? Body { get; set; }
///
/// How the attachment(s) are displayed in the message.
///
[JsonPropertyName("attachmentLayout")]
public string? AttachmentLayout { get; set; }
///
/// Attachments in the message - card, image, file, etc.
///
[JsonPropertyName("attachments")]
public IList? Attachments { get; set; }
///
/// List of entities mentioned in the message.
///
[JsonPropertyName("mentions")]
public IList? Mentions { get; set; }
///
/// Reactions for the message.
///
[JsonPropertyName("reactions")]
public IList? Reactions { get; set; }
}
///
/// Sender of the message.
///
public class MessageFrom
{
///
/// User information of the sender.
///
[JsonPropertyName("user")]
public User? User { get; set; }
}
///
/// String constants for message importance levels.
///
public static class MessagePayloadImportanceTypes
{
///
/// Normal importance.
///
public const string Normal = "normal";
///
/// High importance.
///
public const string High = "high";
///
/// Urgent importance.
///
public const string Urgent = "urgent";
}
///
/// Message body content.
///
public class MessagePayloadBody
{
///
/// Type of content. Common values: "text", "html".
///
[JsonPropertyName("contentType")]
public string? ContentType { get; set; }
///
/// The content of the message.
///
[JsonPropertyName("content")]
public string? Content { get; set; }
}
///
/// Attachment in a message payload.
///
public class MessagePayloadAttachment
{
///
/// Unique identifier for the attachment.
///
[JsonPropertyName("id")]
public string? Id { get; set; }
///
/// Type of attachment content. See for common values.
///
[JsonPropertyName("contentType")]
public string? ContentType { get; set; }
///
/// The attachment content.
///
[JsonPropertyName("content")]
public object? Content { get; set; }
}
///
/// Reaction to a message.
///
public class MessagePayloadReaction
{
///
/// Type of reaction
/// See for common values.
///
[JsonPropertyName("reactionType")]
public string? ReactionType { get; set; }
///
/// Timestamp when the reaction was created.
///
[JsonPropertyName("createdDateTime")]
public string? CreatedDateTime { get; set; }
///
/// User who reacted.
///
[JsonPropertyName("user")]
public User? User { get; set; }
}
///
/// Represents a user who created a reaction.
///
public class User
{
///
/// Gets or sets the user identifier.
///
[JsonPropertyName("id")]
public string? Id { get; set; }
///
/// Gets or sets the user identity type. See for common values.
///
[JsonPropertyName("userIdentityType")]
public string? UserIdentityType { get; set; }
///
/// Gets or sets the display name of the user.
///
[JsonPropertyName("displayName")]
public string? DisplayName { get; set; }
}
///
/// String constants for user identity types.
///
public static class UserIdentityTypes
{
///
/// Azure Active Directory user.
///
public const string AadUser = "aadUser";
///
/// On-premise Azure Active Directory user.
///
public const string OnPremiseAadUser = "onPremiseAadUser";
///
/// Anonymous guest user.
///
public const string AnonymousGuest = "anonymousGuest";
///
/// Federated user.
///
public const string FederatedUser = "federatedUser";
}