aboutsummaryrefslogtreecommitdiff
path: root/src/client
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-04-09 10:44:43 -0700
committerZeyla Hellyer <[email protected]>2017-04-09 10:44:43 -0700
commitc74cc15f8969c8db68119d07a4f273a0d3fc44f4 (patch)
treea37a4989a4af4b6d78fe1d40a62a329ae336578c /src/client
parentRemove selfbot support (diff)
downloadserenity-c74cc15f8969c8db68119d07a4f273a0d3fc44f4.tar.xz
serenity-c74cc15f8969c8db68119d07a4f273a0d3fc44f4.zip
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.<Paste>
Diffstat (limited to 'src/client')
-rw-r--r--src/client/dispatch.rs57
-rw-r--r--src/client/event_store.rs24
-rw-r--r--src/client/gateway/shard.rs18
-rw-r--r--src/client/mod.rs80
4 files changed, 3 insertions, 176 deletions
diff --git a/src/client/dispatch.rs b/src/client/dispatch.rs
index 49dbdb0..fd46394 100644
--- a/src/client/dispatch.rs
+++ b/src/client/dispatch.rs
@@ -121,56 +121,6 @@ fn handle_event(event: Event,
data: &Arc<Mutex<ShareMap>>,
event_store: &Arc<RwLock<EventStore>>) {
match event {
- Event::CallCreate(event) => {
- if let Some(handler) = handler!(on_call_create, event_store) {
- update!(update_with_call_create, event);
-
- let context = context(None, conn, data);
-
- thread::spawn(move || (handler)(context, event.call));
- } else {
- update!(update_with_call_create, event);
- }
- },
- Event::CallDelete(event) => {
- if let Some(handler) = handler!(on_call_delete, event_store) {
- let context = context(None, conn, data);
-
- feature_cache! {{
- let call = update!(update_with_call_delete, event);
-
- thread::spawn(move || (handler)(context, event.channel_id, call));
- } else {
- thread::spawn(move || (handler)(context, event.channel_id));
- }}
- } else {
- update!(update_with_call_delete, event);
- }
- },
- Event::CallUpdate(event) => {
- if let Some(handler) = handler!(on_call_update, event_store) {
- let context = context(None, conn, data);
-
- feature_cache! {{
- let before = update!(update_with_call_update, event, true);
- let after = CACHE
- .read()
- .unwrap()
- .calls
- .get(&event.channel_id)
- .cloned();
-
- thread::spawn(move || (handler)(context, before, after));
- } else {
- thread::spawn(move || (handler)(context, event));
- }}
- } else {
- #[cfg(feature="cache")]
- {
- update!(update_with_call_update, event, false);
- }
- }
- },
Event::ChannelCreate(event) => {
if let Some(handler) = handler!(on_channel_create, event_store) {
update!(update_with_channel_create, event);
@@ -403,13 +353,6 @@ fn handle_event(event: Event,
}
}
},
- Event::GuildSync(event) => {
- if let Some(handler) = handler!(on_guild_sync, event_store) {
- let context = context(None, conn, data);
-
- thread::spawn(move || (handler)(context, event));
- }
- },
Event::GuildUnavailable(event) => {
update!(update_with_guild_unavailable, event);
diff --git a/src/client/event_store.rs b/src/client/event_store.rs
index cc74d63..9ec465c 100644
--- a/src/client/event_store.rs
+++ b/src/client/event_store.rs
@@ -2,24 +2,12 @@ use serde_json::Value;
use std::collections::{BTreeMap, HashMap};
use std::sync::Arc;
use super::context::Context;
-use ::model::event::{
- ChannelPinsAckEvent,
- ChannelPinsUpdateEvent,
- GuildSyncEvent,
- MessageUpdateEvent,
- PresenceUpdateEvent,
- ResumedEvent,
- TypingStartEvent,
- VoiceServerUpdateEvent,
-};
+use ::model::event::*;
use ::model::*;
#[cfg(feature="cache")]
use std::sync::RwLock;
-#[cfg(not(feature="cache"))]
-use ::model::event::{CallUpdateEvent, GuildMemberUpdateEvent};
-
// This should use type macros when stable receives the type macro
// stabilization patch.
//
@@ -41,15 +29,6 @@ use ::model::event::{CallUpdateEvent, GuildMemberUpdateEvent};
#[allow(type_complexity)]
#[derive(Default)]
pub struct EventStore {
- pub on_call_create: Option<Arc<Fn(Context, Call) + Send + Sync + 'static>>,
- #[cfg(feature="cache")]
- pub on_call_delete: Option<Arc<Fn(Context, ChannelId, Option<Arc<RwLock<Call>>>) + Send + Sync + 'static>>,
- #[cfg(not(feature="cache"))]
- pub on_call_delete: Option<Arc<Fn(Context, ChannelId) + Send + Sync + 'static>>,
- #[cfg(feature="cache")]
- pub on_call_update: Option<Arc<Fn(Context, Option<Arc<RwLock<Call>>>, Option<Arc<RwLock<Call>>>) + Send + Sync + 'static>>,
- #[cfg(not(feature="cache"))]
- pub on_call_update: Option<Arc<Fn(Context, CallUpdateEvent) + Send + Sync + 'static>>,
pub on_channel_create: Option<Arc<Fn(Context, Channel) + Send + Sync + 'static>>,
pub on_channel_delete: Option<Arc<Fn(Context, Channel) + Send + Sync + 'static>>,
pub on_channel_pins_ack: Option<Arc<Fn(Context, ChannelPinsAckEvent) + Send + Sync + 'static>>,
@@ -88,7 +67,6 @@ pub struct EventStore {
pub on_guild_role_update: Option<Arc<Fn(Context, GuildId, Option<Role>, Role) + Send + Sync + 'static>>,
#[cfg(not(feature="cache"))]
pub on_guild_role_update: Option<Arc<Fn(Context, GuildId, Role) + Send + Sync + 'static>>,
- pub on_guild_sync: Option<Arc<Fn(Context, GuildSyncEvent) + Send + Sync + 'static>>,
pub on_guild_unavailable: Option<Arc<Fn(Context, GuildId) + Send + Sync + 'static>>,
#[cfg(feature="cache")]
pub on_guild_update: Option<Arc<Fn(Context, Option<Arc<RwLock<Guild>>>, PartialGuild) + Send + Sync + 'static>>,
diff --git a/src/client/gateway/shard.rs b/src/client/gateway/shard.rs
index f42c52a..627ba52 100644
--- a/src/client/gateway/shard.rs
+++ b/src/client/gateway/shard.rs
@@ -18,7 +18,7 @@ use ::constants::OpCode;
use ::internal::prelude::*;
use ::internal::ws_impl::{ReceiverExt, SenderExt};
use ::model::event::{Event, GatewayEvent, ReadyEvent};
-use ::model::{ChannelId, Game, GuildId, OnlineStatus};
+use ::model::{Game, GuildId, OnlineStatus};
#[cfg(feature="cache")]
use ::client::CACHE;
@@ -483,22 +483,6 @@ impl Shard {
Ok(())
}
- /// Syncs a number of [`Call`]s, given by their associated channel Ids. This
- /// will allow the current user to know what calls are currently occurring,
- /// as otherwise events will not be received.
- pub fn sync_calls(&self, channels: &[ChannelId]) {
- for &channel in channels {
- let msg = ObjectBuilder::new()
- .insert("op", OpCode::SyncCall.num())
- .insert_object("d", |obj| obj
- .insert("channel_id", channel.0)
- )
- .build();
-
- let _ = self.keepalive_channel.send(GatewayStatus::SendMessage(msg));
- }
- }
-
/// Requests that one or multiple [`Guild`]s be synced.
///
/// This will ask Discord to start sending member chunks for large guilds
diff --git a/src/client/mod.rs b/src/client/mod.rs
index 9286379..8c073b1 100644
--- a/src/client/mod.rs
+++ b/src/client/mod.rs
@@ -44,19 +44,7 @@ use websocket::result::WebSocketError;
use websocket::stream::WebSocketStream;
use ::internal::prelude::{Error, Result, Value};
use ::internal::ws_impl::ReceiverExt;
-use ::model::event::{
- ChannelPinsAckEvent,
- ChannelPinsUpdateEvent,
- Event,
- GatewayEvent,
- GuildSyncEvent,
- MessageUpdateEvent,
- PresenceUpdateEvent,
- ReadyEvent,
- ResumedEvent,
- TypingStartEvent,
- VoiceServerUpdateEvent,
-};
+use ::model::event::*;
use ::model::*;
#[cfg(feature="framework")]
@@ -65,9 +53,6 @@ use ::ext::framework::Framework;
#[cfg(feature="cache")]
use ::ext::cache::Cache;
-#[cfg(not(feature="cache"))]
-use ::model::event::{CallUpdateEvent, GuildMemberUpdateEvent};
-
#[cfg(feature="cache")]
lazy_static! {
/// A mutable and lazily-initialized static binding. It can be accessed
@@ -326,16 +311,6 @@ impl Client {
self.start_connection(Some([range[0], range[1], total_shards]), rest::get_gateway()?.url)
}
- /// Attaches a handler for when a [`CallCreate`] is received.
- ///
- /// [`CallCreate`]: ../model/event/enum.Event.html#variant.CallCreate
- pub fn on_call_create<F>(&mut self, handler: F)
- where F: Fn(Context, Call) + Send + Sync + 'static {
- self.event_store.write()
- .unwrap()
- .on_call_create = Some(Arc::new(handler));
- }
-
/// Attaches a handler for when a [`ChannelCreate`] is received.
///
/// [`ChannelCreate`]: ../model/event/enum.Event.html#variant.ChannelCreate
@@ -438,16 +413,6 @@ impl Client {
.on_guild_role_create = Some(Arc::new(handler));
}
- /// Attaches a handler for when a [`GuildRoleSync`] is received.
- ///
- /// [`GuildRoleSync`]: ../model/event/enum.Event.html#variant.GuildRoleSync
- pub fn on_guild_sync<F>(&mut self, handler: F)
- where F: Fn(Context, GuildSyncEvent) + Send + Sync + 'static {
- self.event_store.write()
- .unwrap()
- .on_guild_sync = Some(Arc::new(handler));
- }
-
/// Attaches a handler for when a [`GuildUnavailable`] is received.
///
/// [`GuildUnavailable`]: ../model/event/enum.Event.html#variant.GuildUnavailable
@@ -809,29 +774,6 @@ impl Client {
#[cfg(feature="cache")]
impl Client {
- /// Attaches a handler for when a [`CallDelete`] is received.
- ///
- /// The `ChannelId` is the Id of the channel hosting the call. Returns the
- /// call from the cache - optionally - if the call was in it.
- ///
- /// [`CallDelete`]: ../model/event/enum.Event.html#variant.CallDelete
- pub fn on_call_delete<F>(&mut self, handler: F)
- where F: Fn(Context, ChannelId, Option<Arc<RwLock<Call>>>) + Send + Sync + 'static {
- self.event_store.write()
- .unwrap()
- .on_call_delete = Some(Arc::new(handler));
- }
-
- /// Attaches a handler for when a [`CallUpdate`] is received.
- ///
- /// [`CallUpdate`]: ../model/event/enum.Event.html#variant.CallUpdate
- pub fn on_call_update<F>(&mut self, handler: F)
- where F: Fn(Context, Option<Arc<RwLock<Call>>>, Option<Arc<RwLock<Call>>>) + Send + Sync + 'static {
- self.event_store.write()
- .unwrap()
- .on_call_update = Some(Arc::new(handler));
- }
-
/// Attaches a handler for when a [`ChannelUpdate`] is received.
///
/// Optionally provides the version of the channel before the update.
@@ -936,26 +878,6 @@ impl Client {
#[cfg(not(feature="cache"))]
impl Client {
- /// Attaches a handler for when a [`CallDelete`] is received.
- ///
- /// [`CallDelete`]: ../model/event/enum.Event.html#variant.CallDelete
- pub fn on_call_delete<F>(&mut self, handler: F)
- where F: Fn(Context, ChannelId) + Send + Sync + 'static {
- self.event_store.write()
- .unwrap()
- .on_call_delete = Some(Arc::new(handler));
- }
-
- /// Attaches a handler for when a [`CallUpdate`] is received.
- ///
- /// [`CallUpdate`]: ../model/event/enum.Event.html#variant.CallUpdate
- pub fn on_call_update<F>(&mut self, handler: F)
- where F: Fn(Context, CallUpdateEvent) + Send + Sync + 'static {
- self.event_store.write()
- .unwrap()
- .on_call_update = Some(Arc::new(handler));
- }
-
/// Attaches a handler for when a [`ChannelUpdate`] is received.
///
/// [`ChannelUpdate`]: ../model/event/enum.Event.html#variant.ChannelUpdate