2024-03-16 03:27:36 +01:00
|
|
|
pub mod user;
|
2024-03-16 05:45:58 +01:00
|
|
|
pub mod object;
|
2023-12-30 05:08:05 +01:00
|
|
|
pub mod activity;
|
2024-03-16 05:45:58 +01:00
|
|
|
|
2024-03-16 20:09:06 +01:00
|
|
|
#[derive(Debug, Clone, thiserror::Error)]
|
|
|
|
#[error("missing required field: '{0}'")]
|
2024-03-19 01:00:44 +01:00
|
|
|
pub struct FieldError(pub &'static str);
|
2024-03-16 20:09:06 +01:00
|
|
|
|
2024-03-16 05:45:58 +01:00
|
|
|
pub async fn faker(db: &sea_orm::DatabaseConnection) -> Result<(), sea_orm::DbErr> {
|
|
|
|
use sea_orm::EntityTrait;
|
|
|
|
|
|
|
|
user::Entity::insert(user::ActiveModel {
|
|
|
|
id: sea_orm::Set("http://localhost:3000/users/root".into()),
|
|
|
|
name: sea_orm::Set("root".into()),
|
|
|
|
actor_type: sea_orm::Set(super::activitystream::types::ActorType::Person),
|
|
|
|
}).exec(db).await?;
|
|
|
|
|
|
|
|
object::Entity::insert(object::ActiveModel {
|
|
|
|
id: sea_orm::Set("http://localhost:3000/objects/4e28d30b-33c1-4336-918b-6fbe592bdd44".into()),
|
|
|
|
name: sea_orm::Set(None),
|
2024-03-19 01:00:44 +01:00
|
|
|
object_type: sea_orm::Set(crate::activitystream::types::StatusType::Note),
|
2024-03-16 05:45:58 +01:00
|
|
|
attributed_to: sea_orm::Set(Some("http://localhost:3000/users/root".into())),
|
|
|
|
summary: sea_orm::Set(None),
|
|
|
|
content: sea_orm::Set(Some("Hello world!".into())),
|
|
|
|
published: sea_orm::Set(chrono::Utc::now()),
|
|
|
|
}).exec(db).await?;
|
|
|
|
|
|
|
|
activity::Entity::insert(activity::ActiveModel {
|
|
|
|
id: sea_orm::Set("http://localhost:3000/activities/ebac57e1-9828-438c-be34-a44a52de7641".into()),
|
|
|
|
activity_type: sea_orm::Set(crate::activitystream::types::ActivityType::Create),
|
|
|
|
actor: sea_orm::Set("http://localhost:3000/users/root".into()),
|
|
|
|
object: sea_orm::Set(Some("http://localhost:3000/obkects/4e28d30b-33c1-4336-918b-6fbe592bdd44".into())),
|
|
|
|
target: sea_orm::Set(None),
|
|
|
|
published: sea_orm::Set(chrono::Utc::now()),
|
|
|
|
}).exec(db).await?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|