microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
Libraries/Microsoft.Teams.Apps/Activities/Invokes/FileConsentActivity.cs
47lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using Microsoft.Teams.Api.Activities; |
| 5 | using Microsoft.Teams.Api.Activities.Invokes; |
| 6 | using Microsoft.Teams.Apps.Routing; |
| 7 | |
| 8 | namespace Microsoft.Teams.Apps.Activities.Invokes; |
| 9 | |
| 10 | [AttributeUsage(AttributeTargets.Method, Inherited = true)] |
| 11 | public class FileConsentAttribute() : InvokeAttribute(Api.Activities.Invokes.Name.FileConsent, typeof(FileConsentActivity)) |
| 12 | { |
| 13 | public override object Coerce(IContext<IActivity> context) => context.ToActivityType<FileConsentActivity>(); |
| 14 | } |
| 15 | |
| 16 | public static partial class AppInvokeActivityExtensions |
| 17 | { |
| 18 | public static App OnFileConsent(this App app, Func<IContext<FileConsentActivity>, Task> handler) |
| 19 | { |
| 20 | app.Router.Register(new Route() |
| 21 | { |
| 22 | Name = string.Join("/", [ActivityType.Invoke, Name.FileConsent]), |
| 23 | Type = app.Status is null ? RouteType.System : RouteType.User, |
| 24 | Handler = async context => |
| 25 | { |
| 26 | await handler(context.ToActivityType<FileConsentActivity>()); |
| 27 | return null; |
| 28 | }, |
| 29 | Selector = activity => activity is FileConsentActivity |
| 30 | }); |
| 31 | |
| 32 | return app; |
| 33 | } |
| 34 | |
| 35 | public static App OnFileConsent(this App app, Func<IContext<FileConsentActivity>, Task<object?>> handler) |
| 36 | { |
| 37 | app.Router.Register(new Route() |
| 38 | { |
| 39 | Name = string.Join("/", [ActivityType.Invoke, Name.FileConsent]), |
| 40 | Type = app.Status is null ? RouteType.System : RouteType.User, |
| 41 | Handler = context => handler(context.ToActivityType<FileConsentActivity>()), |
| 42 | Selector = activity => activity is FileConsentActivity |
| 43 | }); |
| 44 | |
| 45 | return app; |
| 46 | } |
| 47 | } |