Skip to content

Commit

Permalink
Clean up before merging
Browse files Browse the repository at this point in the history
  • Loading branch information
MrSmoke committed Mar 18, 2024
1 parent de890c0 commit 729eaa8
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 10 deletions.
1 change: 1 addition & 0 deletions src/TeaTime.Slack/Controllers/OAuthCallbackController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Models.ViewModels;
using Services;
using static Constants;

public class OAuthCallbackController(
Expand Down
1 change: 0 additions & 1 deletion src/TeaTime.Slack/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ internal static bool TryGetCallbackState(this BaseEvent command, [NotNullWhen(tr
return true;
}


callbackData = null;
return false;
}
Expand Down
2 changes: 0 additions & 2 deletions src/TeaTime.Slack/ServiceCollectionExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
using System.Reflection;
using Client;
using CommandRouter.Integration.AspNetCore.Extensions;
using Common;
using Common.Features.Orders.Events;
using Common.Features.Runs.Events;
using Common.Options;
using Configuration;
using EventHandlers;
using MediatR;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace TeaTime.Slack;
namespace TeaTime.Slack.Services;

using System.Threading;
using System.Threading.Tasks;
Expand Down
5 changes: 4 additions & 1 deletion src/TeaTime.Slack/Services/SignedSecretsRequestVerifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public bool IsEnabled()

public async Task<bool> VerifyAsync(HttpRequest request, CancellationToken cancellationToken = default)
{
ArgumentNullException.ThrowIfNull(request);

if (!IsEnabled())
return false;

Expand All @@ -49,8 +51,9 @@ public async Task<bool> VerifyAsync(HttpRequest request, CancellationToken cance
}

// Read body and seek back to start
string requestBody;
var bodyStream = request.Body;

string requestBody;
using (var reader = new StreamReader(bodyStream, Encoding.UTF8, leaveOpen: true))
requestBody = await reader.ReadToEndAsync(cancellationToken);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
namespace TeaTime.Slack;
namespace TeaTime.Slack.Services;

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Client;
using Configuration;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
using Client;
using Configuration;
using Models.Requests;
using Models.Responses;

Expand Down Expand Up @@ -42,6 +42,8 @@ public string BuildAuthorizeUrl()

public Task<OAuthTokenResponse> GetOAuthTokenAsync(string code, CancellationToken cancellationToken = default)
{
ArgumentNullException.ThrowIfNull(code);

var oauth = GetOptions();

return slackApiClient.GetOAuthTokenAsync(new OAuthTokenRequest
Expand Down
2 changes: 1 addition & 1 deletion src/TeaTime.Slack/Services/SlackVerifyRequestMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private static async Task CopyToAsync(Stream source, Stream destination, int buf
if (bytesRead > MaxLength)
throw new Exception("Body too big");

await destination.WriteAsync(new ReadOnlyMemory<byte>(buffer, 0, bytesRead), cancellationToken).ConfigureAwait(false);
await destination.WriteAsync(new ReadOnlyMemory<byte>(buffer, 0, bytesRead), cancellationToken);
}
}
finally
Expand Down
2 changes: 1 addition & 1 deletion src/TeaTime.Slack/Views/Shared/_SlackButton.cshtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@using TeaTime.Slack
@using TeaTime.Slack.Services
@inject ISlackAuthenticationService SlackAuthenticationService

@if (SlackAuthenticationService.OAuthEnabled())
Expand Down

0 comments on commit 729eaa8

Please sign in to comment.