change how webhook information is in the webhook

This commit is contained in:
Zomatree
2023-04-01 22:49:34 +01:00
parent 01577fd798
commit 7b39f4e9d9
15 changed files with 31 additions and 33 deletions

View File

@@ -428,6 +428,11 @@ impl Channel {
}
}
let (author_id, webhook) = match &author {
MessageAuthor::User(user) => (user.id.clone(), None),
MessageAuthor::Webhook(webhook) => (webhook.id.clone(), Some((*webhook).clone()))
};
// Start constructing the message
let message_id = Ulid::new().to_string();
let mut message = Message {
@@ -435,14 +440,11 @@ impl Channel {
channel: self.id().to_string(),
masquerade: data.masquerade,
interactions: data.interactions.unwrap_or_default(),
author: author_id,
webhook,
..Default::default()
};
match &author {
MessageAuthor::User(user) => message.author = Some(user.id.clone()),
MessageAuthor::Webhook(webhook) => message.webhook = Some(webhook.id.clone()),
}
// Parse mentions in message.
let mut mentions = HashSet::new();
if let Some(content) = &data.content {
@@ -464,7 +466,7 @@ impl Channel {
let message = Ref::from_unchecked(id).as_message(db).await?;
if mention {
mentions.insert(message.author_id().to_owned());
mentions.insert(message.author.to_owned());
}
replies.insert(message.id);