forked from adam/discord-bot-shtik
startup hang solved
All checks were successful
gitea.arg.rip/vassago/pipeline/head This commit looks good
All checks were successful
gitea.arg.rip/vassago/pipeline/head This commit looks good
🎉
This commit is contained in:
parent
2d50a75f2e
commit
e85a61607e
@ -65,8 +65,7 @@ public class Behaver
|
|||||||
|
|
||||||
internal bool IsSelf(Guid AccountId)
|
internal bool IsSelf(Guid AccountId)
|
||||||
{
|
{
|
||||||
var db = new ChattingContext();
|
var acc = Rememberer.SearchAccount(a => a.Id == AccountId);
|
||||||
var acc = db.Accounts.Find(AccountId);
|
|
||||||
|
|
||||||
return SelfAccounts.Any(acc => acc.Id == AccountId);
|
return SelfAccounts.Any(acc => acc.Id == AccountId);
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ public class TwitchInterface
|
|||||||
private Account UpsertAccount(string username, Channel inChannel)
|
private Account UpsertAccount(string username, Channel inChannel)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"upserting twitch account. username: {username}. inChannel: {inChannel?.Id}");
|
Console.WriteLine($"upserting twitch account. username: {username}. inChannel: {inChannel?.Id}");
|
||||||
var acc = Rememberer.SearchAccount(ui => ui.ExternalId == username && ui.SeenInChannel.ExternalId == inChannel.ExternalId.ToString());
|
var acc = Rememberer.SearchAccount(ui => ui.ExternalId == username && ui.SeenInChannel.ExternalId == inChannel.ExternalId);
|
||||||
Console.WriteLine($"upserting twitch account, retrieved {acc?.Id}.");
|
Console.WriteLine($"upserting twitch account, retrieved {acc?.Id}.");
|
||||||
if (acc != null)
|
if (acc != null)
|
||||||
{
|
{
|
||||||
@ -205,7 +205,7 @@ public class TwitchInterface
|
|||||||
c.SendFile = (f, t) => { throw new InvalidOperationException($"twitch cannot send files"); };
|
c.SendFile = (f, t) => { throw new InvalidOperationException($"twitch cannot send files"); };
|
||||||
c = Rememberer.RememberChannel(c);
|
c = Rememberer.RememberChannel(c);
|
||||||
|
|
||||||
var selfAccountInChannel = c.Users?.FirstOrDefault(a => a.ExternalId == selfAccountInProtocol.ExternalId.ToString());
|
var selfAccountInChannel = c.Users?.FirstOrDefault(a => a.ExternalId == selfAccountInProtocol.ExternalId);
|
||||||
if(selfAccountInChannel == null)
|
if(selfAccountInChannel == null)
|
||||||
{
|
{
|
||||||
selfAccountInChannel = UpsertAccount(selfAccountInProtocol.Username, c);
|
selfAccountInChannel = UpsertAccount(selfAccountInProtocol.Username, c);
|
||||||
@ -248,7 +248,7 @@ Channel c = Rememberer.SearchChannel(ci => ci.ExternalId == $"w_{whisperWith}"
|
|||||||
c.SendFile = (f, t) => { throw new InvalidOperationException($"twitch cannot send files"); };
|
c.SendFile = (f, t) => { throw new InvalidOperationException($"twitch cannot send files"); };
|
||||||
c = Rememberer.RememberChannel(c);
|
c = Rememberer.RememberChannel(c);
|
||||||
|
|
||||||
var selfAccountInChannel = c.Users.FirstOrDefault(a => a.ExternalId == selfAccountInProtocol.ExternalId.ToString());
|
var selfAccountInChannel = c.Users.FirstOrDefault(a => a.ExternalId == selfAccountInProtocol.ExternalId);
|
||||||
if(selfAccountInChannel == null)
|
if(selfAccountInChannel == null)
|
||||||
{
|
{
|
||||||
selfAccountInChannel = UpsertAccount(selfAccountInChannel.Username, c);
|
selfAccountInChannel = UpsertAccount(selfAccountInChannel.Username, c);
|
||||||
|
@ -13,7 +13,7 @@ public static class Rememberer
|
|||||||
{
|
{
|
||||||
Account toReturn;
|
Account toReturn;
|
||||||
dbAccessSemaphore.Wait();
|
dbAccessSemaphore.Wait();
|
||||||
toReturn = db.Accounts.Include(a => a.IsUser).FirstOrDefault(predicate);
|
toReturn = db.Accounts?.Include(a => a.IsUser)?.FirstOrDefault(predicate);
|
||||||
dbAccessSemaphore.Release();
|
dbAccessSemaphore.Release();
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
@ -110,7 +110,7 @@ public static class Rememberer
|
|||||||
dbAccessSemaphore.Wait();
|
dbAccessSemaphore.Wait();
|
||||||
db.Accounts.Remove(toForget);
|
db.Accounts.Remove(toForget);
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
dbAccessSemaphore.Release();
|
dbAccessSemaphore.Release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void ForgetChannel(Channel toForget)
|
public static void ForgetChannel(Channel toForget)
|
||||||
|
Loading…
Reference in New Issue
Block a user