Breaking change to FriendStatus, user cache sync.

This commit is contained in:
Paul Makles
2020-08-10 22:23:58 +02:00
parent 8cb697dfcd
commit 0b90145b31
6 changed files with 67 additions and 27 deletions

View File

@@ -145,25 +145,17 @@ pub fn process_event(event: &Notification) {
match event {
Notification::group_user_join(ev) => {
let mut cache = CACHE.lock().unwrap();
let entry = cache.pop(&ev.id);
if entry.is_some() {
let mut channel = entry.unwrap();
if let Some(channel) = cache.peek_mut(&ev.id) {
channel.recipients.as_mut().unwrap().push(ev.user.clone());
cache.put(ev.id.clone(), channel);
}
}
Notification::group_user_leave(ev) => {
let mut cache = CACHE.lock().unwrap();
let entry = cache.pop(&ev.id);
if entry.is_some() {
let mut channel = entry.unwrap();
if let Some(channel) = cache.peek_mut(&ev.id) {
let recipients = channel.recipients.as_mut().unwrap();
if let Some(pos) = recipients.iter().position(|x| *x == ev.user) {
recipients.remove(pos);
}
cache.put(ev.id.clone(), channel);
}
}
Notification::guild_channel_create(ev) => {