messages can be replied to with internalAPI
All checks were successful
gitea.arg.rip/vassago/pipeline/head This commit looks good

and, they save correctly. which is why they weren't getting guids :face_palm:

see #25
This commit is contained in:
adam 2025-05-29 13:26:17 -04:00
parent 7c7793f3b2
commit 8cc6c00db3
2 changed files with 12 additions and 7 deletions

View File

@ -208,8 +208,6 @@ public class DiscordInterface : ProtocolInterface
var m = Rememberer.SearchMessage(mi => mi.ExternalId == dMessage.Id.ToString() && mi.Protocol == Protocol)
?? new()
{
//I don't understand why messages need to have their Ids specified but no other entity does. shrug dot emoji
Id = Guid.NewGuid(),
Protocol = Protocol
};
@ -226,7 +224,6 @@ public class DiscordInterface : ProtocolInterface
m.Timestamp = dMessage.EditedTimestamp ?? dMessage.CreatedAt;
m.Channel = UpsertChannel(dMessage.Channel);
m.Author = UpsertAccount(dMessage.Author, m.Channel);
Console.WriteLine($"received message; author: {m.Author.DisplayName}, {m.Author.Id}");
if (dMessage.Channel is IGuildChannel)
{
m.Author.DisplayName = (dMessage.Author as IGuildUser).DisplayName;//discord forgot how display names work.
@ -235,6 +232,7 @@ public class DiscordInterface : ProtocolInterface
&& (dMessage.MentionedUserIds?.FirstOrDefault(muid => muid == client.CurrentUser.Id) > 0));
Rememberer.RememberMessage(m);
Console.WriteLine($"received message; author: {m.Author.DisplayName}, {m.Author.Id}. messageid:{m.Id}");
return m;
}
internal Channel UpsertChannel(IMessageChannel channel)

View File

@ -84,8 +84,15 @@ public static class Rememberer
public static void RememberMessage(Message toRemember)
{
dbAccessSemaphore.Wait();
toRemember.Channel ??= new() { Messages = [toRemember] };
db.Update(toRemember.Channel);
toRemember.Channel ??= new();
toRemember.Channel.Messages ??= [];
if (!toRemember.Channel.Messages.Contains(toRemember))
{
toRemember.Channel.Messages.Add(toRemember);
db.Update(toRemember.Channel);
// db.SaveChanges();
}
db.Update(toRemember);
db.SaveChanges();
dbAccessSemaphore.Release();
}
@ -129,9 +136,9 @@ public static class Rememberer
ForgetChannel(childChannel);
}
}
if(toForget.Users?.Count > 0)
if (toForget.Users?.Count > 0)
{
foreach(var account in toForget.Users.ToList())
foreach (var account in toForget.Users.ToList())
{
ForgetAccount(account);
}