Don't cache avatar_url
This commit is contained in:
parent
946e9f8b84
commit
26c8fd41c0
|
@ -43,7 +43,6 @@ pub async fn irc_loop(
|
||||||
let (send, recv) = unbounded_channel();
|
let (send, recv) = unbounded_channel();
|
||||||
tokio::spawn(msg_task(UnboundedReceiverStream::new(recv)));
|
tokio::spawn(msg_task(UnboundedReceiverStream::new(recv)));
|
||||||
|
|
||||||
let mut avatar_cache: HashMap<String, Option<String>> = HashMap::new();
|
|
||||||
let mut id_cache: HashMap<String, Option<u64>> = HashMap::new();
|
let mut id_cache: HashMap<String, Option<u64>> = HashMap::new();
|
||||||
let mut channel_users: HashMap<String, Vec<String>> = HashMap::new();
|
let mut channel_users: HashMap<String, Vec<String>> = HashMap::new();
|
||||||
|
|
||||||
|
@ -120,18 +119,16 @@ pub async fn irc_loop(
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(webhook) = webhooks.get(channel) {
|
if let Some(webhook) = webhooks.get(channel) {
|
||||||
let avatar = &*avatar_cache.entry(nickname.to_owned()).or_insert_with(|| {
|
let avatar_url = members_lock.iter().find_map(|member| {
|
||||||
members_lock.iter().find_map(|member| {
|
(*member.display_name() == nickname)
|
||||||
(*member.display_name() == nickname)
|
.then(|| member.user.avatar_url())
|
||||||
.then(|| member.user.avatar_url())
|
.flatten()
|
||||||
.flatten()
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
|
||||||
send.send(QueuedMessage::Webhook {
|
send.send(QueuedMessage::Webhook {
|
||||||
webhook: webhook.clone(),
|
webhook: webhook.clone(),
|
||||||
http: http.clone(),
|
http: http.clone(),
|
||||||
avatar_url: avatar.clone(),
|
avatar_url,
|
||||||
content: computed,
|
content: computed,
|
||||||
nickname: nickname.to_string(),
|
nickname: nickname.to_string(),
|
||||||
})?;
|
})?;
|
||||||
|
|
Loading…
Reference in a new issue