mirror of
https://github.com/spacebarchat/server.git
synced 2026-07-21 04:40:57 +00:00
Update CS models, deps
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user