microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
copilot/close-pull-request

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

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
4using Microsoft.AspNetCore.Authorization;
5using Microsoft.AspNetCore.Http;
6using Microsoft.AspNetCore.Mvc;
7using Microsoft.Extensions.Hosting;
8
9using static Microsoft.Teams.Plugins.AspNetCore.Extensions.HostApplicationBuilderExtensions;
10
11namespace Microsoft.Teams.Plugins.AspNetCore.Controllers;
12
13[ApiController]
14public 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}