working on tilde integration

This commit is contained in:
notplants
2025-02-19 14:43:31 -05:00
parent 6bbfb454de
commit 22e32a5715
5 changed files with 34 additions and 11 deletions

View File

@ -6,7 +6,7 @@ use std::fmt;
/// all tilde client errors
#[derive(Debug)]
pub struct TildeError {
message: String,
pub(crate) message: String,
}
impl fmt::Display for TildeError {

View File

@ -3,6 +3,7 @@
use crate::error::TildeError;
use serde_json::Value;
use std::process::{Command, exit};
mod error;
@ -23,12 +24,28 @@ pub fn get_sbot_client() -> TildeClient {
impl TildeClient {
pub fn run_tilde_command(&self, command: &str) -> Result<String, TildeError> {
let output = Command::new("out/release/tildefriends.standalone")
.arg(command)
.output().map_err(|e| TildeError {
message: format!("Command execution failed: {}", e),
})?;
if !output.status.success() {
return Err(TildeError { message: format!("Command failed with status: {}", output.status) })
}
let result = String::from_utf8_lossy(&output.stdout).to_string();
println!("Command output: {}", result);
Ok(result)
}
pub async fn latest_description(&self, key: &str) -> Result<String, TildeError> {
todo!();
}
pub async fn whoami(&self) -> Result<String, TildeError> {
todo!();
self.run_tilde_command("get_identity")
}
pub async fn is_following(&self, from_id: &str, to_id: &str) -> Result<bool, TildeError> {
@ -53,4 +70,4 @@ impl TildeClient {
pub async fn publish(&self, post: Value) -> Result<Vec<String>, TildeError> {
todo!();
}
}
}