mirror of
https://github.com/versia-pub/activitypub.git
synced 2025-12-06 06:38:20 +01:00
[feat]diagnostic messages
This commit is contained in:
parent
775c1198c3
commit
98732a5c06
|
|
@ -74,6 +74,7 @@ async fn main() -> actix_web::Result<(), anyhow::Error> {
|
||||||
let user = entities::user::ActiveModel {
|
let user = entities::user::ActiveModel {
|
||||||
id: Set(ap_id.into()),
|
id: Set(ap_id.into()),
|
||||||
username: Set(username),
|
username: Set(username),
|
||||||
|
name: Set("Test account <3".to_string()),
|
||||||
inbox: Set(inbox.to_string()),
|
inbox: Set(inbox.to_string()),
|
||||||
public_key: Set(keypair.public_key.clone()),
|
public_key: Set(keypair.public_key.clone()),
|
||||||
private_key: Set(Some(keypair.private_key.clone())),
|
private_key: Set(Some(keypair.private_key.clone())),
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ use activitypub_federation::{
|
||||||
use chrono::{prelude, DateTime, Utc};
|
use chrono::{prelude, DateTime, Utc};
|
||||||
use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, QueryFilter, Set};
|
use sea_orm::{ActiveModelTrait, ColumnTrait, EntityTrait, QueryFilter, Set};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use tracing::info;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
|
@ -64,6 +65,9 @@ pub struct Person {
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: PersonType,
|
kind: PersonType,
|
||||||
preferred_username: String,
|
preferred_username: String,
|
||||||
|
name: String,
|
||||||
|
summary: Option<String>,
|
||||||
|
url: Url,
|
||||||
id: ObjectId<user::Model>,
|
id: ObjectId<user::Model>,
|
||||||
inbox: Url,
|
inbox: Url,
|
||||||
public_key: PublicKey,
|
public_key: PublicKey,
|
||||||
|
|
@ -97,6 +101,9 @@ impl Object for user::Model {
|
||||||
id: Url::parse(&self.id).unwrap().into(),
|
id: Url::parse(&self.id).unwrap().into(),
|
||||||
inbox: Url::parse(&self.inbox).unwrap(),
|
inbox: Url::parse(&self.inbox).unwrap(),
|
||||||
public_key: self.public_key(),
|
public_key: self.public_key(),
|
||||||
|
name: self.name.clone(),
|
||||||
|
summary: self.summary.clone(),
|
||||||
|
url: Url::parse(&self.url).unwrap(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -116,13 +123,22 @@ impl Object for user::Model {
|
||||||
let model = user::ActiveModel {
|
let model = user::ActiveModel {
|
||||||
id: Set(json.id.to_string()),
|
id: Set(json.id.to_string()),
|
||||||
username: Set(json.preferred_username),
|
username: Set(json.preferred_username),
|
||||||
|
name: Set(json.name),
|
||||||
inbox: Set(json.inbox.to_string()),
|
inbox: Set(json.inbox.to_string()),
|
||||||
public_key: Set(json.public_key.public_key_pem),
|
public_key: Set(json.public_key.public_key_pem),
|
||||||
local: Set(false),
|
local: Set(false),
|
||||||
|
summary: Set(json.summary),
|
||||||
|
url: Set(json.url.to_string()),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
let model = model.insert(_data.database_connection.as_ref()).await?;
|
let model = model.insert(_data.database_connection.as_ref()).await;
|
||||||
Ok(model)
|
if let Err(err) = model {
|
||||||
|
eprintln!("Error inserting user: {:?}", err);
|
||||||
|
Err(err.into())
|
||||||
|
} else {
|
||||||
|
info!("User inserted: {:?}", model.as_ref().unwrap());
|
||||||
|
Ok(model.unwrap())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ use activitypub_federation::{
|
||||||
use activitystreams_kinds::link::MentionType;
|
use activitystreams_kinds::link::MentionType;
|
||||||
use sea_orm::{ActiveModelTrait, Set};
|
use sea_orm::{ActiveModelTrait, Set};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use tracing::info;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||||
|
|
@ -88,7 +89,15 @@ impl Object for post::Model {
|
||||||
};
|
};
|
||||||
let post = post
|
let post = post
|
||||||
.insert(data.app_data().database_connection.clone().as_ref())
|
.insert(data.app_data().database_connection.clone().as_ref())
|
||||||
.await?;
|
.await;
|
||||||
|
|
||||||
|
if let Err(err) = post {
|
||||||
|
eprintln!("Error inserting post: {:?}", err);
|
||||||
|
return Err(err.into());
|
||||||
|
}
|
||||||
|
info!("Post inserted: {:?}", post.as_ref().unwrap());
|
||||||
|
|
||||||
|
let post = post.unwrap();
|
||||||
|
|
||||||
let mention = Mention {
|
let mention = Mention {
|
||||||
href: Url::parse(&creator.id)?,
|
href: Url::parse(&creator.id)?,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue