Implement invite handling commands
Handles SEND_ACTIVITY_JOIN_INVITE and CLOSE_ACTIVITY_REQUEST
This commit is contained in:
parent
9c90034ee7
commit
aaaf2474a6
|
@ -1,4 +1,5 @@
|
|||
use serde::{Serialize, de::DeserializeOwned};
|
||||
use serde_json::Value;
|
||||
|
||||
use connection::Manager as ConnectionManager;
|
||||
use models::{
|
||||
|
@ -9,7 +10,12 @@ use models::{
|
|||
commands::{SubscriptionArgs, Subscription},
|
||||
};
|
||||
#[cfg(feature = "rich_presence")]
|
||||
use models::rich_presence::{SetActivityArgs, Activity};
|
||||
use models::rich_presence::{
|
||||
SetActivityArgs,
|
||||
Activity,
|
||||
SendActivityJoinInviteArgs,
|
||||
CloseActivityRequestArgs,
|
||||
};
|
||||
use error::{Result, Error};
|
||||
|
||||
|
||||
|
@ -53,6 +59,19 @@ impl Client {
|
|||
self.execute(Command::SetActivity, SetActivityArgs::default(), None)
|
||||
}
|
||||
|
||||
// NOTE: Not sure what the actual response values of
|
||||
// SEND_ACTIVITY_JOIN_INVITE and CLOSE_ACTIVITY_REQUEST are,
|
||||
// they are not documented.
|
||||
#[cfg(feature = "rich_presence")]
|
||||
pub fn send_activity_join_invite(&mut self, user_id: u64) -> Result<Payload<Value>> {
|
||||
self.execute(Command::SendActivityJoinInvite, SendActivityJoinInviteArgs::new(user_id), None)
|
||||
}
|
||||
|
||||
#[cfg(feature = "rich_presence")]
|
||||
pub fn close_activity_request(&mut self, user_id: u64) -> Result<Payload<Value>> {
|
||||
self.execute(Command::CloseActivityRequest, CloseActivityRequestArgs::new(user_id), None)
|
||||
}
|
||||
|
||||
pub fn subscribe<F>(&mut self, evt: Event, f: F) -> Result<Payload<Subscription>>
|
||||
where F: FnOnce(SubscriptionArgs) -> SubscriptionArgs
|
||||
{
|
||||
|
|
|
@ -15,6 +15,10 @@ pub enum Command {
|
|||
Unsubscribe,
|
||||
#[cfg(feature = "rich_presence")]
|
||||
SetActivity,
|
||||
#[cfg(feature = "rich_presence")]
|
||||
SendActivityJoinInvite,
|
||||
#[cfg(feature = "rich_presence")]
|
||||
CloseActivityRequest,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Deserialize, Serialize)]
|
||||
|
@ -43,6 +47,8 @@ pub mod prelude {
|
|||
#[cfg(feature = "rich_presence")]
|
||||
pub use super::rich_presence::{
|
||||
SetActivityArgs,
|
||||
SendActivityJoinInviteArgs,
|
||||
CloseActivityRequestArgs,
|
||||
ActivityJoinEvent,
|
||||
ActivitySpectateEvent,
|
||||
ActivityJoinRequestEvent
|
||||
|
|
|
@ -28,6 +28,19 @@ impl Default for SetActivityArgs {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Deserialize, Serialize)]
|
||||
pub struct SendActivityJoinInviteArgs {
|
||||
pub user_id: String,
|
||||
}
|
||||
|
||||
pub type CloseActivityRequestArgs = SendActivityJoinInviteArgs;
|
||||
|
||||
impl SendActivityJoinInviteArgs {
|
||||
pub fn new(user_id: u64) -> Self {
|
||||
Self { user_id: user_id.to_string() }
|
||||
}
|
||||
}
|
||||
|
||||
builder!{ActivityJoinEvent
|
||||
secret: String,
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue