mirror of
https://github.com/Jetsparrow/jetherald.git
synced 2026-01-21 07:56:09 +03:00
Fix infos
This commit is contained in:
parent
7785fe1766
commit
54c126353a
@ -8,7 +8,7 @@ namespace JetHerald.Commands
|
|||||||
{
|
{
|
||||||
public class CreateTopicCommand : IChatCommand
|
public class CreateTopicCommand : IChatCommand
|
||||||
{
|
{
|
||||||
Db db;
|
readonly Db db;
|
||||||
|
|
||||||
public CreateTopicCommand(Db db)
|
public CreateTopicCommand(Db db)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace JetHerald.Commands
|
|||||||
{
|
{
|
||||||
public class DeleteTopicCommand : IChatCommand
|
public class DeleteTopicCommand : IChatCommand
|
||||||
{
|
{
|
||||||
Db db;
|
readonly Db db;
|
||||||
|
|
||||||
public DeleteTopicCommand(Db db)
|
public DeleteTopicCommand(Db db)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,7 +6,7 @@ namespace JetHerald
|
|||||||
{
|
{
|
||||||
public class ListCommand : IChatCommand
|
public class ListCommand : IChatCommand
|
||||||
{
|
{
|
||||||
Db db;
|
readonly Db db;
|
||||||
|
|
||||||
public ListCommand(Db db)
|
public ListCommand(Db db)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,7 +5,7 @@ namespace JetHerald
|
|||||||
{
|
{
|
||||||
public class SubscribeCommand : IChatCommand
|
public class SubscribeCommand : IChatCommand
|
||||||
{
|
{
|
||||||
Db db;
|
readonly Db db;
|
||||||
|
|
||||||
public SubscribeCommand(Db db)
|
public SubscribeCommand(Db db)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -5,7 +5,7 @@ namespace JetHerald
|
|||||||
{
|
{
|
||||||
public class UnsubscribeCommand : IChatCommand
|
public class UnsubscribeCommand : IChatCommand
|
||||||
{
|
{
|
||||||
Db db;
|
readonly Db db;
|
||||||
|
|
||||||
public UnsubscribeCommand(Db db)
|
public UnsubscribeCommand(Db db)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -19,7 +19,7 @@ namespace JetHerald
|
|||||||
class NamespacedIdHandler : SqlMapper.TypeHandler<NamespacedId>
|
class NamespacedIdHandler : SqlMapper.TypeHandler<NamespacedId>
|
||||||
{
|
{
|
||||||
public override void SetValue(IDbDataParameter parameter, NamespacedId value) => parameter.Value = value.ToString();
|
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,19 +40,17 @@ namespace JetHerald
|
|||||||
|
|
||||||
public async Task<int> DeleteTopic(string name, string adminToken)
|
public async Task<int> DeleteTopic(string name, string adminToken)
|
||||||
{
|
{
|
||||||
using (var c = GetConnection())
|
using var c = GetConnection();
|
||||||
{
|
|
||||||
return await c.ExecuteAsync(
|
return await c.ExecuteAsync(
|
||||||
" DELETE" +
|
" DELETE" +
|
||||||
" FROM topic" +
|
" FROM topic" +
|
||||||
" WHERE Name = @name AND AdminToken = @adminToken",
|
" WHERE Name = @name AND AdminToken = @adminToken",
|
||||||
new { name, adminToken });
|
new { name, adminToken });
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<Topic> GetTopic(string name)
|
public async Task<Topic> GetTopic(string name)
|
||||||
{
|
{
|
||||||
using (var c = GetConnection())
|
using var c = GetConnection();
|
||||||
return await c.QuerySingleOrDefaultAsync<Topic>(
|
return await c.QuerySingleOrDefaultAsync<Topic>(
|
||||||
"SELECT *" +
|
"SELECT *" +
|
||||||
" FROM topic" +
|
" FROM topic" +
|
||||||
@ -171,6 +169,6 @@ namespace JetHerald
|
|||||||
}
|
}
|
||||||
|
|
||||||
Options.ConnectionStrings Config { get; }
|
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)
|
public static NamespacedId Telegram(long id)
|
||||||
=> new NamespacedId("telegram", $"{id}");
|
=> new("telegram", $"{id}");
|
||||||
|
|
||||||
public static NamespacedId Discord(ulong id)
|
public static NamespacedId Discord(ulong id)
|
||||||
=> new NamespacedId("discord", $"{id}");
|
=> new("discord", $"{id}");
|
||||||
|
|
||||||
public override string ToString() => $"{Namespace}://{Id}";
|
public override string ToString() => $"{Namespace}://{Id}";
|
||||||
|
|
||||||
|
|||||||
@ -5,9 +5,9 @@ namespace JetHerald
|
|||||||
{
|
{
|
||||||
public static class TokenHelper
|
public static class TokenHelper
|
||||||
{
|
{
|
||||||
static RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
|
static readonly RNGCryptoServiceProvider rng = new();
|
||||||
static byte[] buf = new byte[24];
|
static readonly byte[] buf = new byte[24];
|
||||||
static readonly object SyncLock = new object();
|
static readonly object SyncLock = new();
|
||||||
|
|
||||||
public static string GetToken()
|
public static string GetToken()
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user