Move profile details model into entities too
This commit is contained in:
parent
e1baeffc6e
commit
fddcf7272c
|
@ -13,16 +13,10 @@ use futures::StreamExt;
|
||||||
use log::error;
|
use log::error;
|
||||||
use tokio_tungstenite::{connect_async, tungstenite};
|
use tokio_tungstenite::{connect_async, tungstenite};
|
||||||
|
|
||||||
use super::entities::Session;
|
use super::entities::{ProfileDetails, Session};
|
||||||
use super::internals::xrpc::AuthenticateableXrpcClient;
|
use super::internals::xrpc::AuthenticateableXrpcClient;
|
||||||
use super::streaming::{handle_message, CommitProcessor};
|
use super::streaming::{handle_message, CommitProcessor};
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct ProfileDetails {
|
|
||||||
pub display_name: String,
|
|
||||||
pub description: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Bluesky {
|
pub struct Bluesky {
|
||||||
client: AtpServiceClient<AtpServiceWrapper<AuthenticateableXrpcClient>>,
|
client: AtpServiceClient<AtpServiceWrapper<AuthenticateableXrpcClient>>,
|
||||||
session: Option<Arc<Mutex<Session>>>,
|
session: Option<Arc<Mutex<Session>>>,
|
||||||
|
@ -150,15 +144,10 @@ impl Bluesky {
|
||||||
Err(e) => return Err(e.into()),
|
Err(e) => return Err(e.into()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let profile = match profile_data.value {
|
match profile_data.value {
|
||||||
Record::AppBskyActorProfile(profile) => profile,
|
Record::AppBskyActorProfile(profile) => Ok(Some(ProfileDetails::from(*profile))),
|
||||||
_ => return Err(anyhow!("Big bad, no such profile")),
|
_ => Err(anyhow!("Wrong type of record")),
|
||||||
};
|
}
|
||||||
|
|
||||||
Ok(Some(ProfileDetails {
|
|
||||||
display_name: profile.display_name.unwrap_or_default(),
|
|
||||||
description: profile.description.unwrap_or_default(),
|
|
||||||
}))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn resolve_handle(&self, handle: &str) -> Result<Option<String>> {
|
pub async fn resolve_handle(&self, handle: &str) -> Result<Option<String>> {
|
||||||
|
|
|
@ -2,8 +2,10 @@ mod follow;
|
||||||
mod like;
|
mod like;
|
||||||
mod post;
|
mod post;
|
||||||
mod session;
|
mod session;
|
||||||
|
mod profile;
|
||||||
|
|
||||||
pub use follow::FollowRecord;
|
pub use follow::FollowRecord;
|
||||||
pub use like::LikeRecord;
|
pub use like::LikeRecord;
|
||||||
pub use post::PostRecord;
|
pub use post::PostRecord;
|
||||||
pub use session::Session;
|
pub use session::Session;
|
||||||
|
pub use profile::ProfileDetails;
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
use atrium_api::app::bsky::actor::profile::Record as ProfileRecord;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ProfileDetails {
|
||||||
|
pub display_name: String,
|
||||||
|
pub description: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<ProfileRecord> for ProfileDetails {
|
||||||
|
fn from(value: ProfileRecord) -> Self {
|
||||||
|
Self {
|
||||||
|
display_name: value.display_name.unwrap_or_default(),
|
||||||
|
description: value.description.unwrap_or_default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue