diff --git a/src/Microsoft.Teams.Apps/Schema/SuggestedAction.cs b/src/Microsoft.Teams.Apps/Schema/SuggestedAction.cs index ee342823..51e0f2df 100644 --- a/src/Microsoft.Teams.Apps/Schema/SuggestedAction.cs +++ b/src/Microsoft.Teams.Apps/Schema/SuggestedAction.cs @@ -113,6 +113,11 @@ public class ActionType(string value) : StringEnum(value) public static readonly ActionType SignIn = new("signin"); /// Gets the call action type. public static readonly ActionType Call = new("call"); + /// + /// Gets the setCachePolicy action type used to control caching for a link-unfurling response. + /// Set the action value to {"type":"no-cache"} to prevent Teams from caching the response. + /// + public static readonly ActionType SetCachePolicy = new("setCachePolicy"); /// Gets the experimental Action.Submit action type. public static readonly ActionType Submit = new("Action.Submit"); @@ -150,6 +155,12 @@ public static class ActionTypes /// Gets the call action type. public static ActionType Call => ActionType.Call; + /// + /// Gets the setCachePolicy action type used to control caching for a link-unfurling response. + /// Set the action value to {"type":"no-cache"} to prevent Teams from caching the response. + /// + public static ActionType SetCachePolicy => ActionType.SetCachePolicy; + /// Gets the experimental Action.Submit action type. [System.Diagnostics.CodeAnalysis.Experimental("ExperimentalTeamsSuggestedAction")] public static ActionType Submit => ActionType.Submit; diff --git a/test/Microsoft.Teams.Apps.UnitTests/SuggestedActionsTests.cs b/test/Microsoft.Teams.Apps.UnitTests/SuggestedActionsTests.cs index 5aa8687d..c4a3c321 100644 --- a/test/Microsoft.Teams.Apps.UnitTests/SuggestedActionsTests.cs +++ b/test/Microsoft.Teams.Apps.UnitTests/SuggestedActionsTests.cs @@ -22,6 +22,7 @@ public void ActionTypes_Constants_HaveExpectedValues() Assert.Equal("downloadFile", ActionTypes.DownloadFile); Assert.Equal("signin", ActionTypes.SignIn); Assert.Equal("call", ActionTypes.Call); + Assert.Equal("setCachePolicy", ActionTypes.SetCachePolicy); Assert.Equal("Action.Submit", ActionTypes.Submit); } @@ -250,4 +251,25 @@ public void MessageActivity_SuggestedActions_RoundTrip() Assert.Equal("imBack", roundTripped.SuggestedActions.Actions[1].Type!.ToString()); Assert.Equal("Say Hi", roundTripped.SuggestedActions.Actions[1].Title); } + + [Fact] + public void MessageActivity_SetCachePolicySuggestedAction_RoundTripsNoCacheValue() + { + MessageActivity activity = new("Link unfurl") + { + SuggestedActions = new SuggestedActions() + .AddAction(new SuggestedAction( + ActionTypes.SetCachePolicy, + "Disable caching", + new { type = "no-cache" })) + }; + + string json = activity.ToJson(); + CoreActivity coreActivity = CoreActivity.FromJsonString(json); + MessageActivity roundTripped = MessageActivity.FromActivity(coreActivity); + + SuggestedAction action = Assert.Single(roundTripped.SuggestedActions!.Actions); + Assert.Equal("setCachePolicy", action.Type!.ToString()); + Assert.Equal("no-cache", action.Value!["type"]!.GetValue()); + } }