Skip to content

Commit

Permalink
Fixes private channel deletions making serenity panic. (#656)
Browse files Browse the repository at this point in the history
This only happened if the deletion event was sent by serenity,
where it would get a `ChannelDeletionEvent` which it does not
get if the channel is deleted by the user. This was unexpected
and made it hit an `unimplemented!` which panicked it.
  • Loading branch information
Erk- authored and arqunis committed Jul 13, 2019
1 parent abd84c2 commit 67f5e3d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/model/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,17 @@ impl CacheUpdate for ChannelDeleteEvent {

cache.categories.remove(&channel_id);
},
Channel::Private(ref channel) => {
let id = {
channel.read().id
};

cache.private_channels.remove(&id);
},

// We ignore these because the delete event does not fire for these.
Channel::Private(_) | Channel::Group(_)
| Channel::__Nonexhaustive => unreachable!(),
Channel::Group(_) |
Channel::__Nonexhaustive => unreachable!(),
};

// Remove the cached messages for the channel.
Expand Down

0 comments on commit 67f5e3d

Please sign in to comment.