Skip to content
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 @@ -96,7 +96,7 @@ public TeamsBaggageBuilder Set(string key, string? value)
/// <summary>
/// Populates every baggage key reachable from <c>ctx.Activity</c> — including the Apps-only keys
/// backed by <see cref="TeamsChannelAccount"/>. Tenant fallback uses the typed
/// <see cref="TeamsChannelData"/> when <see cref="TeamsChannelAccount.TenantId"/> is null.
/// <see cref="TeamsChannelData"/> when <see cref="Microsoft.Teams.Core.Schema.ChannelAccount.TenantId"/> is null.
/// </summary>
public TeamsBaggageBuilder FromTeamsContext<TActivity>(Context<TActivity> ctx) where TActivity : TeamsActivity
{
Expand Down
8 changes: 1 addition & 7 deletions core/src/Microsoft.Teams.Apps/Schema/TeamsChannelAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public TeamsChannelAccount()
result.Email = result.Properties.Extract<string>("email");
result.UserPrincipalName = result.Properties.Extract<string>("userPrincipalName");
result.UserRole = result.Properties.Extract<string>("userRole");
result.TenantId = result.Properties.Extract<string>("tenantId");
result.TenantId = channelAccount.TenantId;
if (string.IsNullOrEmpty(result.AadObjectId))
{
result.AadObjectId = result.ObjectId;
Expand Down Expand Up @@ -103,10 +103,4 @@ public TeamsChannelAccount()
/// </summary>
[JsonPropertyName("userRole")]
public string? UserRole { get; set; }

/// <summary>
/// Gets or sets the Microsoft Entra tenant ID associated with this account.
/// </summary>
[JsonPropertyName("tenantId")]
public string? TenantId { get; set; }
Comment thread
MehakBindra marked this conversation as resolved.
}
8 changes: 7 additions & 1 deletion core/src/Microsoft.Teams.Core/Schema/AgenticIdentity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public sealed class AgenticIdentity
/// </summary>
public string? AgenticUserId { get; set; }

/// <summary>
/// Tenant ID associated with the agentic identity.
/// </summary>
public string? TenantId { get; set; }

/// <summary>
/// Agentic application blueprint ID.
/// </summary>
Expand All @@ -37,7 +42,8 @@ public sealed class AgenticIdentity
{
AgenticAppId = account.AgenticAppId,
AgenticUserId = account.AgenticUserId,
AgenticAppBlueprintId = account.AgenticAppBlueprintId
AgenticAppBlueprintId = account.AgenticAppBlueprintId,
TenantId = account.TenantId
};
}
}
9 changes: 8 additions & 1 deletion core/src/Microsoft.Teams.Core/Schema/ChannelAccount.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ public class ChannelAccount()
[JsonPropertyName("agenticAppBlueprintId")]
public string? AgenticAppBlueprintId { get; set; }

/// <summary>
/// Gets or sets the tenant ID associated with the account.
/// </summary>
[JsonPropertyName("tenantId")]
public string? TenantId { get; set; }
Comment thread
MehakBindra marked this conversation as resolved.

/// <summary>
/// Gets the extension data dictionary for storing additional properties not defined in the schema.
/// </summary>
Expand All @@ -71,7 +77,8 @@ public class ChannelAccount()
{
AgenticAppId = AgenticAppId,
AgenticUserId = AgenticUserId,
AgenticAppBlueprintId = AgenticAppBlueprintId
AgenticAppBlueprintId = AgenticAppBlueprintId,
TenantId = TenantId
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,49 @@ public void IsTargeted_DeserializedFromJson()
Assert.Equal("user-123", activity.Recipient.Id);
Assert.True(activity.Recipient.IsTargeted);
}

[Fact]
public void AgenticIdentity_IncludesTenantId_FromRecipient()
{
string json = """
{
"type": "message",
"recipient": {
"id": "28:bot-id",
"agenticAppId": "agentic-app",
"agenticUserId": "agentic-user",
"agenticAppBlueprintId": "blueprint",
"tenantId": "tenant-abc"
}
}
""";

CoreActivity activity = CoreActivity.FromJsonString(json);

AgenticIdentity? identity = activity.Recipient?.GetAgenticIdentity();
Assert.NotNull(identity);
Assert.Equal("agentic-app", identity!.AgenticAppId);
Assert.Equal("agentic-user", identity.AgenticUserId);
Assert.Equal("blueprint", identity.AgenticAppBlueprintId);
Assert.Equal("tenant-abc", identity.TenantId);
}

[Fact]
public void AgenticIdentity_TenantIdAlone_DoesNotCreateIdentity()
{
string json = """
{
"type": "message",
"recipient": {
"id": "user-123",
"tenantId": "tenant-abc"
}
}
""";

CoreActivity activity = CoreActivity.FromJsonString(json);

Assert.Equal("tenant-abc", activity.Recipient?.TenantId);
Assert.Null(activity.Recipient?.GetAgenticIdentity());
}
}
Loading