Skip to content

Commit

Permalink
Update all dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
marchermans committed Nov 11, 2024
1 parent 20b1eed commit 20988c2
Show file tree
Hide file tree
Showing 15 changed files with 425 additions and 319 deletions.
6 changes: 6 additions & 0 deletions LDTTeam Authentication.sln.DotSettings.user
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACommandGroup_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F3ae3554df54242d29975c0721a8339ce4246ccd6ccfcb1a35521a8b168a4c_003FCommandGroup_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEmbed_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F79b09f2a7de046a1a5547c3a84506dfdea800_003Ff1_003F59eb93ce_003FEmbed_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AHttpStatusCode_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fafa340febeff45fd9c30d5ee754ad84435800_003Fad_003Ff8375340_003FHttpStatusCode_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIDiscordRestWebhookAPI_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fd01c2f8aabda453ca04afdae2b88df7f16600_003F80_003F57fe5bd9_003FIDiscordRestWebhookAPI_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIInteraction_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F57ad4a2a27725f2e93cd472c25d954d0a2f86f5480b3f1d217279f8e18c022_003FIInteraction_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AInteractionContext_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F539e1faf29028aae9a82d9f161be281feb8ea32808e5e9b73a293b63c3326_003FInteractionContext_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIPartialChannel_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F2479a3d967fc36e6c98e6ce6edb1ce4069f79936c9d9e5e3d5367711e45498c_003FIPartialChannel_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AResult_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F2a88e9603b6b6c45664f9ae64a13dfd5e59f81cd0a9388169bb8964c1d8e7d_003FResult_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATeam_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F8f98c7b064ea2bdeaace785ba350c5a0187ce86a17e752a0dcc7ab1c5514c36_003FTeam_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ATokenExtensions_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F71bd9d6425d1b3468328fb69fcb92d442b8dce7f54dc18cb7fb975298a187_003FTokenExtensions_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AUrlHelperExtensions_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F63fcee389eb69c983ee8a43935cbf35c6c88371dd5b8cf525b525976e0c96d16_003FUrlHelperExtensions_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="5.0.8" />
<PackageReference Include="Remora.Discord.API" Version="24.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.2" />
<PackageReference Include="Microsoft.Extensions.Identity.Stores" Version="8.0.10" />
<PackageReference Include="Remora.Discord.API" Version="78.0.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
<ItemGroup>
<PackageReference Include="FluffySpoon.AspNet.LetsEncrypt" Version="1.163.0" />
<PackageReference Include="JetBrains.Annotations" Version="2024.3.0" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="5.0.8" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="5.0.8" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.5">
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.10">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.5">
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.10">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="5.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="5.0.2" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="5.0.7" />
<PackageReference Include="Microsoft.Extensions.Hosting.Systemd" Version="8.0.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.6" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.10" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,62 @@
using Remora.Commands.Attributes;
using Remora.Commands.Groups;
using Remora.Discord.API.Abstractions.Objects;
using Remora.Discord.API.Abstractions.Rest;
using Remora.Discord.API.Objects;
using Remora.Discord.Commands.Contexts;
using Remora.Discord.Core;
using Remora.Discord.Commands.Feedback.Services;
using Remora.Results;

namespace LDTTeam.Authentication.Modules.Discord.Commands
{
public class MyRewardsCommands : CommandGroup
{
private readonly InteractionContext _context;
private readonly IDiscordRestWebhookAPI _channelApi;
private readonly IFeedbackService _feedbackService;
private readonly IConditionService _conditionService;

public MyRewardsCommands(InteractionContext context, IDiscordRestWebhookAPI channelApi,
public MyRewardsCommands(InteractionContext context,
IFeedbackService feedbackService,
IConditionService conditionService)
{
_context = context;
_channelApi = channelApi;
_feedbackService = feedbackService;
_conditionService = conditionService;
}

[Command("myrewards")]
[Description("Lists your LDTTeam Auth rewards")]
public async Task<Result> MyRewardsCommand()
public async Task<IResult> MyRewardsCommand()
{
Dictionary<string, bool>? rewards =
await _conditionService.GetRewardsForUser("discord", _context.User.ID.ToString(), CancellationToken);
var member = _context.Interaction.Member;
if (!member.HasValue)
{
return await _feedbackService.SendContextualErrorAsync(
"Command needs a user to run"
);
}
var user = member.Value.User;
if (!user.HasValue)
{
return await _feedbackService.SendContextualErrorAsync(
"Command needs a user to run"
);
}

var rewards =
await _conditionService.GetRewardsForUser("discord", user.Value.ID.ToString(), CancellationToken);

Result<IMessage> reply;
if (rewards == null)
{
reply = await Reply(new Embed
{
Title = "User not found",
Description =
$"User {_context.User.Username} was not found in our system, are you sure you've signed up?",
Colour = Color.Red
}, new Optional<IReadOnlyList<IMessageComponent>>());
reply = await _feedbackService.SendContextualEmbedAsync(
new Embed
{
Title = "User not found",
Description =
$"User {user.Value.Username} was not found in our system, are you sure you've signed up?",
Colour = Color.Red
}
);
}
else
{
Expand All @@ -55,31 +72,19 @@ public async Task<Result> MyRewardsCommand()
fields.Add(new EmbedField(reward, has.ToString(), true));
}

Embed embed = new()
{
Title = $"{_context.User.Username}'s rewards",
Colour = Color.Green,
Fields = fields
};

reply = await Reply(embed, new Optional<IReadOnlyList<IMessageComponent>>());
reply = await _feedbackService.SendContextualEmbedAsync(
new Embed
{
Title = $"{user.Value.Username}'s rewards",
Colour = Color.Green,
Fields = fields
}
);
}

return !reply.IsSuccess
? Result.FromError(reply)
: Result.FromSuccess();
}

private async Task<Result<IMessage>> Reply(Embed embed, Optional<IReadOnlyList<IMessageComponent>> components)
{
return await _channelApi.CreateFollowupMessageAsync
(
_context.ApplicationID,
_context.Token,
embeds: new[] {embed},
components: components,
ct: CancellationToken
);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Threading.Tasks;
Expand All @@ -7,68 +6,74 @@
using Remora.Commands.Attributes;
using Remora.Commands.Groups;
using Remora.Discord.API.Abstractions.Objects;
using Remora.Discord.API.Abstractions.Rest;
using Remora.Discord.API.Objects;
using Remora.Discord.Commands.Contexts;
using Remora.Discord.Commands.Feedback.Services;
using Remora.Results;

namespace LDTTeam.Authentication.Modules.Discord.Commands
{
public class RefreshCommand : CommandGroup
{
private readonly InteractionContext _context;
private readonly IDiscordRestWebhookAPI _channelApi;
private readonly IFeedbackService _feedbackService;
private readonly IBackgroundEventsQueue _eventsQueue;

public RefreshCommand(InteractionContext context, IDiscordRestWebhookAPI channelApi,
IBackgroundEventsQueue eventsQueue)
public RefreshCommand(InteractionContext context,
IBackgroundEventsQueue eventsQueue, IFeedbackService feedbackService)
{
_context = context;
_channelApi = channelApi;
_eventsQueue = eventsQueue;
_feedbackService = feedbackService;
}

[Command("refresh")]
[Description("Refreshes provider(s)")]
public async Task<IResult> RemoveRewardConditionCommand([Description("Optional provider to refresh")]
string? provider = null)
{
if (!_context.Member.Value.Permissions.Value.HasPermission(DiscordPermission.Administrator))
var member = _context.Interaction.Member;
if (!member.HasValue)
{
return await _channelApi.CreateFollowupMessageAsync
(
_context.ApplicationID,
_context.Token,
embeds: new[]
{
new Embed
{
Title = "No Permission",
Description =
"You require Administrator permissions for this command",
Colour = Color.DarkRed
}
},
flags: MessageFlags.Ephemeral,
ct: CancellationToken
return await _feedbackService.SendContextualErrorAsync(
"Command needs a user to run"
);
}

var permissions = member.Value.Permissions;
if (!permissions.HasValue)
{
return await _feedbackService.SendContextualErrorAsync(
"Command needs a user to run"
);
}

if (!permissions.Value.HasPermission(DiscordPermission.Administrator))
{
return await _feedbackService.SendContextualEmbedAsync(
new Embed
{
Title = "No Permission",
Description =
"You require Administrator permissions for this command",
Colour = Color.DarkRed
});
}

await _eventsQueue.QueueBackgroundWorkItemAsync(async (events, scope, _) =>
{
await events._refreshContentEvent.InvokeAsync(scope,
provider == null ? null : new List<string> {provider});
provider == null ? null : [provider]);
await events._postRefreshContentEvent.InvokeAsync(scope);
}, CancellationToken);

return await _channelApi.CreateFollowupMessageAsync
(
_context.ApplicationID,
_context.Token,
"done!",
flags: MessageFlags.Ephemeral,
ct: CancellationToken
);
return await _feedbackService.SendContextualEmbedAsync(
new Embed
{
Title = "Refreshed",
Description = "Refreshed provider(s)",
Colour = Color.Green
});
}
}
}
Loading

0 comments on commit 20988c2

Please sign in to comment.