microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
Libraries/Microsoft.Teams.Plugins/Microsoft.Teams.Plugins.AspNetCore/Controllers/MessageController.cs
31lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using Microsoft.AspNetCore.Authorization; |
| 5 | using Microsoft.AspNetCore.Http; |
| 6 | using Microsoft.AspNetCore.Mvc; |
| 7 | using Microsoft.Extensions.Hosting; |
| 8 | |
| 9 | using static Microsoft.Teams.Plugins.AspNetCore.Extensions.HostApplicationBuilderExtensions; |
| 10 | |
| 11 | namespace Microsoft.Teams.Plugins.AspNetCore.Controllers; |
| 12 | |
| 13 | [ApiController] |
| 14 | public class MessageController : ControllerBase |
| 15 | { |
| 16 | private readonly AspNetCorePlugin _plugin; |
| 17 | private readonly IHostApplicationLifetime _lifetime; |
| 18 | |
| 19 | public MessageController(AspNetCorePlugin plugin, IHostApplicationLifetime lifetime) |
| 20 | { |
| 21 | _plugin = plugin; |
| 22 | _lifetime = lifetime; |
| 23 | } |
| 24 | |
| 25 | [HttpPost("/api/messages")] |
| 26 | [Authorize(Policy = TeamsTokenAuthConstants.AuthorizationPolicy)] |
| 27 | public async Task<IResult> OnMessage() |
| 28 | { |
| 29 | return await _plugin.Do(HttpContext, _lifetime.ApplicationStopping); |
| 30 | } |
| 31 | } |