Compare commits

..

2 Commits

Author SHA1 Message Date
d2aa1f46cc debug statement cleanup
All checks were successful
greyn/vassago/pipeline/head This commit looks good
2023-06-05 15:45:08 -04:00
51fba995c3 log attachments 2023-06-05 15:25:43 -04:00
3 changed files with 17 additions and 34 deletions

View File

@ -94,11 +94,11 @@ public class DiscordInterface
m.MentionsMe = true;
}
if((suMessage.Author.Id != client.CurrentUser.Id)){
if ((suMessage.Author.Id != client.CurrentUser.Id))
{
if (await thingmanagementdoer.Instance.ActOn(m))
{
m.ActedOn = true;
Console.WriteLine("survived a savechanges: 103");
}
}
_db.SaveChanges();
@ -120,7 +120,6 @@ public class DiscordInterface
// seenIn.Add(defaultChannel);
// u.SeenInChannels = seenIn;
// _db.SaveChanges();
Console.WriteLine("survived a savechanges: 123");
// }
return thingmanagementdoer.Instance.OnJoin(u, defaultChannel);
@ -171,20 +170,25 @@ public class DiscordInterface
internal vassago.Models.Attachment UpsertAttachment(IAttachment dAttachment)
{
var addPlease = false;
var a = _db.Attachments.FirstOrDefault(ai => ai.ExternalId == dAttachment.Id);
if (a == null)
{
var creating = _db.Attachments.Add(new vassago.Models.Attachment());
a = creating.Entity;
addPlease = true;
a = new vassago.Models.Attachment();
}
a.ContentType = dAttachment.ContentType;
a.Description = dAttachment.Description;
a.Filename = dAttachment.Filename;
a.Size = dAttachment.Size;
a.Source = new Uri(dAttachment.Url);
if (addPlease)
{
_db.Attachments.Add(a);
}
return a;
}
internal Message UpsertMessage(IUserMessage dMessage)
{
var addPlease = false;
@ -194,12 +198,7 @@ public class DiscordInterface
addPlease = true;
m = new Message();
}
if (m == null)
{
var creating = _db.Messages.Add(new Message() { Author = null, Channel = null });
m = creating.Entity;
}
m.Attachments = m.Attachments ?? new List<vassago.Models.Attachment>();
if (dMessage.Attachments?.Any() == true)
{
m.Attachments = new List<vassago.Models.Attachment>();
@ -208,12 +207,10 @@ public class DiscordInterface
m.Attachments.Add(UpsertAttachment(da));
}
}
//m.Attachments = new List<
m.Author = UpsertUser(dMessage.Author);
m.Channel = UpsertChannel(dMessage.Channel);
m.Content = dMessage.Content;
m.ExternalId = dMessage.Id;
//m.ExternalRepresentation
m.Timestamp = dMessage.EditedTimestamp ?? dMessage.CreatedAt;
if (dMessage.MentionedUserIds?.FirstOrDefault(muid => muid == client.CurrentUser.Id) != null)

View File

@ -47,7 +47,6 @@ namespace vassago.DiscordInterface
{
Console.WriteLine($"deleting command {existingCommand.Name} - (created at {existingCommand.CreatedAt}, it's in guild {existingCommand.Guild?.Id} while I'm in {guild?.Id})");
await existingCommand.DeleteAsync();
Console.WriteLine("survived");
}
else
{
@ -56,7 +55,6 @@ namespace vassago.DiscordInterface
{
Console.WriteLine($"overwriting command {existingCommand.Name}");
await myVersion.register(false, client, guild);
Console.WriteLine($"survived");
}
myVersion.alreadyRegistered = true;
}
@ -65,7 +63,6 @@ namespace vassago.DiscordInterface
{
Console.WriteLine($"creating new command {remaining.Id} ({(remaining.guild == null ? "global" : $"for guild {remaining.guild}")})");
await remaining.register(true, client, guild);
Console.WriteLine($"survived");
}
}

View File

@ -14,15 +14,4 @@ public class User //more like "user's account - no concept of the person outside
public bool IsBot { get; set; } //webhook counts
public Channel SeenInChannel { get; set; }
public string Protocol { get; set; }
public User(){}
public User(User u)
{
Type t = typeof(User);
PropertyInfo[] properties = t.GetProperties();
foreach (PropertyInfo pi in properties)
{
pi.SetValue(this, pi.GetValue(u, null), null);
}
}
}