Compare commits
1 Commits
5fc1457f9c
...
b29d987ee4
Author | SHA1 | Date |
---|---|---|
kozabrada123 | b29d987ee4 |
|
@ -133,8 +133,6 @@ impl ChorusUser {
|
||||||
/// To create normal connection types, see [Self::authorize_connection] and
|
/// To create normal connection types, see [Self::authorize_connection] and
|
||||||
/// [Self::create_connection_callback]
|
/// [Self::create_connection_callback]
|
||||||
///
|
///
|
||||||
/// As of 2024/08/21, Spacebar does not yet implement this endpoint.
|
|
||||||
///
|
|
||||||
/// # Examples
|
/// # Examples
|
||||||
/// ```no_run
|
/// ```no_run
|
||||||
/// let domain = "example.com".to_string();
|
/// let domain = "example.com".to_string();
|
||||||
|
|
|
@ -91,8 +91,6 @@ impl From<Connection> for PublicConnection {
|
||||||
#[serde(rename_all = "lowercase")]
|
#[serde(rename_all = "lowercase")]
|
||||||
/// A type of connection; the service the connection is for
|
/// A type of connection; the service the connection is for
|
||||||
///
|
///
|
||||||
/// Note: this is subject to change, and the enum is likely non-exhaustive
|
|
||||||
///
|
|
||||||
/// # Reference
|
/// # Reference
|
||||||
/// See <https://docs.discord.sex/resources/user#connection-type>
|
/// See <https://docs.discord.sex/resources/user#connection-type>
|
||||||
pub enum ConnectionType {
|
pub enum ConnectionType {
|
||||||
|
@ -107,8 +105,6 @@ pub enum ConnectionType {
|
||||||
/// (Not returned in Get User Profile or when fetching connections)
|
/// (Not returned in Get User Profile or when fetching connections)
|
||||||
Contacts,
|
Contacts,
|
||||||
Crunchyroll,
|
Crunchyroll,
|
||||||
/// Note: spacebar only
|
|
||||||
Discord,
|
|
||||||
Domain,
|
Domain,
|
||||||
Ebay,
|
Ebay,
|
||||||
EpicGames,
|
EpicGames,
|
||||||
|
@ -155,42 +151,9 @@ impl Display for ConnectionType {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConnectionType {
|
impl ConnectionType {
|
||||||
/// Returns an vector of all the connection types
|
/// Returns an array of all the connections
|
||||||
// API note: this could be an array, but it is subject to change.
|
pub fn array() -> [ConnectionType; 25] {
|
||||||
pub fn vector() -> Vec<ConnectionType> {
|
[
|
||||||
vec![
|
|
||||||
ConnectionType::AmazonMusic,
|
|
||||||
ConnectionType::BattleNet,
|
|
||||||
ConnectionType::Bungie,
|
|
||||||
ConnectionType::Contacts,
|
|
||||||
ConnectionType::Crunchyroll,
|
|
||||||
ConnectionType::Discord,
|
|
||||||
ConnectionType::Domain,
|
|
||||||
ConnectionType::Ebay,
|
|
||||||
ConnectionType::EpicGames,
|
|
||||||
ConnectionType::Facebook,
|
|
||||||
ConnectionType::GitHub,
|
|
||||||
ConnectionType::Instagram,
|
|
||||||
ConnectionType::LeagueOfLegends,
|
|
||||||
ConnectionType::PayPal,
|
|
||||||
ConnectionType::Playstation,
|
|
||||||
ConnectionType::Reddit,
|
|
||||||
ConnectionType::RiotGames,
|
|
||||||
ConnectionType::Samsung,
|
|
||||||
ConnectionType::Spotify,
|
|
||||||
ConnectionType::Skype,
|
|
||||||
ConnectionType::Steam,
|
|
||||||
ConnectionType::TikTok,
|
|
||||||
ConnectionType::Twitch,
|
|
||||||
ConnectionType::Twitter,
|
|
||||||
ConnectionType::Xbox,
|
|
||||||
ConnectionType::YouTube,
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns an vector of all the connection types available on discord
|
|
||||||
pub fn discord_vector() -> Vec<ConnectionType> {
|
|
||||||
vec![
|
|
||||||
ConnectionType::AmazonMusic,
|
ConnectionType::AmazonMusic,
|
||||||
ConnectionType::BattleNet,
|
ConnectionType::BattleNet,
|
||||||
ConnectionType::Bungie,
|
ConnectionType::Bungie,
|
||||||
|
@ -218,23 +181,6 @@ impl ConnectionType {
|
||||||
ConnectionType::YouTube,
|
ConnectionType::YouTube,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns an vector of all the connection types available on spacebar
|
|
||||||
pub fn spacebar_vector() -> Vec<ConnectionType> {
|
|
||||||
vec![
|
|
||||||
ConnectionType::BattleNet,
|
|
||||||
ConnectionType::Discord,
|
|
||||||
ConnectionType::EpicGames,
|
|
||||||
ConnectionType::Facebook,
|
|
||||||
ConnectionType::GitHub,
|
|
||||||
ConnectionType::Reddit,
|
|
||||||
ConnectionType::Spotify,
|
|
||||||
ConnectionType::Twitch,
|
|
||||||
ConnectionType::Twitter,
|
|
||||||
ConnectionType::Xbox,
|
|
||||||
ConnectionType::YouTube,
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
|
|
169
tests/user.rs
169
tests/user.rs
|
@ -2,13 +2,7 @@
|
||||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
|
|
||||||
use chorus::{
|
use chorus::types::{PublicUser, Snowflake, User};
|
||||||
errors::ChorusError,
|
|
||||||
types::{
|
|
||||||
ConnectionType, DeleteDisableUserSchema, PublicUser, Snowflake, User,
|
|
||||||
UserModifyProfileSchema, UserNote,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
use wasm_bindgen_test::*;
|
use wasm_bindgen_test::*;
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
|
@ -49,164 +43,3 @@ async fn test_get_user_profile() {
|
||||||
|
|
||||||
common::teardown(bundle).await;
|
common::teardown(bundle).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
|
||||||
#[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
|
|
||||||
async fn test_modify_user_profile() {
|
|
||||||
let mut bundle = common::setup().await;
|
|
||||||
|
|
||||||
let bio = Some(String::from("A user."));
|
|
||||||
let pronouns = Some(String::from("they/them"));
|
|
||||||
|
|
||||||
let modify = UserModifyProfileSchema {
|
|
||||||
bio: bio.clone(),
|
|
||||||
pronouns: pronouns.clone(),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
bundle.user.modify_profile(modify).await.unwrap();
|
|
||||||
|
|
||||||
let user_id = bundle.user.object.read().unwrap().id;
|
|
||||||
|
|
||||||
let user_profile = bundle
|
|
||||||
.user
|
|
||||||
.get_user_profile(user_id, chorus::types::GetUserProfileSchema::default())
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert_eq!(user_profile.profile_metadata.bio, bio);
|
|
||||||
assert_eq!(user_profile.profile_metadata.pronouns, pronouns.unwrap());
|
|
||||||
|
|
||||||
common::teardown(bundle).await;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
|
||||||
#[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
|
|
||||||
async fn test_disable_user() {
|
|
||||||
let mut bundle = common::setup().await;
|
|
||||||
|
|
||||||
let mut other_user = bundle.create_user("integrationtestuser4").await;
|
|
||||||
|
|
||||||
other_user
|
|
||||||
.disable(DeleteDisableUserSchema { password: None })
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
common::teardown(bundle).await;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: these two tests are currently broken.
|
|
||||||
// FIXME: readd them once bitfl0wer/server#2 is merged
|
|
||||||
/*
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
|
||||||
#[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
|
|
||||||
async fn test_get_user_note() {
|
|
||||||
let mut bundle = common::setup().await;
|
|
||||||
|
|
||||||
let mut other_user = bundle.create_user("integrationtestuser3").await;
|
|
||||||
|
|
||||||
let user_id = bundle.user.object.read().unwrap().id;
|
|
||||||
let other_user_id = other_user.object.read().unwrap().id;
|
|
||||||
|
|
||||||
let result = bundle.user.get_user_note(other_user_id).await;
|
|
||||||
assert!(matches!(
|
|
||||||
result.err().unwrap(),
|
|
||||||
ChorusError::NotFound { .. }
|
|
||||||
));
|
|
||||||
|
|
||||||
bundle
|
|
||||||
.user
|
|
||||||
.set_user_note(other_user_id, Some(String::from("A note.")))
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
assert!(false);
|
|
||||||
|
|
||||||
let result = bundle.user.get_user_note(other_user_id).await;
|
|
||||||
assert_eq!(
|
|
||||||
result,
|
|
||||||
Ok(UserNote {
|
|
||||||
user_id,
|
|
||||||
note_user_id: other_user_id,
|
|
||||||
note: String::from("A note.")
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
other_user
|
|
||||||
.delete(DeleteDisableUserSchema { password: None })
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
common::teardown(bundle).await;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
|
||||||
#[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
|
|
||||||
async fn test_set_user_note() {
|
|
||||||
let mut bundle = common::setup().await;
|
|
||||||
|
|
||||||
let mut other_user = bundle.create_user("integrationtestuser3").await;
|
|
||||||
|
|
||||||
let user_id = bundle.user.object.read().unwrap().id;
|
|
||||||
let other_user_id = other_user.object.read().unwrap().id;
|
|
||||||
|
|
||||||
bundle
|
|
||||||
.user
|
|
||||||
.set_user_note(other_user_id, Some(String::from("A note.")))
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let result = bundle.user.get_user_note(other_user_id).await;
|
|
||||||
assert_eq!(
|
|
||||||
result,
|
|
||||||
Ok(UserNote {
|
|
||||||
user_id,
|
|
||||||
note_user_id: other_user_id,
|
|
||||||
note: String::from("A note.")
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
other_user
|
|
||||||
.delete(DeleteDisableUserSchema { password: None })
|
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
common::teardown(bundle).await;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
|
||||||
#[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
|
|
||||||
async fn test_get_user_affinities() {
|
|
||||||
let mut bundle = common::setup().await;
|
|
||||||
|
|
||||||
let result = bundle.user.get_user_affinities().await.unwrap();
|
|
||||||
|
|
||||||
assert!(result.user_affinities.is_empty());
|
|
||||||
assert!(result.inverse_user_affinities.is_empty());
|
|
||||||
|
|
||||||
common::teardown(bundle).await;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
|
||||||
#[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
|
|
||||||
async fn test_get_guild_affinities() {
|
|
||||||
let mut bundle = common::setup().await;
|
|
||||||
|
|
||||||
let result = bundle.user.get_guild_affinities().await.unwrap();
|
|
||||||
|
|
||||||
assert!(result.guild_affinities.is_empty());
|
|
||||||
|
|
||||||
common::teardown(bundle).await;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
|
||||||
#[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
|
|
||||||
async fn test_get_connections() {
|
|
||||||
let mut bundle = common::setup().await;
|
|
||||||
|
|
||||||
let result = bundle.user.get_connections().await.unwrap();
|
|
||||||
|
|
||||||
// We can't *really* test creating or getting connections...
|
|
||||||
// TODO: Find a way?
|
|
||||||
assert!(result.is_empty());
|
|
||||||
|
|
||||||
common::teardown(bundle).await;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue