Compare commits

..

2 Commits

Author SHA1 Message Date
e85a61607e startup hang solved
All checks were successful
gitea.arg.rip/vassago/pipeline/head This commit looks good
🎉
2025-04-24 10:58:01 -04:00
2d50a75f2e something blocks. What, I don't know. 2025-04-23 12:11:48 -04:00
3 changed files with 8 additions and 8 deletions

View File

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

View File

@ -142,8 +142,9 @@ public class TwitchInterface
private Account UpsertAccount(string username, Channel inChannel) private Account UpsertAccount(string username, Channel inChannel)
{ {
var acc = Rememberer.SearchAccount(ui => ui.ExternalId == username && ui.SeenInChannel.ExternalId == inChannel.ToString()); Console.WriteLine($"upserting twitch account. username: {username}. inChannel: {inChannel?.Id}");
Console.WriteLine($"upserting account, retrieved {acc?.Id}."); var acc = Rememberer.SearchAccount(ui => ui.ExternalId == username && ui.SeenInChannel.ExternalId == inChannel.ExternalId);
Console.WriteLine($"upserting twitch account, retrieved {acc?.Id}.");
if (acc != null) if (acc != null)
{ {
Console.WriteLine($"acc's usser: {acc.IsUser?.Id}"); Console.WriteLine($"acc's usser: {acc.IsUser?.Id}");
@ -204,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);
@ -247,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);

View File

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