From c74cc15f8969c8db68119d07a4f273a0d3fc44f4 Mon Sep 17 00:00:00 2001 From: Zeyla Hellyer Date: Sun, 9 Apr 2017 10:44:43 -0700 Subject: Remove support for group calls and guild sync Calls and guild sync are essentially leftovers from selfbot support removal, the former moreso. Removes the following `model::event` structs: - CallCreateEvent - CallDeleteEvent - CallUpdateEvent - GuildSyncEvent which also removes the following `model::event::Event` variants: `client::gateway::Shard::sync_calls` has been removed. The following `client::Client` methods have been removed: - `on_call_create` - `on_call_delete` - `on_call_update` - `on_guild_sync` Removes the following items on `ext::cache::Cache`: ``` ext::cache::Cache::{ // fields calls, // methods get_call, update_with_call_create, update_with_call_delete, update_with_call_update, update_with_guild_sync, } ``` Voice structs and methods now take solely a `guild_id` instead of a `target`, due to the handling of 1-on-1 and group calls being removed. This continues off commit d9118c0. --- src/ext/cache/mod.rs | 103 --------------------------------------------------- 1 file changed, 103 deletions(-) (limited to 'src/ext/cache/mod.rs') diff --git a/src/ext/cache/mod.rs b/src/ext/cache/mod.rs index 7bb9dd8..ee26816 100644 --- a/src/ext/cache/mod.rs +++ b/src/ext/cache/mod.rs @@ -49,7 +49,6 @@ //! while needing to hit the REST API as little as possible, then the answer //! is "yes". //! -//! [`Call`]: ../../model/struct.Call.html //! [`Context`]: ../../client/struct.Context.html //! [`Context::get_channel`]: ../../client/struct.Context.html#method.get_channel //! [`Emoji`]: ../../model/struct.Emoji.html @@ -103,16 +102,6 @@ use ::model::event::*; /// [`rest`]: ../../client/rest/index.html #[derive(Clone, Debug)] pub struct Cache { - /// A map of the currently active calls that the current user knows about, - /// where the key is the Id of the [`PrivateChannel`] or [`Group`] hosting - /// the call. - /// - /// For bot users this will always be empty, except for in [special cases]. - /// - /// [`Group`]: ../../model/struct.Group.html - /// [`PrivateChannel`]: ../../model/struct.PrivateChannel.html - /// [special cases]: index.html#special-cases-in-the-cache - pub calls: HashMap>>, /// A map of channels in [`Guild`]s that the current user has received data /// for. /// @@ -264,16 +253,6 @@ impl Cache { .collect() } - /// Retrieves a reference to a [`Call`] from the cache based on the - /// associated [`Group`]'s channel Id. - /// - /// [`Call`]: ../../model/struct.Call.html - /// [`Group`]: ../../model/struct.Group.html - #[inline] - pub fn get_call>(&self, group_id: C) -> Option>> { - self.calls.get(&group_id.into()).cloned() - } - /// Retrieves a [`Channel`] from the cache based on the given Id. /// /// This will search the [`channels`] map, the [`private_channels`] map, and @@ -464,45 +443,6 @@ impl Cache { self.users.get(&user_id.into()).cloned() } - #[doc(hidden)] - pub fn update_with_call_create(&mut self, event: &CallCreateEvent) { - match self.calls.entry(event.call.channel_id) { - Entry::Vacant(e) => { - e.insert(Arc::new(RwLock::new(event.call.clone()))); - }, - Entry::Occupied(mut e) => { - *e.get_mut() = Arc::new(RwLock::new(event.call.clone())); - }, - } - } - - #[doc(hidden)] - pub fn update_with_call_delete(&mut self, event: &CallDeleteEvent) - -> Option>> { - self.calls.remove(&event.channel_id) - } - - #[doc(hidden)] - pub fn update_with_call_update(&mut self, event: &CallUpdateEvent, old: bool) - -> Option>> { - let item = if old { - self.calls.get(&event.channel_id).cloned() - } else { - None - }; - - self.calls - .get_mut(&event.channel_id) - .map(|call| { - let mut call = call.write().unwrap(); - - call.region.clone_from(&event.region); - call.ringing.clone_from(&event.ringing); - }); - - item - } - #[doc(hidden)] pub fn update_with_channel_create(&mut self, event: &ChannelCreateEvent) -> Option { match event.channel { @@ -832,23 +772,6 @@ impl Cache { }) } - #[doc(hidden)] - pub fn update_with_guild_sync(&mut self, event: &GuildSyncEvent) { - for member in event.members.values() { - self.update_user_entry(&member.user.read().unwrap()); - } - - self.guilds - .get_mut(&event.guild_id) - .map(|guild| { - let mut guild = guild.write().unwrap(); - - guild.large = event.large; - guild.members.clone_from(&event.members); - guild.presences.clone_from(&event.presences); - }); - } - #[doc(hidden)] pub fn update_with_guild_unavailable(&mut self, event: &GuildUnavailableEvent) { self.unavailable_guilds.insert(event.guild_id); @@ -988,31 +911,6 @@ impl Cache { return; } - - if let Some(channel) = event.voice_state.channel_id { - // channel id available, insert voice state - if let Some(call) = self.calls.get_mut(&channel) { - let mut call = call.write().unwrap(); - - { - let finding = call.voice_states - .get_mut(&event.voice_state.user_id); - - if let Some(group_state) = finding { - group_state.clone_from(&event.voice_state); - - return; - } - } - - call.voice_states.insert(event.voice_state.user_id, event.voice_state.clone()); - } - } else { - // delete this user from any group call containing them - for call in self.calls.values_mut() { - call.write().unwrap().voice_states.remove(&event.voice_state.user_id); - } - } } // Adds or updates a user entry in the [`users`] map with a received user. @@ -1033,7 +931,6 @@ impl Cache { impl Default for Cache { fn default() -> Cache { Cache { - calls: HashMap::default(), channels: HashMap::default(), groups: HashMap::default(), guilds: HashMap::default(), -- cgit v1.2.3