- .logignore now supports targeting channels and users

- .logignore now lists all ignored channels and users when no parameter is provided
- Renamed and cleaned up some log-related fields
This commit is contained in:
Kwoth
2021-09-21 22:39:06 +02:00
parent 611817f78a
commit c9e89e1911
13 changed files with 2882 additions and 120 deletions

View File

@@ -117,7 +117,7 @@ namespace NadekoBot.Db
{
var logSetting = ctx.LogSettings
.AsQueryable()
.Include(x => x.IgnoredChannels)
.Include(x => x.LogIgnores)
.Where(x => x.GuildId == guildId)
.FirstOrDefault();

View File

@@ -1,8 +0,0 @@
namespace NadekoBot.Services.Database.Models
{
public class IgnoredLogChannel : DbEntity
{
public LogSetting LogSetting { get; set; }
public ulong ChannelId { get; set; }
}
}

View File

@@ -0,0 +1,15 @@
namespace NadekoBot.Services.Database.Models
{
public class IgnoredLogItem : DbEntity
{
public LogSetting LogSetting { get; set; }
public ulong LogItemId { get; set; }
public IgnoredItemType ItemType { get; set; }
}
public enum IgnoredItemType
{
Channel,
User,
}
}

View File

@@ -4,8 +4,7 @@ namespace NadekoBot.Services.Database.Models
{
public class LogSetting : DbEntity
{
public HashSet<IgnoredLogChannel> IgnoredChannels { get; set; } = new HashSet<IgnoredLogChannel>();
public HashSet<IgnoredVoicePresenceChannel> IgnoredVoicePresenceChannelIds { get; set; } = new HashSet<IgnoredVoicePresenceChannel>();
public List<IgnoredLogItem> LogIgnores { get; set; } = new List<IgnoredLogItem>();
public ulong GuildId { get; set; }
public ulong? LogOtherId { get; set; }

View File

@@ -42,8 +42,8 @@ namespace NadekoBot.Services.Database
//logging
public DbSet<LogSetting> LogSettings { get; set; }
public DbSet<IgnoredLogChannel> IgnoredLogChannels { get; set; }
public DbSet<IgnoredVoicePresenceChannel> IgnoredVoicePresenceCHannels { get; set; }
public DbSet<IgnoredLogItem> IgnoredLogChannels { get; set; }
public DbSet<RotatingPlayingStatus> RotatingStatus { get; set; }
public DbSet<BlacklistEntry> Blacklist { get; set; }
@@ -342,6 +342,15 @@ namespace NadekoBot.Services.Database
modelBuilder.Entity<LogSetting>(ls => ls
.HasIndex(x => x.GuildId)
.IsUnique());
modelBuilder.Entity<LogSetting>(ls => ls
.HasMany(x => x.LogIgnores)
.WithOne(x => x.LogSetting)
.OnDelete(DeleteBehavior.Cascade));
modelBuilder.Entity<IgnoredLogItem>(ili => ili
.HasIndex(x => new { ItemId = x.LogItemId, x.ItemType })
.IsUnique());
#endregion