Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#6825] Update and fix WebexTeams issues #6833

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Thrzn41.WebexTeams" Version="1.6.2" />
<PackageReference Include="Thrzn41.WebexTeams" Version="1.8.1" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Condition=" '$(ReleasePackageVersion)' == '' " Version="$(LocalPackageVersion)" />
<PackageReference Include="Microsoft.Bot.Builder.Integration.AspNet.Core" Condition=" '$(ReleasePackageVersion)' != '' " Version="$(ReleasePackageVersion)" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public virtual async Task DeleteMessageAsync(string messageId, CancellationToken
/// <param name="target">Target for the message.</param>
/// <param name="cancellationToken">A cancellation token for the task.</param>
/// <returns>The created message id.</returns>
public virtual async Task<string> CreateMessageWithAttachmentsAsync(string recipient, string text, IList<Attachment> attachments, MessageTextType messageType = MessageTextType.Text, MessageTarget target = MessageTarget.PersonId, CancellationToken cancellationToken = default)
public virtual async Task<string> CreateMessageWithAttachmentsAsync(string recipient, string text, IList<Schema.Attachment> attachments, MessageTextType messageType = MessageTextType.Text, MessageTarget target = MessageTarget.PersonId, CancellationToken cancellationToken = default)
{
Message result;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,11 @@ public static Activity AttachmentActionToActivity(Message decryptedMessage, Pers
/// </summary>
/// <param name="message">The message with the files to process.</param>
/// <returns>A list of attachments containing the message's files.</returns>
public static List<Attachment> HandleMessageAttachments(Message message)
public static List<Schema.Attachment> HandleMessageAttachments(Message message)
{
var attachmentsList = new List<Attachment>();
var attachmentsList = new List<Schema.Attachment>();

var attachment = new Attachment
var attachment = new Schema.Attachment
{
// Currently Webex API takes only one attachment
ContentUrl = message.FileUris[0].AbsoluteUri,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ protected override async Task OnMessageActivityAsync(ITurnContext<IMessageActivi
var activity = MessageFactory.Text($" I got {turnContext.Activity.Attachments.Count} attachments");
foreach (var attachment in turnContext.Activity.Attachments)
{
var image = new Attachment(
var image = new Schema.Attachment(
"image/png",
"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQtB3AwMUeNoq4gUBGe6Ocj8kyh3bXa9ZbV7u1fVKQoyKFHdkqU");

Expand Down Expand Up @@ -79,10 +79,10 @@ private static async Task SendWelcomeMessageAsync(ITurnContext turnContext, Canc
}
}

private static Attachment CreateAdaptiveCardAttachment(string filePath)
private static Schema.Attachment CreateAdaptiveCardAttachment(string filePath)
{
var adaptiveCardJson = File.ReadAllText(filePath);
var adaptiveCardAttachment = new Attachment()
var adaptiveCardAttachment = new Schema.Attachment()
{
ContentType = "application/vnd.microsoft.card.adaptive",
Content = JsonConvert.DeserializeObject(adaptiveCardJson, new JsonSerializerSettings { MaxDepth = null }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ public async void SendActivitiesAsyncWithAttachmentShouldSucceed()
activity.Object.Type = "message";
activity.Object.Recipient = new ChannelAccount(id: "MockId");
activity.Object.Text = "Hello, Bot!";
activity.Object.Attachments = new List<Attachment>
activity.Object.Attachments = new List<Schema.Attachment>
{
new Attachment("image/png", "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQtB3AwMUeNoq4gUBGe6Ocj8kyh3bXa9ZbV7u1fVKQoyKFHdkqU"),
new Schema.Attachment("image/png", "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQtB3AwMUeNoq4gUBGe6Ocj8kyh3bXa9ZbV7u1fVKQoyKFHdkqU"),
};

var turnContext = new TurnContext(webexAdapter, activity.Object);
Expand All @@ -303,17 +303,17 @@ public async void SendActivitiesAsyncWithAttachmentActionsShouldSucceed()
{
const string expectedResponseId = "Mocked Response Id";
var webexApi = new Mock<WebexClientWrapper>(_testOptions);
webexApi.Setup(x => x.CreateMessageWithAttachmentsAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<IList<Attachment>>(), It.IsAny<MessageTextType>(), It.IsAny<MessageTarget>(), It.IsAny<CancellationToken>())).Returns(Task.FromResult(expectedResponseId));
webexApi.Setup(x => x.CreateMessageWithAttachmentsAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<IList<Schema.Attachment>>(), It.IsAny<MessageTextType>(), It.IsAny<MessageTarget>(), It.IsAny<CancellationToken>())).Returns(Task.FromResult(expectedResponseId));

var webexAdapter = new WebexAdapter(webexApi.Object, _adapterOptions);

var activity = new Mock<Activity>().SetupAllProperties();
activity.Object.Type = "message";
activity.Object.Recipient = new ChannelAccount(id: "MockId");
activity.Object.Text = "Hello, Bot!";
activity.Object.Attachments = new List<Attachment>
activity.Object.Attachments = new List<Schema.Attachment>
{
new Attachment("application/vnd.microsoft.card.adaptive"),
new Schema.Attachment("application/vnd.microsoft.card.adaptive"),
};

var turnContext = new TurnContext(webexAdapter, activity.Object);
Expand All @@ -328,7 +328,7 @@ public async void SendActivitiesAsyncShouldSucceedAndNoActivityReturnedWithActiv
{
const string expectedResponseId = "Mocked Response Id";
var webexApi = new Mock<WebexClientWrapper>(_testOptions);
webexApi.Setup(x => x.CreateMessageWithAttachmentsAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<IList<Attachment>>(), It.IsAny<MessageTextType>(), It.IsAny<MessageTarget>(), It.IsAny<CancellationToken>())).Returns(Task.FromResult(expectedResponseId));
webexApi.Setup(x => x.CreateMessageWithAttachmentsAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<IList<Schema.Attachment>>(), It.IsAny<MessageTextType>(), It.IsAny<MessageTarget>(), It.IsAny<CancellationToken>())).Returns(Task.FromResult(expectedResponseId));

var webexAdapter = new WebexAdapter(webexApi.Object, _adapterOptions);

Expand Down
Loading