Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Update BskyAgent #197

Merged
merged 2 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bsky-sdk/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ anyhow.workspace = true
async-trait.workspace = true
atrium-api.workspace = true
atrium-xrpc-client = { workspace = true, optional = true }
ipld-core.workspace = true
psl = { version = "2.1.42", optional = true }
regex.workspace = true
serde = { workspace = true, features = ["derive"] }
Expand All @@ -26,6 +25,7 @@ toml = { version = "0.8.13", optional = true }
unicode-segmentation = { version = "1.11.0", optional = true }

[dev-dependencies]
ipld-core.workspace = true
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }

[features]
Expand Down
16 changes: 7 additions & 9 deletions bsky-sdk/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ use crate::moderation::{ModerationPrefsLabeler, Moderator};
use crate::preference::{FeedViewPreferenceData, Preferences, ThreadViewPreferenceData};
use atrium_api::agent::store::MemorySessionStore;
use atrium_api::agent::{store::SessionStore, AtpAgent};
use atrium_api::app::bsky::actor::defs::{LabelersPref, PreferencesItem};
use atrium_api::app::bsky::actor::defs::PreferencesItem;
use atrium_api::types::{Object, Union};
use atrium_api::xrpc::XrpcClient;
#[cfg(feature = "default-client")]
use atrium_xrpc_client::reqwest::ReqwestClient;
use ipld_core::serde::from_ipld;
use std::collections::HashMap;
use std::ops::Deref;
use std::sync::Arc;
Expand Down Expand Up @@ -160,11 +159,12 @@ where
Union::Refs(PreferencesItem::HiddenPostsPref(p)) => {
prefs.moderation_prefs.hidden_posts = p.data.items;
}
Union::Unknown(u) => {
if u.r#type == "app.bsky.actor.defs#labelersPref" {
prefs.moderation_prefs.labelers.extend(
from_ipld::<LabelersPref>(u.data)?
.data
Union::Refs(PreferencesItem::LabelersPref(p)) => {
prefs
.moderation_prefs
.labelers
.extend(
p.data
.labelers
.into_iter()
.map(|item| ModerationPrefsLabeler {
Expand All @@ -173,7 +173,6 @@ where
is_default_labeler: false,
}),
);
}
}
_ => {
// TODO
Expand Down Expand Up @@ -214,7 +213,6 @@ where
.labelers
.iter()
.map(|labeler| (labeler.did.clone(), labeler.is_default_labeler))
.take(10)
.collect(),
));
}
Expand Down
2 changes: 0 additions & 2 deletions bsky-sdk/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ pub enum Error {
#[error("saving config error: {0}")]
ConfigSave(Box<dyn std::error::Error + Send + Sync + 'static>),
#[error(transparent)]
IpldSerde(#[from] ipld_core::serde::SerdeError),
#[error(transparent)]
Moderation(#[from] crate::moderation::Error),
}

Expand Down
Loading