summary refs log tree commit diff
path: root/extra/admin-api/Spacebar.AdminApi/Controllers/UserController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'extra/admin-api/Spacebar.AdminApi/Controllers/UserController.cs')
-rw-r--r--extra/admin-api/Spacebar.AdminApi/Controllers/UserController.cs12
1 files changed, 6 insertions, 6 deletions
diff --git a/extra/admin-api/Spacebar.AdminApi/Controllers/UserController.cs b/extra/admin-api/Spacebar.AdminApi/Controllers/UserController.cs

index f1f861d5..5b76c72d 100644 --- a/extra/admin-api/Spacebar.AdminApi/Controllers/UserController.cs +++ b/extra/admin-api/Spacebar.AdminApi/Controllers/UserController.cs
@@ -85,7 +85,7 @@ public class UserController( /// <param name="id">User ID</param> /// <returns>User object</returns> [HttpGet("{id}")] - public async Task<UserModel> GetById(string id) { + public async Task<UserModel> GetById(long id) { (await auth.GetCurrentUserAsync(Request)).GetRights().AssertHasAllRights(SpacebarRights.Rights.OPERATOR); return await db.Users @@ -137,7 +137,7 @@ public class UserController( } [HttpGet("{id}/delete")] - public async IAsyncEnumerable<AsyncActionResult> DeleteUser(string id, [FromQuery] int messageDeleteChunkSize = 100) { + public async IAsyncEnumerable<AsyncActionResult> DeleteUser(long id, [FromQuery] int messageDeleteChunkSize = 100) { (await auth.GetCurrentUserAsync(Request)).GetRights().AssertHasAllRights(SpacebarRights.Rights.OPERATOR); var user = await db.Users.FindAsync(id); @@ -170,11 +170,11 @@ public class UserController( yield return new("STATS", new { total_messages = messages.Count(), total_channels = channels.Count, - messages_per_channel = channels.ToDictionary(c => c.ChannelId, c => messages.Count(m => m.ChannelId == c.ChannelId)) + messages_per_channel = channels.ToDictionary(c => c.ChannelId!, c => messages.Count(m => m.ChannelId == c.ChannelId)) }); if (messages.Any()) { var results = channels - .Select(ctx => DeleteMessagesForChannel(ctx.GuildId, ctx.ChannelId!, id, messageDeleteChunkSize)) + .Select(ctx => DeleteMessagesForChannel(ctx.GuildId, ctx.ChannelId!.Value, id, messageDeleteChunkSize)) .ToList(); var a = AggregateAsyncEnumerablesWithoutOrder(results); await foreach (var result in a) { @@ -195,7 +195,7 @@ public class UserController( private async IAsyncEnumerable<AsyncActionResult> DeleteMessagesForChannel( // context - string? guildId, string channelId, string authorId, + long? guildId, long channelId, long authorId, // options int messageDeleteChunkSize = 100 ) { @@ -205,7 +205,7 @@ public class UserController( var messagesInChannel = _db.Messages.AsNoTracking().Count(m => m.AuthorId == authorId && m.ChannelId == channelId && m.GuildId == guildId); var remaining = messagesInChannel; while (true) { - var messageIds = _db.Database.SqlQuery<string>($""" + var messageIds = _db.Database.SqlQuery<long>($""" DELETE FROM messages WHERE id IN ( SELECT id FROM messages