Skip to content

Commit

Permalink
CC v5.1 changes (#711)
Browse files Browse the repository at this point in the history
* v5.1 changes

* Avoid multiple sign in

* Updated troubleshooting guide
  • Loading branch information
Porkai-Pandian authored Apr 28, 2022
1 parent 2d14455 commit 02d45de
Show file tree
Hide file tree
Showing 80 changed files with 1,687 additions and 611 deletions.
529 changes: 529 additions & 0 deletions .github/fabricbot.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions CompanyCommunicator_Context.tm7

Large diffs are not rendered by default.

18 changes: 10 additions & 8 deletions Deployment/azuredeploy.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@
"kind": "Storage",
"properties": {
"supportsHttpsTrafficOnly": true,
"allowBlobPublicAccess": false
"allowBlobPublicAccess": false,
"minimumTlsVersion": "TLS1_2"
},
"sku": {
"name": "Standard_LRS"
Expand Down Expand Up @@ -449,14 +450,14 @@
}
},
{
"apiVersion": "2018-07-12",
"apiVersion": "2021-03-01",
"name": "[variables('authorBotName')]",
"type": "Microsoft.BotService/botServices",
"location": "global",
"sku": {
"name": "F0"
},
"kind": "sdk",
"kind": "azurebot",
"properties": {
"displayName": "[concat(parameters('appDisplayName'),'-author')]",
"description": "[parameters('appDescription')]",
Expand All @@ -469,7 +470,7 @@
{
"name": "[concat(variables('authorBotName'), '/MsTeamsChannel')]",
"type": "Microsoft.BotService/botServices/channels",
"apiVersion": "2018-07-12",
"apiVersion": "2021-03-01",
"location": "global",
"sku": {
"name": "F0"
Expand All @@ -488,14 +489,14 @@
]
},
{
"apiVersion": "2018-07-12",
"apiVersion": "2021-03-01",
"name": "[variables('botName')]",
"type": "Microsoft.BotService/botServices",
"location": "global",
"sku": {
"name": "F0"
},
"kind": "sdk",
"kind": "azurebot",
"properties": {
"displayName": "[parameters('appDisplayName')]",
"description": "[parameters('appDescription')]",
Expand All @@ -508,7 +509,7 @@
{
"name": "[concat(variables('botName'), '/MsTeamsChannel')]",
"type": "Microsoft.BotService/botServices/channels",
"apiVersion": "2018-07-12",
"apiVersion": "2021-03-01",
"location": "global",
"sku": {
"name": "F0"
Expand Down Expand Up @@ -893,6 +894,7 @@
},
"properties": {
"tenantId": "[variables('subscriptionTenantId')]",
"enableSoftDelete": true,
"enabledForDeployment": false,
"enabledForDiskEncryption": false,
"enabledForTemplateDeployment": true,
Expand Down Expand Up @@ -1313,4 +1315,4 @@
"value": "[if(variables('useFrontDoor'), variables('frontDoorDomain'), concat('Please create a custom domain name for ', variables('botAppDomain'), ' and use that in the manifest'))]"
}
}
}
}
18 changes: 10 additions & 8 deletions Deployment/azuredeploywithcert.json
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@
"kind": "Storage",
"properties": {
"supportsHttpsTrafficOnly": true,
"allowBlobPublicAccess": false
"allowBlobPublicAccess": false,
"minimumTlsVersion": "TLS1_2"
},
"sku": {
"name": "Standard_LRS"
Expand Down Expand Up @@ -449,14 +450,14 @@
}
},
{
"apiVersion": "2018-07-12",
"apiVersion": "2021-03-01",
"name": "[variables('authorBotName')]",
"type": "Microsoft.BotService/botServices",
"location": "global",
"sku": {
"name": "F0"
},
"kind": "sdk",
"kind": "azurebot",
"properties": {
"displayName": "[concat(parameters('appDisplayName'),'-author')]",
"description": "[parameters('appDescription')]",
Expand All @@ -469,7 +470,7 @@
{
"name": "[concat(variables('authorBotName'), '/MsTeamsChannel')]",
"type": "Microsoft.BotService/botServices/channels",
"apiVersion": "2018-07-12",
"apiVersion": "2021-03-01",
"location": "global",
"sku": {
"name": "F0"
Expand All @@ -488,14 +489,14 @@
]
},
{
"apiVersion": "2018-07-12",
"apiVersion": "2021-03-01",
"name": "[variables('botName')]",
"type": "Microsoft.BotService/botServices",
"location": "global",
"sku": {
"name": "F0"
},
"kind": "sdk",
"kind": "azurebot",
"properties": {
"displayName": "[parameters('appDisplayName')]",
"description": "[parameters('appDescription')]",
Expand All @@ -508,7 +509,7 @@
{
"name": "[concat(variables('botName'), '/MsTeamsChannel')]",
"type": "Microsoft.BotService/botServices/channels",
"apiVersion": "2018-07-12",
"apiVersion": "2021-03-01",
"location": "global",
"sku": {
"name": "F0"
Expand Down Expand Up @@ -904,6 +905,7 @@
],
"properties": {
"tenantId": "[variables('subscriptionTenantId')]",
"enableSoftDelete": true,
"accessPolicies": [
{
"tenantId": "[reference(concat('Microsoft.Web/sites/', variables('botAppName')), '2018-02-01', 'Full').identity.tenantId]",
Expand Down Expand Up @@ -1273,4 +1275,4 @@
"value": "[if(variables('useFrontDoor'), variables('frontDoorDomain'), concat('Please create a custom domain name for ', variables('botAppDomain'), ' and use that in the manifest'))]"
}
}
}
}
4 changes: 3 additions & 1 deletion Deployment/deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,9 @@ function logout {
}

WriteI -message "Azure AD sign-in..."
$ADaccount = Connect-AzureAD -Tenant $parameters.subscriptionTenantId.Value -ErrorAction Stop
$context = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile.DefaultContext
$aadToken = [Microsoft.Azure.Commands.Common.Authentication.AzureSession]::Instance.AuthenticationFactory.Authenticate($context.Account, $context.Environment, $context.Tenant.Id.ToString(), $null, [Microsoft.Azure.Commands.Common.Authentication.ShowDialog]::Never, $null, "https://graph.windows.net").AccessToken
$ADaccount = Connect-AzureAD -AadAccessToken $aadToken -AccountId $context.Account.Id -TenantId $context.tenant.id -ErrorAction Stop
$userAlias = (($user | ConvertFrom-Json) | where {$_.id -eq $parameters.subscriptionId.Value}).user.name


Expand Down
2 changes: 1 addition & 1 deletion Manifest/manifest_authors.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.5/MicrosoftTeams.schema.json",
"manifestVersion": "1.5",
"version": "5.0.0",
"version": "5.1.0",
"id": "1c07cd26-a088-4db8-8928-ace382fa219f",
"packageName": "com.microsoft.teams.companycommunicator.authors",
"developer": {
Expand Down
2 changes: 1 addition & 1 deletion Manifest/manifest_users.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.5/MicrosoftTeams.schema.json",
"manifestVersion": "1.5",
"version": "5.0.0",
"version": "5.1.0",
"id": "148a66bb-e83d-425a-927d-09f4299a9274",
"packageName": "com.microsoft.teams.companycommunicator",
"developer": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static bool IsCompleted(this NotificationDataEntity entity)
{
return NotificationStatus.Failed.ToString().Equals(entity.Status) ||
NotificationStatus.Sent.ToString().Equals(entity.Status) ||
NotificationStatus.Canceled.ToString().Equals(entity.Status) ||
entity.IsCompleted;
}

Expand Down
30 changes: 30 additions & 0 deletions Source/CompanyCommunicator.Common/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// <copyright file="StringExtensions.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
// </copyright>

namespace Microsoft.Teams.Apps.CompanyCommunicator.Common.Extensions
{
using System;

/// <summary>
/// Extension class for strings.
/// </summary>
public static class StringExtensions
{
/// <summary>
/// Append new line to the original string.
/// </summary>
/// <param name="originalString">the original string.</param>
/// <param name="newString">the string to be appended.</param>
/// <returns>the appended string.</returns>
public static string AppendNewLine(this string originalString, string newString)
{
return string.IsNullOrEmpty(newString)
? originalString
: string.IsNullOrWhiteSpace(originalString)
? newString
: $"{originalString}{Environment.NewLine}{newString}";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ namespace Microsoft.Teams.Apps.CompanyCommunicator.Common.Repositories
public abstract class BaseRepository<T> : IRepository<T>
where T : TableEntity, new()
{
/// <summary>
/// Maximum length of error and warning messages to save in the entity.
/// This limit ensures that we don't hit the Azure table storage limits for the max size of the data
/// in a column, and the total size of an entity.
/// </summary>
public const int MaxMessageLengthToSave = 1024;

private readonly string defaultPartitionKey;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,23 @@ public IEnumerable<string> Groups
/// </summary>
public int Throttled { get; set; }

/// <summary>
/// Gets or sets the number of not found recipients.
/// </summary>
public int? RecipientNotFound { get; set; }

/// <summary>
/// Gets or sets the number or recipients who have an unknown status - this means a status
/// that has not changed from the initial initialization status after the notification has
/// been force completed.
/// </summary>
public int Unknown { get; set; }

/// <summary>
/// Gets or sets the number or recipients who have canceled status.
/// </summary>
public int? Canceled { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the sending process is completed.
/// [DEPRECATED - kept for backward compatibility].
Expand Down Expand Up @@ -208,5 +218,10 @@ public IEnumerable<string> Groups
/// Gets or sets notification status.
/// </summary>
public string Status { get; set; }

/// <summary>
/// Gets or sets the payload of the durable function instance.
/// </summary>
public string FunctionInstancePayload { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,13 @@ namespace Microsoft.Teams.Apps.CompanyCommunicator.Common.Repositories.Notificat
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Teams.Apps.CompanyCommunicator.Common.Extensions;

/// <summary>
/// Repository of the notification data in the table storage.
/// </summary>
public class NotificationDataRepository : BaseRepository<NotificationDataEntity>, INotificationDataRepository
{
/// <summary>
/// Maximum length of error and warning messages to save in the entity.
/// This limit ensures that we don't hit the Azure table storage limits for the max size of the data
/// in a column, and the total size of an entity.
/// </summary>
public const int MaxMessageLengthToSave = 1024;

/// <summary>
/// Initializes a new instance of the <see cref="NotificationDataRepository"/> class.
/// </summary>
Expand Down Expand Up @@ -179,7 +173,7 @@ public async Task SaveExceptionInNotificationDataEntityAsync(
notificationDataEntityId);
if (notificationDataEntity != null)
{
var newMessage = this.AppendNewLine(notificationDataEntity.ErrorMessage, errorMessage);
var newMessage = notificationDataEntity.ErrorMessage.AppendNewLine(errorMessage);

// Restrict the total length of stored message to avoid hitting table storage limits
if (newMessage.Length <= MaxMessageLengthToSave)
Expand Down Expand Up @@ -208,7 +202,7 @@ public async Task SaveWarningInNotificationDataEntityAsync(
notificationDataEntityId);
if (notificationDataEntity != null)
{
var newMessage = this.AppendNewLine(notificationDataEntity.WarningMessage, warningMessage);
var newMessage = notificationDataEntity.WarningMessage.AppendNewLine(warningMessage);

// Restrict the total length of stored message to avoid hitting table storage limits
if (newMessage.Length <= MaxMessageLengthToSave)
Expand All @@ -225,12 +219,5 @@ public async Task SaveWarningInNotificationDataEntityAsync(
throw;
}
}

private string AppendNewLine(string originalString, string newString)
{
return string.IsNullOrWhiteSpace(originalString)
? newString
: $"{originalString}{Environment.NewLine}{newString}";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,15 @@ public enum NotificationStatus
/// Failed to send the message. This is an end state.
/// </summary>
Failed,

/// <summary>
/// In process of canceling the message.
/// </summary>
Canceling,

/// <summary>
/// Canceled the message. This is an end state.
/// </summary>
Canceled,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,14 @@ public interface ISentNotificationDataRepository : IRepository<SentNotificationD
/// </summary>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
public Task EnsureSentNotificationDataTableExistsAsync();

/// <summary>
/// Save exception error message in a notification data entity.
/// </summary>
/// <param name="notificationId">notification Id.</param>
/// <param name="recipientId">recipient Id.</param>
/// <param name="errorMessage">Error message.</param>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
public Task SaveExceptionInSentNotificationDataEntityAsync(string notificationId, string recipientId, string errorMessage);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,10 @@ public class SentNotificationDataEntity : TableEntity
/// only the final one will be stored here.
/// </summary>
public string ErrorMessage { get; set; }

/// <summary>
/// Gets or sets the exception details for the user.
/// </summary>
public string Exception { get; set; }
}
}
Loading

0 comments on commit 02d45de

Please sign in to comment.