-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathunpublish.rs
76 lines (65 loc) · 1.98 KB
/
unpublish.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
use anyhow::Result;
use atrium_api::{
agent::{store::MemorySessionStore, AtpAgent},
types::string::{Handle, Nsid},
};
use clap::Parser;
#[derive(Parser, Debug)]
struct Args {
/// Your bluesky handle
#[arg(long)]
handle: String,
/// An app password. See [app-passwords](https://bsky.app/settings/app-passwords)
#[arg(long)]
app_password: String,
/// Short name of the feed. Sharing a link to a feed will use a URL like `<host>/profile/<user-did>/feed/<name!>`. This utility will unpublish the feed with the matching name.
#[arg(long)]
name: String,
}
pub const XRPC_HOST: &str = "https://bsky.social";
#[tokio::main]
async fn main() -> Result<()> {
let args = Args::parse();
let handle = args.handle;
let password = args.app_password;
println!("Logging in");
let agent = AtpAgent::new(
atrium_xrpc_client::reqwest::ReqwestClient::new(XRPC_HOST),
MemorySessionStore::default(),
);
agent.login(handle.clone(), password).await?;
let publisher_did = agent
.api
.com
.atproto
.identity
.resolve_handle(
atrium_api::com::atproto::identity::resolve_handle::ParametersData {
handle: Handle::new(handle.to_owned()).unwrap(),
}
.into(),
)
.await
.unwrap();
agent
.api
.com
.atproto
.repo
.delete_record(
atrium_api::com::atproto::repo::delete_record::InputData {
collection: Nsid::new("app.bsky.feed.generator".to_owned()).unwrap(),
repo: atrium_api::types::string::AtIdentifier::Did(
publisher_did.to_owned().did.clone(),
),
rkey: args.name.to_owned(),
swap_commit: None,
swap_record: None,
}
.into(),
)
.await
.expect("Failed to unpublish feed");
println!("Successfully unpublished");
Ok(())
}