diff --git a/extra/admin-api/Spacebar.AdminApi/Controllers/ChannelController.cs b/extra/admin-api/Spacebar.AdminApi/Controllers/ChannelController.cs
index cccc4760..f46443c8 100644
--- a/extra/admin-api/Spacebar.AdminApi/Controllers/ChannelController.cs
+++ b/extra/admin-api/Spacebar.AdminApi/Controllers/ChannelController.cs
@@ -20,7 +20,7 @@ public class ChannelController(
ISpacebarReplication replication
) : ControllerBase {
[HttpDelete("{id}")]
- public async Task DeleteById(string id) {
+ public async Task DeleteById(long id) {
(await auth.GetCurrentUserAsync(Request)).GetRights().AssertHasAllRights(SpacebarRights.Rights.OPERATOR);
// TODO: proper type
await replication.SendAsync<Channel>(new() {
@@ -35,7 +35,7 @@ public class ChannelController(
private async IAsyncEnumerable<AsyncActionResult> DeleteMessagesForChannel(
// context
- string? guildId, string channelId, string authorId,
+ long? guildId, long channelId, long authorId,
// options
int messageDeleteChunkSize = 100
) {
@@ -45,7 +45,7 @@ public class ChannelController(
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
@@ -67,7 +67,7 @@ public class ChannelController(
ChannelId = channelId,
MessageIds = messageIds,
},
- Origin = "Admin API (GuildController.DeleteUser)",
+ Origin = "Admin API (ChannelController.DeleteMessagesForChannel)",
});
yield return new("BULK_DELETED", new {
diff --git a/extra/admin-api/Spacebar.AdminApi/Controllers/ConfigController.cs b/extra/admin-api/Spacebar.AdminApi/Controllers/ConfigController.cs
index fdd45f15..b9be35a1 100644
--- a/extra/admin-api/Spacebar.AdminApi/Controllers/ConfigController.cs
+++ b/extra/admin-api/Spacebar.AdminApi/Controllers/ConfigController.cs
@@ -48,7 +48,7 @@ public class ConfigController(ILogger<ConfigController> logger, SpacebarDbContex
await Task.WhenAll(tasks);
await replication.SendAsync(new() {
Event = "SB_RELOAD_CONFIG",
- GuildId = "0",
+ GuildId = 0,
Origin = "Admin API (POST /Configuration)",
});
@@ -61,7 +61,7 @@ public class ConfigController(ILogger<ConfigController> logger, SpacebarDbContex
await replication.SendAsync(new() {
Event = "SB_RELOAD_CONFIG",
- GuildId = "0",
+ GuildId = 0,
Origin = "Admin API (POST /Configuration/ReloadConfig)",
});
diff --git a/extra/admin-api/Spacebar.AdminApi/Controllers/DiscoveryController.cs b/extra/admin-api/Spacebar.AdminApi/Controllers/DiscoveryController.cs
index b914abef..acc27c20 100644
--- a/extra/admin-api/Spacebar.AdminApi/Controllers/DiscoveryController.cs
+++ b/extra/admin-api/Spacebar.AdminApi/Controllers/DiscoveryController.cs
@@ -75,7 +75,7 @@ public class GuildDiscoveryController(
}
[HttpGet("{guildId}")]
- public async Task<DiscoverableGuildModel> GetDiscoverableGuild(string guildId, bool includeExcluded = false) {
+ public async Task<DiscoverableGuildModel> GetDiscoverableGuild(long guildId, bool includeExcluded = false) {
(await auth.GetCurrentUserAsync(Request)).GetRights().AssertHasAllRights(SpacebarRights.Rights.OPERATOR);
var discoverableGuilds = db.Guilds
.AsNoTracking()
@@ -131,7 +131,7 @@ public class GuildDiscoveryController(
}
[HttpPatch("{guildId}")]
- public async Task<DiscoverableGuildModel> UpdateDiscoverableGuild(string guildId, [FromBody] DiscoverableGuildUpdateModel guildUpdateModel, bool includeExcluded = false) {
+ public async Task<DiscoverableGuildModel> UpdateDiscoverableGuild(long guildId, [FromBody] DiscoverableGuildUpdateModel guildUpdateModel, bool includeExcluded = false) {
(await auth.GetCurrentUserAsync(Request)).GetRights().AssertHasAllRights(SpacebarRights.Rights.OPERATOR);
var guild = await db.Guilds
.AsNoTracking()
diff --git a/extra/admin-api/Spacebar.AdminApi/Controllers/GuildController.cs b/extra/admin-api/Spacebar.AdminApi/Controllers/GuildController.cs
index 38d8b3c2..3313fc0e 100644
--- a/extra/admin-api/Spacebar.AdminApi/Controllers/GuildController.cs
+++ b/extra/admin-api/Spacebar.AdminApi/Controllers/GuildController.cs
@@ -80,7 +80,7 @@ public class GuildController(
}
[HttpPost("{id}/force_join")]
- public async Task<IActionResult> ForceJoinGuild([FromBody] ForceJoinRequest request, string id) {
+ public async Task<IActionResult> ForceJoinGuild([FromBody] ForceJoinRequest request, long id) {
(await auth.GetCurrentUserAsync(Request)).GetRights().AssertHasAllRights(SpacebarRights.Rights.OPERATOR);
var guild = await db.Guilds.FindAsync(id);
@@ -125,7 +125,7 @@ public class GuildController(
var adminRole = roles.FirstOrDefault(r => r.Permissions == "8" || r.Permissions == "9"); // Administrator
if (adminRole == null) {
adminRole = new Role {
- Id = Guid.NewGuid().ToString(),
+ Id = Random.Shared.NextInt64(), // TODO: snowflakes
GuildId = id,
Name = "Instance administrator",
Color = 0,
@@ -152,7 +152,7 @@ public class GuildController(
}
[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);
@@ -182,7 +182,7 @@ public class GuildController(
messages_per_channel = channels.ToDictionary(c => c.ChannelId, c => messages.Count(m => m.ChannelId == c.ChannelId))
});
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 GuildController(
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 GuildController(
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
diff --git a/extra/admin-api/Spacebar.AdminApi/Controllers/Media/UserMediaController.cs b/extra/admin-api/Spacebar.AdminApi/Controllers/Media/UserMediaController.cs
index 01104f9d..84d2a6a1 100644
--- a/extra/admin-api/Spacebar.AdminApi/Controllers/Media/UserMediaController.cs
+++ b/extra/admin-api/Spacebar.AdminApi/Controllers/Media/UserMediaController.cs
@@ -12,7 +12,7 @@ namespace Spacebar.AdminApi.Controllers.Media;
[Route("/media/user")]
public class UserMediaController(ILogger<UserMediaController> logger, SpacebarDbContext db, SpacebarAspNetAuthenticationService auth, IServiceProvider sp) : ControllerBase {
[HttpGet("{userId}/attachments")]
- public async IAsyncEnumerable<Attachment> GetAttachmentsByUser(string userId) {
+ public async IAsyncEnumerable<Attachment> GetAttachmentsByUser(long userId) {
(await auth.GetCurrentUserAsync(Request)).GetRights().AssertHasAllRights(SpacebarRights.Rights.OPERATOR);
var db2 = sp.CreateScope().ServiceProvider.GetService<SpacebarDbContext>();
diff --git a/extra/admin-api/Spacebar.AdminApi/Controllers/TestControllers/IpcTestController.cs b/extra/admin-api/Spacebar.AdminApi/Controllers/TestControllers/IpcTestController.cs
index 6881e1e3..cd1dae62 100644
--- a/extra/admin-api/Spacebar.AdminApi/Controllers/TestControllers/IpcTestController.cs
+++ b/extra/admin-api/Spacebar.AdminApi/Controllers/TestControllers/IpcTestController.cs
@@ -23,7 +23,7 @@ public class IpcTestController(
public async IAsyncEnumerable<string> Test() {
(await auth.GetCurrentUserAsync(Request)).GetRights().AssertHasAllRights(SpacebarRights.Rights.OPERATOR);
- var guildId = "1006649183970562092";
+ var guildId = 1006649183970562092;
// var roleId = "1006706520514028812"; //Administrator
var roleId = "1391303296148639051"; //Spacebar Maintainer
// int color = 16711680; //Administrator
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
|