-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implicit usings + file-scoped ns * Make Shared lib a P2P dep and dont publish to nuget.org * Update CI.yml to RTM of .NET 6 * Delete Cake remnants * RTM version of .NET 6 in release pipes * Drop .NET 5 * Remove .NET 3.1 SDK from all pipes
- Loading branch information
Showing
101 changed files
with
2,081 additions
and
2,291 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,6 @@ jobs: | |
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup .NET 3.1 | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 3.1.x | ||
- name: Setup .NET 5 | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
|
@@ -27,7 +23,7 @@ jobs: | |
- name: Setup .NET 6 | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: "6.0.100-rc.2.21458.9" | ||
dotnet-version: "6.0.x" | ||
- name: Determine Version | ||
id: gitversion | ||
uses: gittools/actions/gitversion/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 7 additions & 8 deletions
15
source/src/Slackbot.Net.Endpoints/Abstractions/EventHandledResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
namespace Slackbot.Net.Endpoints.Abstractions | ||
namespace Slackbot.Net.Endpoints.Abstractions; | ||
|
||
public class EventHandledResponse | ||
{ | ||
public class EventHandledResponse | ||
{ | ||
public string Response { get; } | ||
public string Response { get; } | ||
|
||
public EventHandledResponse(string response) | ||
{ | ||
Response = response; | ||
} | ||
public EventHandledResponse(string response) | ||
{ | ||
Response = response; | ||
} | ||
} |
10 changes: 4 additions & 6 deletions
10
source/src/Slackbot.Net.Endpoints/Abstractions/IHandleAppHomeOpened.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
using System.Threading.Tasks; | ||
using Slackbot.Net.Endpoints.Models.Events; | ||
|
||
namespace Slackbot.Net.Endpoints.Abstractions | ||
namespace Slackbot.Net.Endpoints.Abstractions; | ||
|
||
public interface IHandleAppHomeOpened | ||
{ | ||
public interface IHandleAppHomeOpened | ||
{ | ||
Task<EventHandledResponse> Handle(EventMetaData eventMetadata, AppHomeOpenedEvent payload); | ||
} | ||
Task<EventHandledResponse> Handle(EventMetaData eventMetadata, AppHomeOpenedEvent payload); | ||
} |
14 changes: 6 additions & 8 deletions
14
source/src/Slackbot.Net.Endpoints/Abstractions/IHandleAppMentions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
using System.Threading.Tasks; | ||
using Slackbot.Net.Endpoints.Models.Events; | ||
|
||
namespace Slackbot.Net.Endpoints.Abstractions | ||
namespace Slackbot.Net.Endpoints.Abstractions; | ||
|
||
public interface IHandleAppMentions | ||
{ | ||
public interface IHandleAppMentions | ||
{ | ||
Task<EventHandledResponse> Handle(EventMetaData eventMetadata, AppMentionEvent slackEvent); | ||
bool ShouldHandle(AppMentionEvent slackEvent) => true; | ||
(string HandlerTrigger, string Description) GetHelpDescription() => ("", ""); | ||
} | ||
Task<EventHandledResponse> Handle(EventMetaData eventMetadata, AppMentionEvent slackEvent); | ||
bool ShouldHandle(AppMentionEvent slackEvent) => true; | ||
(string HandlerTrigger, string Description) GetHelpDescription() => ("", ""); | ||
} |
10 changes: 4 additions & 6 deletions
10
source/src/Slackbot.Net.Endpoints/Abstractions/IHandleInteractiveBlockActions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
using System.Threading.Tasks; | ||
using Slackbot.Net.Endpoints.Models.Interactive.BlockActions; | ||
|
||
namespace Slackbot.Net.Endpoints.Abstractions | ||
namespace Slackbot.Net.Endpoints.Abstractions; | ||
|
||
public interface IHandleInteractiveBlockActions | ||
{ | ||
public interface IHandleInteractiveBlockActions | ||
{ | ||
Task<EventHandledResponse> Handle(BlockActionInteraction blockActionEvent); | ||
} | ||
Task<EventHandledResponse> Handle(BlockActionInteraction blockActionEvent); | ||
} |
10 changes: 4 additions & 6 deletions
10
source/src/Slackbot.Net.Endpoints/Abstractions/IHandleMemberJoinedChannel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
using System.Threading.Tasks; | ||
using Slackbot.Net.Endpoints.Models.Events; | ||
|
||
namespace Slackbot.Net.Endpoints.Abstractions | ||
namespace Slackbot.Net.Endpoints.Abstractions; | ||
|
||
public interface IHandleMemberJoinedChannel | ||
{ | ||
public interface IHandleMemberJoinedChannel | ||
{ | ||
Task<EventHandledResponse> Handle(EventMetaData eventMetadata, MemberJoinedChannelEvent memberjoined); | ||
} | ||
Task<EventHandledResponse> Handle(EventMetaData eventMetadata, MemberJoinedChannelEvent memberjoined); | ||
} |
10 changes: 4 additions & 6 deletions
10
source/src/Slackbot.Net.Endpoints/Abstractions/IHandleViewSubmissions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
using System.Threading.Tasks; | ||
using Slackbot.Net.Endpoints.Models.Interactive.ViewSubmissions; | ||
|
||
namespace Slackbot.Net.Endpoints.Abstractions | ||
namespace Slackbot.Net.Endpoints.Abstractions; | ||
|
||
public interface IHandleViewSubmissions | ||
{ | ||
public interface IHandleViewSubmissions | ||
{ | ||
Task<EventHandledResponse> Handle(ViewSubmission payload); | ||
} | ||
Task<EventHandledResponse> Handle(ViewSubmission payload); | ||
} |
7 changes: 3 additions & 4 deletions
7
source/src/Slackbot.Net.Endpoints/Abstractions/INoOpAppMentions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
namespace Slackbot.Net.Endpoints.Abstractions | ||
namespace Slackbot.Net.Endpoints.Abstractions; | ||
|
||
public interface INoOpAppMentions : IHandleAppMentions | ||
{ | ||
public interface INoOpAppMentions : IHandleAppMentions | ||
{ | ||
|
||
} | ||
} |
11 changes: 4 additions & 7 deletions
11
source/src/Slackbot.Net.Endpoints/Abstractions/ISelectAppMentionEventHandlers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,8 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Slackbot.Net.Endpoints.Models.Events; | ||
|
||
namespace Slackbot.Net.Endpoints.Abstractions | ||
namespace Slackbot.Net.Endpoints.Abstractions; | ||
|
||
public interface ISelectAppMentionEventHandlers | ||
{ | ||
public interface ISelectAppMentionEventHandlers | ||
{ | ||
Task<IEnumerable<IHandleAppMentions>> GetAppMentionEventHandlerFor(EventMetaData eventMetadata, AppMentionEvent slackEvent); | ||
} | ||
Task<IEnumerable<IHandleAppMentions>> GetAppMentionEventHandlerFor(EventMetaData eventMetadata, AppMentionEvent slackEvent); | ||
} |
12 changes: 5 additions & 7 deletions
12
source/src/Slackbot.Net.Endpoints/Abstractions/IShortcutHandlers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
using System.Threading.Tasks; | ||
using Slackbot.Net.Endpoints.Models.Events; | ||
|
||
namespace Slackbot.Net.Endpoints.Abstractions | ||
namespace Slackbot.Net.Endpoints.Abstractions; | ||
|
||
public interface IShortcutAppMentions | ||
{ | ||
public interface IShortcutAppMentions | ||
{ | ||
Task Handle(EventMetaData eventMetadata, AppMentionEvent @event); | ||
bool ShouldShortcut(AppMentionEvent @event); | ||
} | ||
Task Handle(EventMetaData eventMetadata, AppMentionEvent @event); | ||
bool ShouldShortcut(AppMentionEvent @event); | ||
} |
11 changes: 4 additions & 7 deletions
11
source/src/Slackbot.Net.Endpoints/Abstractions/IUninstall.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
using System.Threading.Tasks; | ||
namespace Slackbot.Net.Endpoints.Abstractions; | ||
|
||
namespace Slackbot.Net.Endpoints.Abstractions | ||
public interface IUninstall | ||
{ | ||
public interface IUninstall | ||
{ | ||
Task OnUninstalled(string teamId, string teamName); | ||
} | ||
} | ||
Task OnUninstalled(string teamId, string teamName); | ||
} |
69 changes: 32 additions & 37 deletions
69
source/src/Slackbot.Net.Endpoints/AppMentionEventHandlerSelector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,49 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
using Slackbot.Net.Endpoints.Abstractions; | ||
using Slackbot.Net.Endpoints.Models.Events; | ||
|
||
namespace Slackbot.Net.Endpoints | ||
namespace Slackbot.Net.Endpoints; | ||
|
||
internal class AppMentionEventHandlerSelector : ISelectAppMentionEventHandlers | ||
{ | ||
internal class AppMentionEventHandlerSelector : ISelectAppMentionEventHandlers | ||
private readonly ILoggerFactory _loggerFactory; | ||
private readonly IServiceProvider _provider; | ||
|
||
public AppMentionEventHandlerSelector(ILoggerFactory loggerFactory, IServiceProvider provider) | ||
{ | ||
private readonly ILoggerFactory _loggerFactory; | ||
private readonly IServiceProvider _provider; | ||
_loggerFactory = loggerFactory; | ||
_provider = provider; | ||
} | ||
|
||
public async Task<IEnumerable<IHandleAppMentions>> GetAppMentionEventHandlerFor(EventMetaData eventMetadata, AppMentionEvent slackEvent) | ||
{ | ||
var allHandlers = _provider.GetServices<IHandleAppMentions>(); | ||
var shortCutter = _provider.GetService<IShortcutAppMentions>(); | ||
var noopHandler = _provider.GetService<INoOpAppMentions>(); | ||
|
||
public AppMentionEventHandlerSelector(ILoggerFactory loggerFactory, IServiceProvider provider) | ||
if (shortCutter != null && shortCutter.ShouldShortcut(slackEvent)) | ||
{ | ||
_loggerFactory = loggerFactory; | ||
_provider = provider; | ||
await shortCutter.Handle(eventMetadata, slackEvent); | ||
return new List<IHandleAppMentions>(); | ||
} | ||
|
||
public async Task<IEnumerable<IHandleAppMentions>> GetAppMentionEventHandlerFor(EventMetaData eventMetadata, AppMentionEvent slackEvent) | ||
{ | ||
var allHandlers = _provider.GetServices<IHandleAppMentions>(); | ||
var shortCutter = _provider.GetService<IShortcutAppMentions>(); | ||
var noopHandler = _provider.GetService<INoOpAppMentions>(); | ||
|
||
if (shortCutter != null && shortCutter.ShouldShortcut(slackEvent)) | ||
{ | ||
await shortCutter.Handle(eventMetadata, slackEvent); | ||
return new List<IHandleAppMentions>(); | ||
} | ||
|
||
return SelectHandler(allHandlers, noopHandler, slackEvent); | ||
return SelectHandler(allHandlers, noopHandler, slackEvent); | ||
|
||
} | ||
} | ||
|
||
private IEnumerable<IHandleAppMentions> SelectHandler(IEnumerable<IHandleAppMentions> handlers, INoOpAppMentions noOpAppMentions, AppMentionEvent message) | ||
{ | ||
var matchingHandlers = handlers.Where(s => s.ShouldHandle(message)); | ||
if (matchingHandlers.Any()) | ||
return matchingHandlers; | ||
private IEnumerable<IHandleAppMentions> SelectHandler(IEnumerable<IHandleAppMentions> handlers, INoOpAppMentions noOpAppMentions, AppMentionEvent message) | ||
{ | ||
var matchingHandlers = handlers.Where(s => s.ShouldHandle(message)); | ||
if (matchingHandlers.Any()) | ||
return matchingHandlers; | ||
|
||
if(noOpAppMentions != null) | ||
return new List<IHandleAppMentions> { noOpAppMentions }; | ||
if(noOpAppMentions != null) | ||
return new List<IHandleAppMentions> { noOpAppMentions }; | ||
|
||
return new List<IHandleAppMentions> | ||
{ | ||
new NoOpAppMentionEventHandler(_loggerFactory.CreateLogger<NoOpAppMentionEventHandler>()) | ||
}; | ||
} | ||
return new List<IHandleAppMentions> | ||
{ | ||
new NoOpAppMentionEventHandler(_loggerFactory.CreateLogger<NoOpAppMentionEventHandler>()) | ||
}; | ||
} | ||
} |
34 changes: 16 additions & 18 deletions
34
source/src/Slackbot.Net.Endpoints/Authentication/AuthenticationBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,25 @@ | ||
using System; | ||
using System.ComponentModel.DataAnnotations; | ||
using Microsoft.AspNetCore.Authentication; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Slackbot.Net.Endpoints.Authentication | ||
{ | ||
public static class AuthenticationBuilderExtensions | ||
{ | ||
public static AuthenticationBuilder AddSlackbotEvents(this AuthenticationBuilder builder, Action<SlackbotEventsAuthenticationOptions> optionsAction) | ||
{ | ||
builder.Services.Configure(optionsAction); | ||
return builder.AddScheme<SlackbotEventsAuthenticationOptions, SlackbotEventsAuthenticationAuthenticationHandler>(SlackbotEventsAuthenticationConstants.AuthenticationScheme, optionsAction); | ||
} | ||
} | ||
namespace Slackbot.Net.Endpoints.Authentication; | ||
|
||
public class SlackbotEventsAuthenticationOptions : AuthenticationSchemeOptions | ||
public static class AuthenticationBuilderExtensions | ||
{ | ||
public static AuthenticationBuilder AddSlackbotEvents(this AuthenticationBuilder builder, Action<SlackbotEventsAuthenticationOptions> optionsAction) | ||
{ | ||
[Required] | ||
public string SigningSecret { get; set; } | ||
builder.Services.Configure(optionsAction); | ||
return builder.AddScheme<SlackbotEventsAuthenticationOptions, SlackbotEventsAuthenticationAuthenticationHandler>(SlackbotEventsAuthenticationConstants.AuthenticationScheme, optionsAction); | ||
} | ||
} | ||
|
||
public static class SlackbotEventsAuthenticationConstants | ||
{ | ||
public const string AuthenticationScheme = "SlacbotEventsAuthenticationScheme"; | ||
} | ||
public class SlackbotEventsAuthenticationOptions : AuthenticationSchemeOptions | ||
{ | ||
[Required] | ||
public string SigningSecret { get; set; } | ||
} | ||
|
||
public static class SlackbotEventsAuthenticationConstants | ||
{ | ||
public const string AuthenticationScheme = "SlacbotEventsAuthenticationScheme"; | ||
} |
Oops, something went wrong.