Compare commits

..

No commits in common. "e85a61607e5fd5f37dcab5cbd324a45aeec48664" and "be9436676305baa7377fa099e405fece8342b7ae" have entirely different histories.

3 changed files with 8 additions and 8 deletions

View File

@ -65,7 +65,8 @@ public class Behaver
internal bool IsSelf(Guid AccountId) internal bool IsSelf(Guid AccountId)
{ {
var acc = Rememberer.SearchAccount(a => a.Id == AccountId); var db = new ChattingContext();
var acc = db.Accounts.Find(AccountId);
return SelfAccounts.Any(acc => acc.Id == AccountId); return SelfAccounts.Any(acc => acc.Id == AccountId);
} }

View File

@ -142,9 +142,8 @@ 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}"); var acc = Rememberer.SearchAccount(ui => ui.ExternalId == username && ui.SeenInChannel.ExternalId == inChannel.ToString());
var acc = Rememberer.SearchAccount(ui => ui.ExternalId == username && ui.SeenInChannel.ExternalId == inChannel.ExternalId); Console.WriteLine($"upserting account, retrieved {acc?.Id}.");
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}");
@ -205,7 +204,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); var selfAccountInChannel = c.Users?.FirstOrDefault(a => a.ExternalId == selfAccountInProtocol.ExternalId.ToString());
if(selfAccountInChannel == null) if(selfAccountInChannel == null)
{ {
selfAccountInChannel = UpsertAccount(selfAccountInProtocol.Username, c); selfAccountInChannel = UpsertAccount(selfAccountInProtocol.Username, c);
@ -248,7 +247,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); var selfAccountInChannel = c.Users.FirstOrDefault(a => a.ExternalId == selfAccountInProtocol.ExternalId.ToString());
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)