mirror of
https://github.com/Jetsparrow/jetherald.git
synced 2026-01-20 23:56:08 +03:00
Fix infos
This commit is contained in:
parent
7785fe1766
commit
54c126353a
@ -8,7 +8,7 @@ namespace JetHerald.Commands
|
||||
{
|
||||
public class CreateTopicCommand : IChatCommand
|
||||
{
|
||||
Db db;
|
||||
readonly Db db;
|
||||
|
||||
public CreateTopicCommand(Db db)
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@ namespace JetHerald.Commands
|
||||
{
|
||||
public class DeleteTopicCommand : IChatCommand
|
||||
{
|
||||
Db db;
|
||||
readonly Db db;
|
||||
|
||||
public DeleteTopicCommand(Db db)
|
||||
{
|
||||
|
||||
@ -6,7 +6,7 @@ namespace JetHerald
|
||||
{
|
||||
public class ListCommand : IChatCommand
|
||||
{
|
||||
Db db;
|
||||
readonly Db db;
|
||||
|
||||
public ListCommand(Db db)
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@ namespace JetHerald
|
||||
{
|
||||
public class SubscribeCommand : IChatCommand
|
||||
{
|
||||
Db db;
|
||||
readonly Db db;
|
||||
|
||||
public SubscribeCommand(Db db)
|
||||
{
|
||||
|
||||
@ -5,7 +5,7 @@ namespace JetHerald
|
||||
{
|
||||
public class UnsubscribeCommand : IChatCommand
|
||||
{
|
||||
Db db;
|
||||
readonly Db db;
|
||||
|
||||
public UnsubscribeCommand(Db db)
|
||||
{
|
||||
|
||||
@ -19,7 +19,7 @@ namespace JetHerald
|
||||
class NamespacedIdHandler : SqlMapper.TypeHandler<NamespacedId>
|
||||
{
|
||||
public override void SetValue(IDbDataParameter parameter, NamespacedId value) => parameter.Value = value.ToString();
|
||||
public override NamespacedId Parse(object value) => new NamespacedId((string)value);
|
||||
public override NamespacedId Parse(object value) => new((string)value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -40,24 +40,22 @@ namespace JetHerald
|
||||
|
||||
public async Task<int> DeleteTopic(string name, string adminToken)
|
||||
{
|
||||
using (var c = GetConnection())
|
||||
{
|
||||
return await c.ExecuteAsync(
|
||||
" DELETE" +
|
||||
" FROM topic" +
|
||||
" WHERE Name = @name AND AdminToken = @adminToken",
|
||||
new { name, adminToken });
|
||||
}
|
||||
using var c = GetConnection();
|
||||
return await c.ExecuteAsync(
|
||||
" DELETE" +
|
||||
" FROM topic" +
|
||||
" WHERE Name = @name AND AdminToken = @adminToken",
|
||||
new { name, adminToken });
|
||||
}
|
||||
|
||||
public async Task<Topic> GetTopic(string name)
|
||||
{
|
||||
using (var c = GetConnection())
|
||||
return await c.QuerySingleOrDefaultAsync<Topic>(
|
||||
"SELECT *" +
|
||||
" FROM topic" +
|
||||
" WHERE Name = @name",
|
||||
new { name });
|
||||
using var c = GetConnection();
|
||||
return await c.QuerySingleOrDefaultAsync<Topic>(
|
||||
"SELECT *" +
|
||||
" FROM topic" +
|
||||
" WHERE Name = @name",
|
||||
new { name });
|
||||
}
|
||||
|
||||
public async Task<Topic> GetTopicForSub(string token, NamespacedId chat)
|
||||
@ -147,7 +145,7 @@ namespace JetHerald
|
||||
ON DUPLICATE KEY UPDATE
|
||||
ExpiryTime = CURRENT_TIMESTAMP() + INTERVAL @timeoutSeconds SECOND;
|
||||
",
|
||||
new { topicId, heart, @timeoutSeconds});
|
||||
new { topicId, heart, @timeoutSeconds });
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<HeartAttack>> ProcessHeartAttacks()
|
||||
@ -159,7 +157,7 @@ namespace JetHerald
|
||||
public async Task MarkHeartAttackReported(ulong id, byte status = 1)
|
||||
{
|
||||
using var c = GetConnection();
|
||||
await c.ExecuteAsync("UPDATE heartattack SET Status = @status WHERE HeartattackId = @id", new {id, status});
|
||||
await c.ExecuteAsync("UPDATE heartattack SET Status = @status WHERE HeartattackId = @id", new { id, status });
|
||||
}
|
||||
|
||||
|
||||
@ -171,6 +169,6 @@ namespace JetHerald
|
||||
}
|
||||
|
||||
Options.ConnectionStrings Config { get; }
|
||||
MySqlConnection GetConnection() => new MySqlConnection(Config.DefaultConnection);
|
||||
MySqlConnection GetConnection() => new(Config.DefaultConnection);
|
||||
}
|
||||
}
|
||||
|
||||
@ -22,10 +22,10 @@ namespace JetHerald
|
||||
}
|
||||
|
||||
public static NamespacedId Telegram(long id)
|
||||
=> new NamespacedId("telegram", $"{id}");
|
||||
=> new("telegram", $"{id}");
|
||||
|
||||
public static NamespacedId Discord(ulong id)
|
||||
=> new NamespacedId("discord", $"{id}");
|
||||
=> new("discord", $"{id}");
|
||||
|
||||
public override string ToString() => $"{Namespace}://{Id}";
|
||||
|
||||
@ -34,7 +34,7 @@ namespace JetHerald
|
||||
public override bool Equals(object obj)
|
||||
=> obj is NamespacedId nsid && this == nsid;
|
||||
|
||||
public static bool operator == (NamespacedId a, NamespacedId b)
|
||||
public static bool operator ==(NamespacedId a, NamespacedId b)
|
||||
=> a.Namespace == b.Namespace && a.Id == b.Id;
|
||||
|
||||
public static bool operator !=(NamespacedId a, NamespacedId b)
|
||||
|
||||
@ -5,9 +5,9 @@ namespace JetHerald
|
||||
{
|
||||
public static class TokenHelper
|
||||
{
|
||||
static RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
|
||||
static byte[] buf = new byte[24];
|
||||
static readonly object SyncLock = new object();
|
||||
static readonly RNGCryptoServiceProvider rng = new();
|
||||
static readonly byte[] buf = new byte[24];
|
||||
static readonly object SyncLock = new();
|
||||
|
||||
public static string GetToken()
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user