Added ResolvePeer, UnfollowPeer, RelationshipType
This commit is contained in:
parent
9f772cf3a6
commit
deecab0321
|
@ -3,8 +3,11 @@ use socialvoid_rawclient as rawclient;
|
|||
use socialvoid_rawclient::Error;
|
||||
use socialvoid_types::Peer;
|
||||
use socialvoid_types::Profile;
|
||||
use socialvoid_types::RelationshipType;
|
||||
use socialvoid_types::SessionIdentification;
|
||||
|
||||
/// GetMe
|
||||
/// Returns the peer object of the authenticated peer
|
||||
pub async fn get_me(
|
||||
client: &rawclient::Client,
|
||||
session_identification: SessionIdentification,
|
||||
|
@ -38,6 +41,40 @@ pub async fn get_profile(
|
|||
.await
|
||||
}
|
||||
|
||||
/// ResolvePeer
|
||||
pub async fn resolve_peer(
|
||||
client: &rawclient::Client,
|
||||
session_identification: SessionIdentification,
|
||||
peer: String,
|
||||
) -> Result<Peer, Error> {
|
||||
client
|
||||
.send_request(
|
||||
"network.resolve_peer",
|
||||
json!({
|
||||
"session_identification": serde_json::to_value(session_identification)?,
|
||||
"peer": peer,
|
||||
}),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// UnfollowPeer
|
||||
pub async fn unfollow_peer(
|
||||
client: &rawclient::Client,
|
||||
session_identification: SessionIdentification,
|
||||
peer: String,
|
||||
) -> Result<RelationshipType, Error> {
|
||||
client
|
||||
.send_request(
|
||||
"network.unfollow_peer",
|
||||
json!({
|
||||
"session_identification": serde_json::to_value(session_identification)?,
|
||||
"peer": peer,
|
||||
}),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
@ -118,6 +118,19 @@ pub struct Profile {
|
|||
display_picture_sizes: Vec<DisplayPictureSize>,
|
||||
}
|
||||
|
||||
/// Relationship of a peer with another peer.
|
||||
/// https://github.com/intellivoid/Socialvoid-Standard-Documentation/blob/master/Types/RelationshipTypes.md
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub enum RelationshipType {
|
||||
NONE,
|
||||
FOLLOWING,
|
||||
FOLLOWS_YOU,
|
||||
AWAITING_APPROVAL,
|
||||
MUTUALLY_FOLLOWING,
|
||||
BLOCKED,
|
||||
BLOCKED_YOU,
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Profile {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
write!(
|
||||
|
|
Loading…
Reference in New Issue