Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate frontend to Blazor #992

Merged
merged 117 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
117 commits
Select commit Hold shift + click to select a range
3c1e27e
Initial blazor implementation
calledude Jul 15, 2023
b5c8382
Remove template files
calledude Jul 29, 2023
d0510cb
Add developmentSettings to gitignore and allow wwwroot in blazor project
calledude Jul 29, 2023
b75e5a5
Add MudBlazor to _Host.cshtml
calledude Jul 29, 2023
f3f135c
Initial landing page implementation
calledude Jul 29, 2023
68b903b
Migrate Modix startup to Modix.Web
calledude Jul 29, 2023
7e982e4
Implement navbar with separate views depending on authorization state
calledude Jul 29, 2023
5651a49
Initial implementation of UserLookup page
calledude Jul 29, 2023
39f3da4
Initial implementation of Commands page
calledude Jul 29, 2023
1c350c4
Initial implementation of Stats page
calledude Jul 29, 2023
16d7f8c
Initial implementation of Tags page
calledude Jul 29, 2023
b02cb4e
Initial implementation of Promotions page
calledude Jul 29, 2023
8ff568f
Run AuthorizationService.OnAuthenticatedAsync in MainLayout instead
calledude Jul 30, 2023
a26a118
Initial implementation of Logs/Infractions page
calledude Jul 30, 2023
e25d0f7
Use dropdown for 'Type' in infractions grid
calledude Jul 30, 2023
3563872
Remove unnecessary comments
calledude Jul 30, 2023
7d28fbb
Move navbar from MainLayout to separate component
calledude Jul 30, 2023
a6cb9cc
Change page titles
calledude Jul 30, 2023
0080f30
Get SocketGuild from SocketGuildUser instead
calledude Aug 1, 2023
c91ce5c
Use OnAfterRenderAsync instead to avoid duplicate DB calls
calledude Aug 1, 2023
06c21b2
Implement guild selection
calledude Aug 1, 2023
2a3d850
Remove <AuthorizeView> etc in favor of Authorize attribute
calledude Aug 1, 2023
d940b7d
Use OnAfterRenderAsync to avoid unnecessary execution of db calls etc
calledude Aug 1, 2023
993a479
Use [Authorize] attribute to avoid rendering of the page whatsoever
calledude Aug 1, 2023
4e0942b
Fix icon colors of navbar in the logged out state
calledude Aug 1, 2023
1599955
Use middleware to assign claims rather than have it in App.razor
calledude Aug 1, 2023
6c6d77a
Move logout button to dropdown menu
calledude Aug 1, 2023
5a1b16b
Rename LocalStorageService -> CookieService
calledude Aug 1, 2023
5458ac8
Show current user when first visiting UserLookup
calledude Aug 1, 2023
52eeea9
Move models to Models folder
calledude Aug 1, 2023
fd451a6
Propagate CurrentUserId down to components via SessionState to avoid …
calledude Aug 1, 2023
35e9651
Fix issue with filters not resetting properly
calledude Aug 1, 2023
13169b3
Initially select nothing in the dropdown for InfractionType (nothing …
calledude Aug 1, 2023
b648bca
Force cookie to be created on root path
calledude Aug 1, 2023
4ee8dfc
Continue with first found guild if no guild cookie was found
calledude Aug 1, 2023
8547ab1
Case-insensitive filtering on Tags page
calledude Aug 1, 2023
7c51c23
Improve feedback when Tag creation fails (or succeeds)
calledude Aug 1, 2023
0708b77
Allow null/empty comments for promotions
calledude Aug 1, 2023
da919b4
Disable editing comments for closed campaigns
calledude Aug 1, 2023
c0e738d
Initial implementation of Configuration (Claims)
calledude Aug 3, 2023
53c79d7
Small touchup
calledude Aug 3, 2023
edc9ee8
Remove unnecessary stuff in MainLayout
calledude Aug 3, 2023
f4fa55d
Modify DesignatedRoleService API slightly to return the id of the cre…
calledude Aug 3, 2023
02e5392
Initial implementation of Configuration (Roles)
calledude Aug 3, 2023
acc05cb
Slight improvement to styling of menu for Configuration and Logs
calledude Aug 3, 2023
2142bf3
Modify DesignatedChannelService API slightly to return the id of the …
calledude Aug 3, 2023
ff77745
Make IndividualDesignation component generic
calledude Aug 3, 2023
189ef63
Initial implementation of Configuration (Channels)
calledude Aug 3, 2023
7af84ef
Slight improvements to Channels/Roles configuration pages
calledude Aug 3, 2023
99b531a
Make Autocomplete component generic
calledude Aug 3, 2023
c4e91aa
Move ModixUser and RoleInformation into Common
calledude Aug 3, 2023
fb96f85
Modify interface of PromotionsService to return the PromotionActionSu…
calledude Aug 3, 2023
0b2a80f
Implement possibility of passing query parameters to infractions page…
calledude Aug 4, 2023
1d81a81
Add possibility of accepting/rejecting/forcing a campaign as well as …
calledude Aug 4, 2023
f3a53ae
Simplify styling on Infractions page
calledude Aug 4, 2023
635b4ba
Use iconbuttons instead for accept/reject
calledude Aug 4, 2023
cd5cd8f
Re-use existing extension method for getting full username
calledude Aug 4, 2023
3f734e9
Initial implementation of Logs/DeletedMessages page
calledude Aug 5, 2023
f1f4e6f
Fix bug with filtering DeletedMessageEntity
calledude Aug 5, 2023
aefc94a
Set _currentContext before potential early bail
calledude Aug 5, 2023
8935577
Show role color if relevant in Tags grid
calledude Aug 5, 2023
84da697
Enable query parameter for Tags page
calledude Aug 5, 2023
d139371
Use generic version of DialogParameters when instantiating Dialogs
calledude Aug 5, 2023
063d0bf
Persist infraction table settings to local storage
calledude Aug 5, 2023
eb48e5e
Slight styling improvements to stats page
calledude Aug 5, 2023
b2af708
Fix/consolidate date string formatting
calledude Aug 5, 2023
96ded79
Responsive navmenu
calledude Aug 5, 2023
4015fad
Responsive commands page
calledude Aug 5, 2023
9d64695
Better styling for DeletedMessages
calledude Aug 6, 2023
30a4018
Better styling for Infractions page
calledude Aug 6, 2023
eb98938
Responsive styling for Configuration (Claims)
calledude Aug 6, 2023
ea7a29d
Responsive styling for UserLookup
calledude Aug 6, 2023
aa089cc
Slightly improve styling for landing and promotions pages
calledude Aug 6, 2023
e62e7d8
Remove unnecessary elements from landing page
calledude Aug 6, 2023
3b18046
Change Primary color to match the vue website
calledude Aug 6, 2023
572cc3b
Fix weird flickering issue when navigating via anchors
calledude Aug 6, 2023
6d54058
Use MudGrid instead of MudDrawer
calledude Aug 6, 2023
c9a9c62
Rename DiscordUserService to DiscordHelper
calledude Aug 6, 2023
a5773f0
Make it possible to switch between Vue and Blazor via config flag 'Us…
calledude Aug 6, 2023
1e3fc62
Remove appsettings from Modix.Web
calledude Aug 6, 2023
75742fa
Add NoDefaultLaunchSettingsFile to avoid re-creating launchSettings.json
calledude Aug 6, 2023
ff29b6d
Remove LocalStorageService in favor of reading cookies upon first HTT…
calledude Aug 6, 2023
3e45eb1
Remove unused package/project references
calledude Aug 6, 2023
4e0f930
Add favicon
calledude Aug 6, 2023
fa1b339
Use Roles instead of Policy authorization
calledude Aug 6, 2023
f32b7ad
Improve grid size for bigger screens
calledude Aug 6, 2023
fc99cbc
Implement comment creation box to show when the user has yet to vote …
calledude Aug 6, 2023
c7b9278
Fit content to screen width on Tags page
calledude Aug 6, 2023
aadaced
Minor touchups
calledude Sep 11, 2023
12dc264
Remove unused css
calledude Sep 11, 2023
445b2bd
Fix more nullability stuff
calledude Sep 11, 2023
97b8325
Fixed AutoComplete after breaking it by not invoking the RenderFragme…
calledude Sep 11, 2023
263cd83
Disable button/comment box on promotion creation page if no "next ran…
calledude Sep 11, 2023
f923f73
Fix compilation issue
calledude Dec 21, 2023
2b8e9c6
Upgrade packages to stable version to fix startup issue
calledude Dec 21, 2023
b0cb57d
Fix ItemTemplate issue causing preview to be empty
calledude Dec 21, 2023
8d3d176
Remove TODO comments, add error message when fetching of campaign det…
calledude Dec 21, 2023
a96e3cc
Make Title an optional parameter on the AutoComplete component and re…
calledude Dec 21, 2023
cfb447e
Remove background color from UserLookup
calledude Dec 21, 2023
c5ae0d9
Apply small gap rule on small screen sizes (that aren't quite xs yet)…
calledude Dec 21, 2023
e9a93dc
Improved styling for toolbar on Infractions page
calledude Dec 21, 2023
79aac74
Improved styling for toolbar on Tags page
calledude Dec 21, 2023
5d966f2
Fix css not being served from the correct folder
calledude Dec 22, 2023
18cc9ae
Improve styling for Promotions page on small resolutions
calledude Dec 22, 2023
b60925e
Update NuGet packages and change from deprecated APIs/properties
calledude Dec 22, 2023
bde3adf
Remove UseStaticFiles call in favor of linking to static files correc…
calledude Dec 22, 2023
fb80fd1
Update Dockerfile to use .net8 instead of .net8-preview image
calledude Dec 23, 2023
aab1e42
Update more NuGet packages to .NET pinned versions and cleanup some o…
calledude Dec 23, 2023
a64e032
Use maxcpucount:1 in Dockerfile to avoid files being used by other pr…
calledude Dec 23, 2023
ab96419
Slight mobile styling tweaks to Infractions and Tags page
calledude Dec 23, 2023
4f09bf6
Reduce reliance on inline styling
calledude Dec 27, 2023
8b1a691
Update default value for UseBlazor setting in deployment configuratio…
calledude Dec 27, 2023
9bf0fa4
Format code
calledude Dec 27, 2023
7477b25
Improved styling on CreatePromotion page on small resolutions
calledude Dec 28, 2023
f6f5ccc
Improved styling for Configuration/Logs pages
calledude Dec 28, 2023
c627fb1
Add margin to make it look a bit nicer when scrolling to the bottom o…
calledude Dec 28, 2023
b90ed09
Tweak styling for large resolutions on Stats and Logs pages
calledude Dec 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ bld/
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
wwwroot/
!Modix.Web/wwwroot/
dataprotection/

# VS Code
Expand Down Expand Up @@ -261,5 +262,5 @@ Modix/config
/Modix/Properties/launchSettings.json

*.DotSettings
Modix/developmentSettings\.json
Modix/logs/*
**/developmentSettings\.json
**/logs/*
47 changes: 23 additions & 24 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@
<ItemGroup>
<PackageReference Update="Discord.Net" Version="3.11.0" />

<PackageReference Update="Microsoft.EntityFrameworkCore" Version="8.0.0-preview.4.*" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Design" Version="8.0.0-preview.4.*"/>
<PackageReference Update="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.0-preview.4.*" />
<PackageReference Update="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0-preview.4" />
<PackageReference Update="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Update="Microsoft.EntityFrameworkCore.Design" Version="8.0.0"/>
<PackageReference Update="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.0" />
<PackageReference Update="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />

<PackageReference Update="Nito.AsyncEx.Coordination" Version="5.1.2" />

<PackageReference Update="AspNet.Security.OAuth.Discord" Version="7.0.2" />
<PackageReference Update="AspNet.Security.OAuth.Discord" Version="8.0.0" />

<PackageReference Update="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.0-preview.6.*" />
<PackageReference Update="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.0-preview.6.*" />
<PackageReference Update="Microsoft.Extensions.Caching.Memory" Version="8.0.0-preview.6.*" />
<PackageReference Update="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0-preview.6.*" />
<PackageReference Update="Microsoft.Extensions.DependencyInjection" Version="8.0.0-preview.6.*" />
<PackageReference Update="Microsoft.Extensions.Hosting" Version="8.0.0-preview.6.*" />
<PackageReference Update="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0-preview.6.*" />
<PackageReference Update="Microsoft.Extensions.Http" Version="8.0.0-preview.6.*" />
<PackageReference Update="Microsoft.Extensions.Http.Polly" Version="8.0.0-preview.6.*" />
<PackageReference Update="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0-preview.6.*" />
<PackageReference Update="Microsoft.Extensions.Logging.Console" Version="8.0.0-preview.6.*" />
<PackageReference Update="Microsoft.Extensions.Options" Version="8.0.0-preview.6.*" />
<PackageReference Update="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0-preview.6.*" />
<PackageReference Update="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.0" />
<PackageReference Update="Microsoft.AspNetCore.SpaServices.Extensions" Version="8.0.0" />
<PackageReference Update="Microsoft.Extensions.Caching.Memory" Version="8.0.0" />
<PackageReference Update="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
<PackageReference Update="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Update="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Update="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" />
<PackageReference Update="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Update="Microsoft.Extensions.Http.Polly" Version="8.0.0" />
<PackageReference Update="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
<PackageReference Update="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
<PackageReference Update="Microsoft.Extensions.Options" Version="8.0.0" />
<PackageReference Update="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
<PackageReference Update="Microsoft.NET.Test.Sdk" Version="17.*" />

<PackageReference Update="Newtonsoft.Json" Version="13.0.3" />
Expand All @@ -44,13 +44,12 @@

<PackageReference Update="LinqKit.Microsoft.EntityFrameworkCore" Version="7.1.4" />

<PackageReference Update="Serilog" Version="3.0.1" />
<PackageReference Update="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Update="Serilog.Expressions" Version="3.4.1" />
<PackageReference Update="Serilog.Extensions.Logging" Version="7.0.0" />
<PackageReference Update="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Update="Serilog" Version="3.1.1" />
<PackageReference Update="Serilog.AspNetCore" Version="8.0.0" />
<PackageReference Update="Serilog.Expressions" Version="4.0.0" />
<PackageReference Update="Serilog.Sinks.Console" Version="5.0.1" />
<PackageReference Update="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Update="Serilog.Sinks.Seq" Version="5.2.2" />
<PackageReference Update="Serilog.Sinks.Seq" Version="6.0.0" />

<PackageReference Update="Humanizer.Core" Version="2.14.1" />

Expand Down
8 changes: 4 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM mcr.microsoft.com/dotnet/aspnet:8.0-preview AS base
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app

FROM mcr.microsoft.com/dotnet/sdk:8.0-preview AS dotnet-build-base
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS dotnet-build-base
WORKDIR /src
RUN printf 'Package: nodejs\nPin: origin deb.nodesource.com\nPin-Priority: 600\n' > /etc/apt/preferences.d/nodesource
RUN apt-get update && apt-get install curl -y \
Expand All @@ -15,13 +15,13 @@ RUN dotnet restore Modix.sln
COPY . .

FROM dotnet-build-base AS dotnet-build
RUN dotnet build -c Release --no-restore Modix.sln
RUN dotnet build -maxcpucount:1 -c Release --no-restore Modix.sln

FROM dotnet-build as dotnet-test
RUN dotnet test -c Release --no-build --no-restore Modix.sln

FROM dotnet-build AS publish
RUN dotnet publish -c Release --no-build --no-restore -o /app Modix/Modix.csproj
RUN dotnet publish -maxcpucount:1 -c Release --no-build --no-restore -o /app Modix/Modix.csproj

FROM base AS final
COPY --from=publish /app .
Expand Down
2 changes: 1 addition & 1 deletion Modix.Bot.Test/Modix.Bot.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Discord.Net" Version="2.4.0" />
<PackageReference Include="Discord.Net" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
<PackageReference Include="NUnit"/>
Expand Down
4 changes: 2 additions & 2 deletions Modix.Data.Test/Assertions/DbContextSequenceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ private static ResettableSequenceValueGenerator<TProperty> GetGetResettableSeque
.GetOrAdd(property, entity, valueGeneratorConstructor);
}

private static readonly Dictionary<Type, Func<IProperty, IEntityType, ValueGenerator>> _valueGeneratorConstructorsByValueType
= new Dictionary<Type, Func<IProperty, IEntityType, ValueGenerator>>()
private static readonly Dictionary<Type, Func<IProperty, ITypeBase, ValueGenerator>> _valueGeneratorConstructorsByValueType
= new Dictionary<Type, Func<IProperty, ITypeBase, ValueGenerator>>()
{
[typeof(long)] = (p, e) => new ResettableInt64SequenceValueGenerator()
};
Expand Down
5 changes: 2 additions & 3 deletions Modix.Data/Models/Core/ModixConfig.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace Modix.Data.Models.Core
namespace Modix.Data.Models.Core
{
public class ModixConfig
{
Expand Down Expand Up @@ -31,5 +29,6 @@ public class ModixConfig
public string WebsiteBaseUrl { get; set; } = "https://mod.gg";

public bool EnableStatsd { get; set; }
public bool UseBlazor { get; set; }
}
}
10 changes: 8 additions & 2 deletions Modix.Data/Models/Moderation/DeletedMessageSearchCriteria.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,16 @@ public static IQueryable<DeletedMessageEntity> FilterBy(this IQueryable<DeletedM
x => ReusableQueries.StringContainsUser.Invoke(x.Author, criteria!.Author!),
!string.IsNullOrWhiteSpace(criteria?.Author))
.FilterBy(
x => x.CreateAction.CreatedById == criteria!.CreatedById,
x => x.Batch == null
? x.CreateAction.CreatedById == criteria!.CreatedById
: x.Batch.CreateAction.CreatedById == criteria!.CreatedById,
criteria?.CreatedById != null)
.FilterBy(
x => ReusableQueries.StringContainsUser.Invoke(x.CreateAction.CreatedBy!, criteria!.CreatedBy!),
x => ReusableQueries.StringContainsUser.Invoke(
x.Batch == null
? x.CreateAction.CreatedBy!
: x.Batch.CreateAction.CreatedBy,
criteria!.CreatedBy!),
!string.IsNullOrWhiteSpace(criteria?.CreatedBy))
.FilterBy(
x => ReusableQueries.DbCaseInsensitiveContains.Invoke(x.Content, criteria!.Content!),
Expand Down
3 changes: 1 addition & 2 deletions Modix.Data/Repositories/DeletedMessageRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,12 @@ public async Task CreateAsync(
public async Task<RecordsPage<DeletedMessageSummary>> SearchSummariesPagedAsync(
DeletedMessageSearchCriteria searchCriteria, IEnumerable<SortingCriteria> sortingCriteria, PagingCriteria pagingCriteria)
{
var sourceQuery = ModixContext.Set<DeletedMessageEntity>().AsNoTracking();
var sourceQuery = ModixContext.Set<DeletedMessageEntity>().AsNoTracking().AsExpandable();

var filteredQuery = sourceQuery
.FilterBy(searchCriteria);

var pagedQuery = filteredQuery
.AsExpandable()
.Select(DeletedMessageSummary.FromEntityProjection)
.SortBy(sortingCriteria, DeletedMessageSummary.SortablePropertyMap)
.OrderThenBy(x => x.MessageId, SortDirection.Ascending)
Expand Down
2 changes: 1 addition & 1 deletion Modix.Services.Test/Modix.Services.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Moq" />
Expand Down
25 changes: 12 additions & 13 deletions Modix.Services/Core/DesignatedChannelService.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;

using Discord;

using Serilog;

using Modix.Data.Models.Core;
using Modix.Data.Repositories;
using System.Threading;
using Serilog;

namespace Modix.Services.Core
{
Expand All @@ -25,7 +22,7 @@ public interface IDesignatedChannelService
/// <param name="channel">The channel to be assigned.</param>
/// <param name="type">The type of designation to be assigned.</param>
/// <returns>A <see cref="Task"/> that will complete when the operation has completed.</returns>
Task AddDesignatedChannelAsync(IGuild guild, IMessageChannel channel, DesignatedChannelType type);
Task<long> AddDesignatedChannelAsync(IGuild guild, IMessageChannel channel, DesignatedChannelType type);

/// <summary>
/// Unassigns a channel's previously given designation, for a given guild.
Expand Down Expand Up @@ -117,7 +114,7 @@ public DesignatedChannelService(IDesignatedChannelMappingRepository designatedCh
}

/// <inheritdoc />
public async Task AddDesignatedChannelAsync(IGuild guild, IMessageChannel logChannel, DesignatedChannelType type)
public async Task<long> AddDesignatedChannelAsync(IGuild guild, IMessageChannel logChannel, DesignatedChannelType type)
{
AuthorizationService.RequireAuthenticatedUser();
AuthorizationService.RequireClaims(AuthorizationClaim.DesignatedChannelMappingCreate);
Expand All @@ -135,7 +132,7 @@ public async Task AddDesignatedChannelAsync(IGuild guild, IMessageChannel logCha
throw new InvalidOperationException($"{logChannel.Name} in {guild.Name} is already assigned to {type}");
}

await DesignatedChannelMappingRepository.CreateAsync(new DesignatedChannelMappingCreationData()
var id = await DesignatedChannelMappingRepository.CreateAsync(new DesignatedChannelMappingCreationData()
{
GuildId = guild.Id,
ChannelId = logChannel.Id,
Expand All @@ -144,6 +141,8 @@ await DesignatedChannelMappingRepository.CreateAsync(new DesignatedChannelMappin
});

transaction.Commit();

return id;
}
}

Expand Down Expand Up @@ -205,11 +204,11 @@ public Task<bool> AnyDesignatedChannelAsync(ulong guildId, DesignatedChannelType
/// <inheritdoc />
public Task<IReadOnlyCollection<ulong>> GetDesignatedChannelIdsAsync(ulong guildId, DesignatedChannelType type)
=> DesignatedChannelMappingRepository.SearchChannelIdsAsync(new DesignatedChannelMappingSearchCriteria()
{
GuildId = guildId,
Type = type,
IsDeleted = false
});
{
GuildId = guildId,
Type = type,
IsDeleted = false
});

/// <inheritdoc />
public async Task<IReadOnlyCollection<IMessageChannel>> GetDesignatedChannelsAsync(IGuild guild, DesignatedChannelType type)
Expand Down
8 changes: 5 additions & 3 deletions Modix.Services/Core/DesignatedRoleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface IDesignatedRoleService
/// <param name="roleId">The Discord snowflake ID of the role being designated</param>
/// <param name="type">The type of designation to be made</param>
/// <returns>A <see cref="Task"/> that will complete when the operation has completed.</returns>
Task AddDesignatedRoleAsync(ulong guildId, ulong roleId, DesignatedRoleType type);
Task<long> AddDesignatedRoleAsync(ulong guildId, ulong roleId, DesignatedRoleType type);

/// <summary>
/// Unassigns a role's previously given designation.
Expand Down Expand Up @@ -95,7 +95,7 @@ public DesignatedRoleService(IAuthorizationService authorizationService, IDesign
}

/// <inheritdoc />
public async Task AddDesignatedRoleAsync(ulong guildId, ulong roleId, DesignatedRoleType type)
public async Task<long> AddDesignatedRoleAsync(ulong guildId, ulong roleId, DesignatedRoleType type)
{
AuthorizationService.RequireAuthenticatedUser();
AuthorizationService.RequireClaims(AuthorizationClaim.DesignatedRoleMappingCreate);
Expand All @@ -111,7 +111,7 @@ public async Task AddDesignatedRoleAsync(ulong guildId, ulong roleId, Designated
}, default))
throw new InvalidOperationException($"Role {roleId} already has a {type} designation");

await DesignatedRoleMappingRepository.CreateAsync(new DesignatedRoleMappingCreationData()
var entityId = await DesignatedRoleMappingRepository.CreateAsync(new DesignatedRoleMappingCreationData()
{
GuildId = guildId,
RoleId = roleId,
Expand All @@ -120,6 +120,8 @@ await DesignatedRoleMappingRepository.CreateAsync(new DesignatedRoleMappingCreat
});

transaction.Commit();

return entityId;
}
}

Expand Down
12 changes: 8 additions & 4 deletions Modix.Services/Promotions/PromotionsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public interface IPromotionsService
/// <param name="sentiment">The <see cref="PromotionCommentEntity.Sentiment"/> value to use for the new comment.</param>
/// <param name="content">The <see cref="PromotionCommentEntity.Content"/> value to use for the new comment.</param>
/// <returns>A <see cref="Task"/> that will complete when the operation has completed.</returns>
Task AddCommentAsync(long campaignId, PromotionSentiment sentiment, string? content);
Task<PromotionActionSummary> AddCommentAsync(long campaignId, PromotionSentiment sentiment, string? content);

/// <summary>
/// Updates an existing comment on a promotion campaign by deleting the comment and adding a new one.
Expand All @@ -59,7 +59,7 @@ public interface IPromotionsService
/// <param name="newSentiment">The <see cref="PromotionCommentEntity.Sentiment"/> value of the updated comment.</param>
/// <param name="newContent">The <see cref="PromotionCommentEntity.Content"/> value of the updated comment.</param>
/// <returns>A <see cref="Task"/> that will complete when the operation has completed.</returns>
Task UpdateCommentAsync(long commentId, PromotionSentiment newSentiment, string? newContent);
Task<PromotionActionSummary> UpdateCommentAsync(long commentId, PromotionSentiment newSentiment, string? newContent);

Task AddOrUpdateCommentAsync(long campaignId, Optional<PromotionSentiment> sentiment, Optional<string?> comment = default);

Expand Down Expand Up @@ -187,7 +187,7 @@ public async Task CreateCampaignAsync(ulong subjectId, string? comment = null)
}

/// <inheritdoc />
public async Task AddCommentAsync(long campaignId, PromotionSentiment sentiment, string? content)
public async Task<PromotionActionSummary> AddCommentAsync(long campaignId, PromotionSentiment sentiment, string? content)
{
AuthorizationService.RequireAuthenticatedGuild();
AuthorizationService.RequireAuthenticatedUser();
Expand Down Expand Up @@ -234,10 +234,12 @@ public async Task AddCommentAsync(long campaignId, PromotionSentiment sentiment,
}

PublishActionNotificationAsync(resultAction);

return resultAction;
}

/// <inheritdoc />
public async Task UpdateCommentAsync(long commentId, PromotionSentiment newSentiment, string? newContent)
public async Task<PromotionActionSummary> UpdateCommentAsync(long commentId, PromotionSentiment newSentiment, string? newContent)
{
AuthorizationService.RequireAuthenticatedUser();
AuthorizationService.RequireClaims(AuthorizationClaim.PromotionsComment);
Expand All @@ -263,6 +265,8 @@ public async Task UpdateCommentAsync(long commentId, PromotionSentiment newSenti
}

PublishActionNotificationAsync(resultAction);

return resultAction;
}

public async Task AddOrUpdateCommentAsync(long campaignId, Optional<PromotionSentiment> sentiment, Optional<string?> content = default)
Expand Down
Loading
Loading