mirror of
https://github.com/Nutomic/ibis.git
synced 2024-12-23 08:21:23 +00:00
fix tests
This commit is contained in:
parent
446556ff1a
commit
02db60ba15
7 changed files with 18 additions and 9 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -730,6 +730,7 @@ dependencies = [
|
|||
"rand",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha2",
|
||||
"tokio",
|
||||
"tracing",
|
||||
|
|
|
@ -22,6 +22,7 @@ hex = "0.4.3"
|
|||
jsonwebtoken = "9.2.0"
|
||||
rand = "0.8.5"
|
||||
serde = "1.0.192"
|
||||
serde_json = "1.0.108"
|
||||
sha2 = "0.10.8"
|
||||
tokio = { version = "1.34.0", features = ["full"] }
|
||||
tracing = "0.1.40"
|
||||
|
|
|
@ -29,7 +29,7 @@ create table local_user (
|
|||
create table instance_follow (
|
||||
id serial primary key,
|
||||
instance_id int REFERENCES instance ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
|
||||
follower_id int REFERENCES person ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
|
||||
follower_id int REFERENCES instance ON UPDATE CASCADE ON DELETE CASCADE NOT NULL,
|
||||
pending boolean not null,
|
||||
unique(instance_id, follower_id)
|
||||
);
|
||||
|
|
|
@ -82,8 +82,6 @@ diesel::table! {
|
|||
diesel::joinable!(article -> instance (instance_id));
|
||||
diesel::joinable!(conflict -> article (article_id));
|
||||
diesel::joinable!(edit -> article (article_id));
|
||||
diesel::joinable!(instance_follow -> instance (instance_id));
|
||||
diesel::joinable!(instance_follow -> person (follower_id));
|
||||
diesel::joinable!(local_user -> person (person_id));
|
||||
|
||||
diesel::allow_tables_to_appear_in_same_query!(
|
||||
|
|
|
@ -52,6 +52,7 @@ impl ActivityHandler for Accept {
|
|||
let local_instance = DbInstance::read_local_instance(&data.db_connection)?;
|
||||
let actor = self.actor.dereference(data).await?;
|
||||
DbInstance::follow(local_instance.id, actor.id, false, data)?;
|
||||
dbg!(&self);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ impl Follow {
|
|||
to: DbInstance,
|
||||
data: &Data<MyDataHandle>,
|
||||
) -> MyResult<()> {
|
||||
dbg!(1);
|
||||
let id = generate_activity_id(local_instance.ap_id.inner())?;
|
||||
let follow = Follow {
|
||||
actor: local_instance.ap_id.clone(),
|
||||
|
@ -33,6 +34,7 @@ impl Follow {
|
|||
kind: Default::default(),
|
||||
id,
|
||||
};
|
||||
dbg!(&follow);
|
||||
local_instance
|
||||
.send(follow, vec![to.shared_inbox_or_inbox()], data)
|
||||
.await?;
|
||||
|
|
|
@ -20,6 +20,7 @@ use std::thread::{sleep, spawn};
|
|||
use std::time::Duration;
|
||||
use tokio::task::JoinHandle;
|
||||
use tracing::log::LevelFilter;
|
||||
use tracing::warn;
|
||||
use url::Url;
|
||||
|
||||
pub static CLIENT: Lazy<Client> = Lazy::new(Client::new);
|
||||
|
@ -208,11 +209,12 @@ where
|
|||
T: for<'de> Deserialize<'de>,
|
||||
{
|
||||
let res = req.send().await?;
|
||||
if res.status() == StatusCode::OK {
|
||||
Ok(res.json().await?)
|
||||
let status = res.status();
|
||||
let text = res.text().await?;
|
||||
if status == StatusCode::OK {
|
||||
Ok(serde_json::from_str(&text).map_err(|e| anyhow!("Json error on {text}: {e}"))?)
|
||||
} else {
|
||||
let text = res.text().await?;
|
||||
Err(anyhow!("Post API response {text}").into())
|
||||
Err(anyhow!("API error: {text}").into())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -229,10 +231,14 @@ pub async fn follow_instance(api_instance: &str, follow_instance: &str) -> MyRes
|
|||
id: instance_resolved.id,
|
||||
};
|
||||
// cant use post helper because follow doesnt return json
|
||||
CLIENT
|
||||
let res = CLIENT
|
||||
.post(format!("http://{}/api/v1/instance/follow", api_instance))
|
||||
.form(&follow_form)
|
||||
.send()
|
||||
.await?;
|
||||
Ok(())
|
||||
if res.status() == StatusCode::OK {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(anyhow!("API error: {}", res.text().await?).into())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue