Fix infos

This commit is contained in:
Basique Evangelist 2021-04-27 23:40:33 +03:00
parent 7785fe1766
commit 54c126353a
9 changed files with 29 additions and 31 deletions

View File

@ -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)
{ {

View File

@ -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)
{ {

View File

@ -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)
{ {

View File

@ -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)
{ {

View File

@ -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)
{ {

View File

@ -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);
} }
} }
} }

View File

@ -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);
} }
} }

View File

@ -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}";

View File

@ -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()
{ {