mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 04:56:49 +00:00
feat: add abuse handling
This commit is contained in:
parent
4bf60a47d7
commit
2dfb851246
17 changed files with 405 additions and 16 deletions
36
PluralKit.Core/Models/AbuseLog.cs
Normal file
36
PluralKit.Core/Models/AbuseLog.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using NodaTime;
|
||||
|
||||
namespace PluralKit.Core;
|
||||
|
||||
public readonly struct AbuseLogId: INumericId<AbuseLogId, int>
|
||||
{
|
||||
public int Value { get; }
|
||||
|
||||
public AbuseLogId(int value)
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
|
||||
public bool Equals(AbuseLogId other) => Value == other.Value;
|
||||
|
||||
public override bool Equals(object obj) => obj is AbuseLogId other && Equals(other);
|
||||
|
||||
public override int GetHashCode() => Value;
|
||||
|
||||
public static bool operator ==(AbuseLogId left, AbuseLogId right) => left.Equals(right);
|
||||
|
||||
public static bool operator !=(AbuseLogId left, AbuseLogId right) => !left.Equals(right);
|
||||
|
||||
public int CompareTo(AbuseLogId other) => Value.CompareTo(other.Value);
|
||||
|
||||
public override string ToString() => $"AbuseLog #{Value}";
|
||||
}
|
||||
|
||||
public class AbuseLog
|
||||
{
|
||||
public AbuseLogId Id { get; private set; }
|
||||
public Guid Uuid { get; private set; }
|
||||
public string Description { get; private set; }
|
||||
public bool DenyBotUsage { get; private set; }
|
||||
public Instant Created { get; private set; }
|
||||
}
|
||||
16
PluralKit.Core/Models/Patch/AbuseLogPatch.cs
Normal file
16
PluralKit.Core/Models/Patch/AbuseLogPatch.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using SqlKata;
|
||||
|
||||
namespace PluralKit.Core;
|
||||
|
||||
public class AbuseLogPatch: PatchObject
|
||||
{
|
||||
public Partial<string> Description { get; set; }
|
||||
public Partial<bool> DenyBotUsage { get; set; }
|
||||
|
||||
public override Query Apply(Query q) => q.ApplyPatch(wrapper => wrapper
|
||||
.With("description", Description)
|
||||
.With("deny_bot_usage", DenyBotUsage)
|
||||
);
|
||||
}
|
||||
|
|
@ -8,10 +8,12 @@ public class AccountPatch: PatchObject
|
|||
{
|
||||
public Partial<ulong> DmChannel { get; set; }
|
||||
public Partial<bool> AllowAutoproxy { get; set; }
|
||||
public Partial<AbuseLogId?> AbuseLog { get; set; }
|
||||
|
||||
public override Query Apply(Query q) => q.ApplyPatch(wrapper => wrapper
|
||||
.With("dm_channel", DmChannel)
|
||||
.With("allow_autoproxy", AllowAutoproxy)
|
||||
.With("abuse_log", AbuseLog)
|
||||
);
|
||||
|
||||
public JObject ToJson()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue