Remove unnecessary parameterization of Bluesky hosts
Really isn't necessary. I'm never going to use anything other than proper, real, production Bluesky for this.
This commit is contained in:
		
							parent
							
								
									fddcf7272c
								
							
						
					
					
						commit
						b5156ecfbf
					
				| 
						 | 
				
			
			@ -28,7 +28,7 @@ async fn main() -> Result<()> {
 | 
			
		|||
    let database_url =
 | 
			
		||||
        env::var("DATABASE_URL").context("DATABASE_URL environment variable must be set")?;
 | 
			
		||||
 | 
			
		||||
    let bluesky = Bluesky::unauthenticated("https://bsky.social");
 | 
			
		||||
    let bluesky = Bluesky::unauthenticated();
 | 
			
		||||
    let database = Database::connect(&database_url).await?;
 | 
			
		||||
 | 
			
		||||
    for handle in &args.handle {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -43,7 +43,7 @@ async fn main() -> Result<()> {
 | 
			
		|||
 | 
			
		||||
    println!("Logging in");
 | 
			
		||||
 | 
			
		||||
    let bluesky = Bluesky::login("https://bsky.social", &handle, &password).await?;
 | 
			
		||||
    let bluesky = Bluesky::login(&handle, &password).await?;
 | 
			
		||||
 | 
			
		||||
    let mut avatar = None;
 | 
			
		||||
    if let Some(path) = args.avatar_filename {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -17,7 +17,7 @@ async fn main() -> Result<()> {
 | 
			
		|||
    let password = env::var("PUBLISHER_BLUESKY_PASSWORD")
 | 
			
		||||
        .context("PUBLISHER_BLUESKY_PASSWORD environment variable must be set")?;
 | 
			
		||||
 | 
			
		||||
    let bluesky = Bluesky::login("https://bsky.social", &handle, &password).await?;
 | 
			
		||||
    let bluesky = Bluesky::login(&handle, &password).await?;
 | 
			
		||||
    let session = bluesky
 | 
			
		||||
        .session()
 | 
			
		||||
        .ok_or_else(|| anyhow!("Could not log in"))?;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,7 +23,7 @@ async fn main() -> Result<()> {
 | 
			
		|||
    info!("Initializing service clients");
 | 
			
		||||
 | 
			
		||||
    let ai = Arc::new(AI::new(&config.chat_gpt_api_key, "https://api.openai.com"));
 | 
			
		||||
    let bluesky = Arc::new(Bluesky::unauthenticated("https://bsky.social"));
 | 
			
		||||
    let bluesky = Arc::new(Bluesky::unauthenticated());
 | 
			
		||||
    let database = Arc::new(Database::connect(&config.database_url).await?);
 | 
			
		||||
 | 
			
		||||
    info!("Initializing language detector");
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,17 +23,20 @@ pub struct Bluesky {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
impl Bluesky {
 | 
			
		||||
    pub fn unauthenticated(host: &str) -> Self {
 | 
			
		||||
    const XRPC_HOST: &str = "https://bsky.social";
 | 
			
		||||
    const FIREHOSE_HOST: &str = "wss://bsky.social";
 | 
			
		||||
 | 
			
		||||
    pub fn unauthenticated() -> Self {
 | 
			
		||||
        Self {
 | 
			
		||||
            client: AtpServiceClient::new(AuthenticateableXrpcClient::new(host.to_owned())),
 | 
			
		||||
            client: AtpServiceClient::new(AuthenticateableXrpcClient::new(Self::XRPC_HOST.to_owned())),
 | 
			
		||||
            session: None,
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub async fn login(host: &str, handle: &str, password: &str) -> Result<Self> {
 | 
			
		||||
    pub async fn login(handle: &str, password: &str) -> Result<Self> {
 | 
			
		||||
        use atrium_api::com::atproto::server::create_session::Input;
 | 
			
		||||
 | 
			
		||||
        let client = AtpServiceClient::new(AuthenticateableXrpcClient::new(host.to_owned()));
 | 
			
		||||
        let client = AtpServiceClient::new(AuthenticateableXrpcClient::new(Self::XRPC_HOST.to_owned()));
 | 
			
		||||
 | 
			
		||||
        let result = client
 | 
			
		||||
            .service
 | 
			
		||||
| 
						 | 
				
			
			@ -49,7 +52,7 @@ impl Bluesky {
 | 
			
		|||
        let session = Arc::new(Mutex::new(result.try_into()?));
 | 
			
		||||
 | 
			
		||||
        let authenticated_client = AtpServiceClient::new(AuthenticateableXrpcClient::with_session(
 | 
			
		||||
            host.to_owned(),
 | 
			
		||||
            Self::XRPC_HOST.to_owned(),
 | 
			
		||||
            session.clone(),
 | 
			
		||||
        ));
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -178,10 +181,10 @@ impl Bluesky {
 | 
			
		|||
    ) -> Result<()> {
 | 
			
		||||
        let url = match cursor {
 | 
			
		||||
            Some(cursor) => format!(
 | 
			
		||||
                "wss://bsky.social/xrpc/com.atproto.sync.subscribeRepos?cursor={}",
 | 
			
		||||
                cursor
 | 
			
		||||
                "{}/xrpc/com.atproto.sync.subscribeRepos?cursor={}",
 | 
			
		||||
                Self::FIREHOSE_HOST, cursor
 | 
			
		||||
            ),
 | 
			
		||||
            None => "wss://bsky.social/xrpc/com.atproto.sync.subscribeRepos".to_owned(),
 | 
			
		||||
            None => format!("{}/xrpc/com.atproto.sync.subscribeRepos", Self::FIREHOSE_HOST),
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        let (mut stream, _) = connect_async(url).await?;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue