feat: split ignores into 'ignore messages' and 'ignore entities'
This commit is contained in:
parent
d48ab7e16e
commit
0cac964aa6
32 changed files with 730 additions and 488 deletions
|
|
@ -53,7 +53,8 @@ public partial class GuildsController
|
|||
|
||||
await guildRepository.ImportConfigAsync(
|
||||
guildId.Value,
|
||||
export.Channels.ToGuildConfig(),
|
||||
export.Channels.ToChannelConfig(),
|
||||
export.Channels.ToMessageConfig(),
|
||||
export.BannedSystems,
|
||||
export.KeyRoles
|
||||
);
|
||||
|
|
@ -91,7 +92,7 @@ public partial class GuildsController
|
|||
|
||||
return new ConfigExport(
|
||||
config.Id,
|
||||
ChannelsBackup.FromGuildConfig(config.Channels),
|
||||
ChannelsBackup.FromGuildConfig(config),
|
||||
config.BannedSystems,
|
||||
config.KeyRoles,
|
||||
invites.Select(i => new InviteExport(i.Code, i.Name)),
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public partial class GuildsController
|
|||
var (guildId, _) = await ParseGuildAsync(id);
|
||||
var guildConfig = await guildRepository.GetAsync(guildId);
|
||||
|
||||
if (guildConfig.Channels.IgnoredChannels.Contains(channelId))
|
||||
if (guildConfig.Messages.IgnoredChannels.Contains(channelId))
|
||||
return NoContent();
|
||||
|
||||
var channel = channelCache
|
||||
|
|
@ -47,8 +47,8 @@ public partial class GuildsController
|
|||
if (channel == null)
|
||||
return NoContent();
|
||||
|
||||
guildConfig.Channels.IgnoredChannels.Add(channelId);
|
||||
await guildRepository.UpdateChannelConfigAsync(guildId, guildConfig.Channels);
|
||||
guildConfig.Messages.IgnoredChannels.Add(channelId);
|
||||
await guildRepository.UpdateChannelConfigAsync(guildId, guildConfig);
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
|
@ -59,8 +59,8 @@ public partial class GuildsController
|
|||
var (guildId, _) = await ParseGuildAsync(id);
|
||||
var guildConfig = await guildRepository.GetAsync(guildId);
|
||||
|
||||
guildConfig.Channels.IgnoredChannels.Remove(channelId);
|
||||
await guildRepository.UpdateChannelConfigAsync(guildId, guildConfig.Channels);
|
||||
guildConfig.Messages.IgnoredChannels.Remove(channelId);
|
||||
await guildRepository.UpdateChannelConfigAsync(guildId, guildConfig);
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public partial class GuildsController
|
|||
);
|
||||
|
||||
guildConfig.Channels.Redirects[source.ID.Value] = target.ID.Value;
|
||||
await guildRepository.UpdateChannelConfigAsync(guildId, guildConfig.Channels);
|
||||
await guildRepository.UpdateChannelConfigAsync(guildId, guildConfig);
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
|
@ -80,7 +80,7 @@ public partial class GuildsController
|
|||
);
|
||||
|
||||
guildConfig.Channels.Redirects.Remove(channelId, out _);
|
||||
await guildRepository.UpdateChannelConfigAsync(guildId, guildConfig.Channels);
|
||||
await guildRepository.UpdateChannelConfigAsync(guildId, guildConfig);
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public partial class GuildsController
|
|||
var guildConfig = await guildRepository.GetAsync(guildId);
|
||||
|
||||
var output = new List<IgnoredUser>();
|
||||
foreach (var userId in guildConfig.Channels.IgnoredUsers)
|
||||
foreach (var userId in guildConfig.Messages.IgnoredUsers)
|
||||
{
|
||||
if (cts.Token.IsCancellationRequested)
|
||||
break;
|
||||
|
|
@ -72,11 +72,11 @@ public partial class GuildsController
|
|||
if (user == null)
|
||||
throw new ApiError(HttpStatusCode.NotFound, ErrorCode.BadRequest, "User not found");
|
||||
|
||||
if (guildConfig.Channels.IgnoredUsers.Contains(user.ID.Value))
|
||||
if (guildConfig.Messages.IgnoredUsers.Contains(user.ID.Value))
|
||||
return Ok(new IgnoredUser(user.ID.Value, user.Tag()));
|
||||
|
||||
guildConfig.Channels.IgnoredUsers.Add(user.ID.Value);
|
||||
await guildRepository.UpdateChannelConfigAsync(guildId, guildConfig.Channels);
|
||||
guildConfig.Messages.IgnoredUsers.Add(user.ID.Value);
|
||||
await guildRepository.UpdateChannelConfigAsync(guildId, guildConfig);
|
||||
|
||||
return Ok(new IgnoredUser(user.ID.Value, user.Tag()));
|
||||
}
|
||||
|
|
@ -87,8 +87,8 @@ public partial class GuildsController
|
|||
var (guildId, _) = await ParseGuildAsync(id);
|
||||
var guildConfig = await guildRepository.GetAsync(guildId);
|
||||
|
||||
guildConfig.Channels.IgnoredUsers.Remove(userId);
|
||||
await guildRepository.UpdateChannelConfigAsync(guildId, guildConfig.Channels);
|
||||
guildConfig.Messages.IgnoredUsers.Remove(userId);
|
||||
await guildRepository.UpdateChannelConfigAsync(guildId, guildConfig);
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,28 +159,6 @@ public partial class GuildsController(
|
|||
.ToList();
|
||||
var guildConfig = await guildRepository.GetAsync(guildId);
|
||||
|
||||
if (req.IgnoredChannels != null)
|
||||
{
|
||||
var categories = channelCache
|
||||
.GuildChannels(guildId)
|
||||
.Where(c => c.Type is ChannelType.GuildCategory)
|
||||
.ToList();
|
||||
|
||||
if (
|
||||
req.IgnoredChannels.Any(cId =>
|
||||
guildChannels.All(c => c.ID.Value != cId)
|
||||
&& categories.All(c => c.ID.Value != cId)
|
||||
)
|
||||
)
|
||||
throw new ApiError(
|
||||
HttpStatusCode.BadRequest,
|
||||
ErrorCode.BadRequest,
|
||||
"One or more ignored channels are unknown"
|
||||
);
|
||||
|
||||
guildConfig.Channels.IgnoredChannels = req.IgnoredChannels.ToList();
|
||||
}
|
||||
|
||||
// i love repeating myself wheeeeee
|
||||
if (
|
||||
req.GuildUpdate == null
|
||||
|
|
@ -334,12 +312,11 @@ public partial class GuildsController(
|
|||
)
|
||||
guildConfig.Channels.MessageDeleteBulk = req.MessageDeleteBulk ?? 0;
|
||||
|
||||
await guildRepository.UpdateChannelConfigAsync(guildId, guildConfig.Channels);
|
||||
await guildRepository.UpdateChannelConfigAsync(guildId, guildConfig);
|
||||
return Ok(guildConfig.Channels);
|
||||
}
|
||||
|
||||
public record ChannelRequest(
|
||||
ulong[]? IgnoredChannels = null,
|
||||
ulong? GuildUpdate = null,
|
||||
ulong? GuildEmojisUpdate = null,
|
||||
ulong? GuildRoleCreate = null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue