1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-11-22 06:31:09 +00:00

remove unused typedef

This commit is contained in:
Felix Ableitner 2024-02-08 11:40:27 +01:00
parent 334dc3826f
commit 0c45fe3eba
24 changed files with 82 additions and 95 deletions

View file

@ -1,7 +1,7 @@
use crate::backend::database::article::DbArticleForm;
use crate::backend::database::conflict::{DbConflict, DbConflictForm};
use crate::backend::database::edit::DbEditForm;
use crate::backend::database::MyDataHandle;
use crate::backend::database::IbisData;
use crate::backend::error::MyResult;
use crate::backend::federation::activities::create_article::CreateArticle;
use crate::backend::federation::activities::submit_article_update;
@ -27,7 +27,7 @@ use diffy::create_patch;
#[debug_handler]
pub(in crate::backend::api) async fn create_article(
Extension(user): Extension<LocalUserView>,
data: Data<MyDataHandle>,
data: Data<IbisData>,
Form(create_article): Form<CreateArticleData>,
) -> MyResult<Json<ArticleView>> {
if create_article.title.is_empty() {
@ -77,7 +77,7 @@ pub(in crate::backend::api) async fn create_article(
#[debug_handler]
pub(in crate::backend::api) async fn edit_article(
Extension(user): Extension<LocalUserView>,
data: Data<MyDataHandle>,
data: Data<IbisData>,
Form(mut edit_form): Form<EditArticleData>,
) -> MyResult<Json<Option<ApiConflict>>> {
// resolve conflict if any
@ -139,7 +139,7 @@ pub(in crate::backend::api) async fn edit_article(
#[debug_handler]
pub(in crate::backend::api) async fn get_article(
Query(query): Query<GetArticleData>,
data: Data<MyDataHandle>,
data: Data<IbisData>,
) -> MyResult<Json<ArticleView>> {
match (query.title, query.id) {
(Some(title), None) => Ok(Json(DbArticle::read_view_title(
@ -160,7 +160,7 @@ pub(in crate::backend::api) async fn get_article(
#[debug_handler]
pub(in crate::backend::api) async fn list_articles(
Query(query): Query<ListArticlesData>,
data: Data<MyDataHandle>,
data: Data<IbisData>,
) -> MyResult<Json<Vec<DbArticle>>> {
let only_local = query.only_local.unwrap_or(false);
Ok(Json(DbArticle::read_all(only_local, &data.db_connection)?))
@ -171,7 +171,7 @@ pub(in crate::backend::api) async fn list_articles(
#[debug_handler]
pub(in crate::backend::api) async fn fork_article(
Extension(_user): Extension<LocalUserView>,
data: Data<MyDataHandle>,
data: Data<IbisData>,
Form(fork_form): Form<ForkArticleData>,
) -> MyResult<Json<ArticleView>> {
// TODO: lots of code duplicated from create_article(), can move it into helper
@ -221,7 +221,7 @@ pub(in crate::backend::api) async fn fork_article(
#[debug_handler]
pub(super) async fn resolve_article(
Query(query): Query<ResolveObject>,
data: Data<MyDataHandle>,
data: Data<IbisData>,
) -> MyResult<Json<ArticleView>> {
let article: DbArticle = ObjectId::from(query.id).dereference(&data).await?;
let edits = DbEdit::read_for_article(&article, &data.db_connection)?;
@ -237,7 +237,7 @@ pub(super) async fn resolve_article(
#[debug_handler]
pub(super) async fn search_article(
Query(query): Query<SearchArticleData>,
data: Data<MyDataHandle>,
data: Data<IbisData>,
) -> MyResult<Json<Vec<DbArticle>>> {
let article = DbArticle::search(&query.query, &data.db_connection)?;
Ok(Json(article))

View file

@ -1,4 +1,4 @@
use crate::backend::database::MyDataHandle;
use crate::backend::database::IbisData;
use crate::backend::error::MyResult;
use crate::backend::federation::activities::follow::Follow;
use crate::common::{DbInstance, InstanceView, ResolveObject};
@ -13,7 +13,7 @@ use axum_macros::debug_handler;
/// Retrieve the local instance info.
#[debug_handler]
pub(in crate::backend::api) async fn get_local_instance(
data: Data<MyDataHandle>,
data: Data<IbisData>,
) -> MyResult<Json<InstanceView>> {
let local_instance = DbInstance::read_local_view(&data.db_connection)?;
Ok(Json(local_instance))
@ -24,7 +24,7 @@ pub(in crate::backend::api) async fn get_local_instance(
#[debug_handler]
pub(in crate::backend::api) async fn follow_instance(
Extension(user): Extension<LocalUserView>,
data: Data<MyDataHandle>,
data: Data<IbisData>,
Form(query): Form<FollowInstance>,
) -> MyResult<()> {
let target = DbInstance::read(query.id, &data.db_connection)?;
@ -40,7 +40,7 @@ pub(in crate::backend::api) async fn follow_instance(
#[debug_handler]
pub(super) async fn resolve_instance(
Query(query): Query<ResolveObject>,
data: Data<MyDataHandle>,
data: Data<IbisData>,
) -> MyResult<Json<DbInstance>> {
let instance: DbInstance = ObjectId::from(query.id).dereference(&data).await?;
Ok(Json(instance))

View file

@ -9,7 +9,7 @@ use crate::backend::api::user::validate;
use crate::backend::api::user::{login_user, logout_user};
use crate::backend::api::user::{my_profile, AUTH_COOKIE};
use crate::backend::database::conflict::DbConflict;
use crate::backend::database::MyDataHandle;
use crate::backend::database::IbisData;
use crate::backend::error::MyResult;
use crate::common::ApiConflict;
use crate::common::LocalUserView;
@ -54,7 +54,7 @@ pub fn api_routes() -> Router {
}
async fn auth<B>(
data: Data<MyDataHandle>,
data: Data<IbisData>,
jar: CookieJar,
mut request: Request<B>,
next: Next<B>,
@ -74,7 +74,7 @@ async fn auth<B>(
#[debug_handler]
async fn edit_conflicts(
Extension(user): Extension<LocalUserView>,
data: Data<MyDataHandle>,
data: Data<IbisData>,
) -> MyResult<Json<Vec<ApiConflict>>> {
let conflicts = DbConflict::list(&user.local_user, &data.db_connection)?;
let conflicts: Vec<ApiConflict> = try_join_all(conflicts.into_iter().map(|c| {

View file

@ -1,4 +1,4 @@
use crate::backend::database::{read_jwt_secret, MyDataHandle};
use crate::backend::database::{read_jwt_secret, IbisData};
use crate::backend::error::MyResult;
use crate::common::{DbLocalUser, DbPerson, LocalUserView, LoginUserData, RegisterUserData};
use activitypub_federation::config::Data;
@ -29,7 +29,7 @@ struct Claims {
pub exp: u64,
}
fn generate_login_token(local_user: &DbLocalUser, data: &Data<MyDataHandle>) -> MyResult<String> {
fn generate_login_token(local_user: &DbLocalUser, data: &Data<IbisData>) -> MyResult<String> {
let hostname = data.domain().to_string();
let claims = Claims {
sub: local_user.id.to_string(),
@ -44,7 +44,7 @@ fn generate_login_token(local_user: &DbLocalUser, data: &Data<MyDataHandle>) ->
Ok(jwt)
}
pub async fn validate(jwt: &str, data: &Data<MyDataHandle>) -> MyResult<LocalUserView> {
pub async fn validate(jwt: &str, data: &Data<IbisData>) -> MyResult<LocalUserView> {
let validation = Validation::default();
let secret = read_jwt_secret(data)?;
let key = DecodingKey::from_secret(secret.as_bytes());
@ -54,7 +54,7 @@ pub async fn validate(jwt: &str, data: &Data<MyDataHandle>) -> MyResult<LocalUse
#[debug_handler]
pub(in crate::backend::api) async fn register_user(
data: Data<MyDataHandle>,
data: Data<IbisData>,
jar: CookieJar,
Form(form): Form<RegisterUserData>,
) -> MyResult<(CookieJar, Json<LocalUserView>)> {
@ -69,7 +69,7 @@ pub(in crate::backend::api) async fn register_user(
#[debug_handler]
pub(in crate::backend::api) async fn login_user(
data: Data<MyDataHandle>,
data: Data<IbisData>,
jar: CookieJar,
Form(form): Form<LoginUserData>,
) -> MyResult<(CookieJar, Json<LocalUserView>)> {
@ -83,7 +83,7 @@ pub(in crate::backend::api) async fn login_user(
Ok((jar, Json(user)))
}
fn create_cookie(jwt: String, data: &Data<MyDataHandle>) -> Cookie<'static> {
fn create_cookie(jwt: String, data: &Data<IbisData>) -> Cookie<'static> {
let mut domain = data.domain().to_string();
// remove port from domain
if domain.contains(':') {
@ -103,7 +103,7 @@ fn create_cookie(jwt: String, data: &Data<MyDataHandle>) -> Cookie<'static> {
#[debug_handler]
pub(in crate::backend::api) async fn my_profile(
data: Data<MyDataHandle>,
data: Data<IbisData>,
jar: CookieJar,
) -> MyResult<Json<LocalUserView>> {
let jwt = jar.get(AUTH_COOKIE).map(|c| c.value());
@ -116,7 +116,7 @@ pub(in crate::backend::api) async fn my_profile(
#[debug_handler]
pub(in crate::backend::api) async fn logout_user(
data: Data<MyDataHandle>,
data: Data<IbisData>,
jar: CookieJar,
) -> MyResult<CookieJar> {
let jar = jar.remove(create_cookie(String::new(), &data));

View file

@ -1,5 +1,5 @@
use crate::backend::database::schema::conflict;
use crate::backend::database::MyDataHandle;
use crate::backend::database::IbisData;
use crate::backend::error::MyResult;
use crate::backend::federation::activities::submit_article_update;
use crate::backend::utils::generate_article_version;
@ -63,10 +63,7 @@ impl DbConflict {
Ok(delete(conflict::table.find(id)).get_result(conn.deref_mut())?)
}
pub async fn to_api_conflict(
&self,
data: &Data<MyDataHandle>,
) -> MyResult<Option<ApiConflict>> {
pub async fn to_api_conflict(&self, data: &Data<IbisData>) -> MyResult<Option<ApiConflict>> {
let article = DbArticle::read(self.article_id, &data.db_connection)?;
// Make sure to get latest version from origin so that all conflicts can be resolved
let original_article = article.ap_id.dereference_forced(data).await?;

View file

@ -1,5 +1,5 @@
use crate::backend::database::schema::{instance, instance_follow};
use crate::backend::database::MyDataHandle;
use crate::backend::database::IbisData;
use crate::backend::error::MyResult;
use crate::backend::federation::objects::articles_collection::DbArticleCollection;
use crate::common::{DbInstance, DbPerson, InstanceView};
@ -46,7 +46,7 @@ impl DbInstance {
pub fn read_from_ap_id(
ap_id: &ObjectId<DbInstance>,
data: &Data<MyDataHandle>,
data: &Data<IbisData>,
) -> MyResult<DbInstance> {
let mut conn = data.db_connection.lock().unwrap();
Ok(instance::table
@ -75,7 +75,7 @@ impl DbInstance {
follower: &DbPerson,
instance: &DbInstance,
pending_: bool,
data: &Data<MyDataHandle>,
data: &Data<IbisData>,
) -> MyResult<()> {
use instance_follow::dsl::{follower_id, instance_id, pending};
let mut conn = data.db_connection.lock().unwrap();

View file

@ -1,13 +1,11 @@
use diesel::PgConnection;
use std::ops::Deref;
use std::sync::{Arc, Mutex};
// TODO: can remove this
pub type MyDataHandle = IbisData;
use crate::backend::database::schema::jwt_secret;
use crate::backend::error::MyResult;
use crate::config::IbisConfig;
use diesel::PgConnection;
use diesel::{QueryDsl, RunQueryDsl};
use std::ops::Deref;
use std::ops::DerefMut;
use std::sync::{Arc, Mutex};
pub mod article;
pub mod conflict;

View file

@ -1,6 +1,6 @@
use crate::backend::database::schema::{instance, instance_follow};
use crate::backend::database::schema::{local_user, person};
use crate::backend::database::{IbisData, MyDataHandle};
use crate::backend::database::IbisData;
use crate::backend::error::MyResult;
use crate::common::{DbInstance, DbLocalUser, DbPerson, LocalUserView};
use activitypub_federation::config::Data;
@ -46,7 +46,7 @@ impl DbPerson {
.get_result::<DbPerson>(conn.deref_mut())?)
}
pub fn read(id: i32, data: &Data<MyDataHandle>) -> MyResult<DbPerson> {
pub fn read(id: i32, data: &Data<IbisData>) -> MyResult<DbPerson> {
let mut conn = data.db_connection.lock().unwrap();
Ok(person::table.find(id).get_result(conn.deref_mut())?)
}
@ -95,7 +95,7 @@ impl DbPerson {
pub fn read_from_ap_id(
ap_id: &ObjectId<DbPerson>,
data: &Data<MyDataHandle>,
data: &Data<IbisData>,
) -> MyResult<DbPerson> {
let mut conn = data.db_connection.lock().unwrap();
Ok(person::table
@ -103,10 +103,7 @@ impl DbPerson {
.get_result(conn.deref_mut())?)
}
pub fn read_local_from_name(
username: &str,
data: &Data<MyDataHandle>,
) -> MyResult<LocalUserView> {
pub fn read_local_from_name(username: &str, data: &Data<IbisData>) -> MyResult<LocalUserView> {
let mut conn = data.db_connection.lock().unwrap();
let (person, local_user) = person::table
.inner_join(local_user::table)
@ -122,7 +119,7 @@ impl DbPerson {
})
}
pub fn read_local_from_id(id: i32, data: &Data<MyDataHandle>) -> MyResult<LocalUserView> {
pub fn read_local_from_id(id: i32, data: &Data<IbisData>) -> MyResult<LocalUserView> {
let mut conn = data.db_connection.lock().unwrap();
let (person, local_user) = person::table
.inner_join(local_user::table)

View file

@ -1,7 +1,7 @@
use crate::backend::error::MyResult;
use crate::backend::federation::send_activity;
use crate::backend::utils::generate_activity_id;
use crate::backend::{database::MyDataHandle, federation::activities::follow::Follow};
use crate::backend::{database::IbisData, federation::activities::follow::Follow};
use crate::common::DbInstance;
use activitypub_federation::traits::Actor;
use activitypub_federation::{
@ -24,7 +24,7 @@ impl Accept {
pub async fn send(
local_instance: DbInstance,
object: Follow,
data: &Data<MyDataHandle>,
data: &Data<IbisData>,
) -> MyResult<()> {
let id = generate_activity_id(local_instance.ap_id.inner())?;
let follower = object.actor.dereference(data).await?;
@ -47,7 +47,7 @@ impl Accept {
#[async_trait::async_trait]
impl ActivityHandler for Accept {
type DataType = MyDataHandle;
type DataType = IbisData;
type Error = crate::backend::error::Error;
fn id(&self) -> &Url {

View file

@ -1,4 +1,4 @@
use crate::backend::database::MyDataHandle;
use crate::backend::database::IbisData;
use crate::backend::error::MyResult;
use crate::backend::federation::objects::article::ApubArticle;
use crate::backend::utils::generate_activity_id;
@ -27,7 +27,7 @@ pub struct CreateArticle {
}
impl CreateArticle {
pub async fn send_to_followers(article: DbArticle, data: &Data<MyDataHandle>) -> MyResult<()> {
pub async fn send_to_followers(article: DbArticle, data: &Data<IbisData>) -> MyResult<()> {
let local_instance = DbInstance::read_local_instance(&data.db_connection)?;
let object = article.clone().into_json(data).await?;
let id = generate_activity_id(local_instance.ap_id.inner())?;
@ -47,7 +47,7 @@ impl CreateArticle {
}
#[async_trait::async_trait]
impl ActivityHandler for CreateArticle {
type DataType = MyDataHandle;
type DataType = IbisData;
type Error = crate::backend::error::Error;
fn id(&self) -> &Url {

View file

@ -1,7 +1,7 @@
use crate::backend::error::MyResult;
use crate::backend::federation::send_activity;
use crate::backend::{
database::MyDataHandle, federation::activities::accept::Accept, generate_activity_id,
database::IbisData, federation::activities::accept::Accept, generate_activity_id,
};
use crate::common::DbInstance;
use crate::common::DbPerson;
@ -26,7 +26,7 @@ pub struct Follow {
}
impl Follow {
pub async fn send(actor: DbPerson, to: DbInstance, data: &Data<MyDataHandle>) -> MyResult<()> {
pub async fn send(actor: DbPerson, to: DbInstance, data: &Data<IbisData>) -> MyResult<()> {
let id = generate_activity_id(actor.ap_id.inner())?;
let follow = Follow {
actor: actor.ap_id.clone(),
@ -41,7 +41,7 @@ impl Follow {
#[async_trait::async_trait]
impl ActivityHandler for Follow {
type DataType = MyDataHandle;
type DataType = IbisData;
type Error = crate::backend::error::Error;
fn id(&self) -> &Url {

View file

@ -1,5 +1,5 @@
use crate::backend::database::edit::DbEditForm;
use crate::backend::database::MyDataHandle;
use crate::backend::database::IbisData;
use crate::backend::error::Error;
use crate::backend::federation::activities::update_local_article::UpdateLocalArticle;
use crate::backend::federation::activities::update_remote_article::UpdateRemoteArticle;
@ -22,7 +22,7 @@ pub async fn submit_article_update(
previous_version: EditVersion,
original_article: &DbArticle,
creator_id: i32,
data: &Data<MyDataHandle>,
data: &Data<IbisData>,
) -> Result<(), Error> {
let form = DbEditForm::new(
original_article,

View file

@ -1,5 +1,5 @@
use crate::backend::database::conflict::{DbConflict, DbConflictForm};
use crate::backend::database::MyDataHandle;
use crate::backend::database::IbisData;
use crate::backend::error::MyResult;
use crate::backend::federation::objects::edit::ApubEdit;
use crate::backend::utils::generate_activity_id;
@ -31,7 +31,7 @@ impl RejectEdit {
pub async fn send(
edit: ApubEdit,
user_instance: DbInstance,
data: &Data<MyDataHandle>,
data: &Data<IbisData>,
) -> MyResult<()> {
let local_instance = DbInstance::read_local_instance(&data.db_connection)?;
let id = generate_activity_id(local_instance.ap_id.inner())?;
@ -55,7 +55,7 @@ impl RejectEdit {
#[async_trait::async_trait]
impl ActivityHandler for RejectEdit {
type DataType = MyDataHandle;
type DataType = IbisData;
type Error = crate::backend::error::Error;
fn id(&self) -> &Url {

View file

@ -1,4 +1,4 @@
use crate::backend::database::MyDataHandle;
use crate::backend::database::IbisData;
use crate::backend::error::MyResult;
use crate::backend::federation::objects::article::ApubArticle;
@ -33,7 +33,7 @@ impl UpdateLocalArticle {
pub async fn send(
article: DbArticle,
extra_recipients: Vec<DbInstance>,
data: &Data<MyDataHandle>,
data: &Data<IbisData>,
) -> MyResult<()> {
debug_assert!(article.local);
let local_instance = DbInstance::read_local_instance(&data.db_connection)?;
@ -56,7 +56,7 @@ impl UpdateLocalArticle {
#[async_trait::async_trait]
impl ActivityHandler for UpdateLocalArticle {
type DataType = MyDataHandle;
type DataType = IbisData;
type Error = crate::backend::error::Error;
fn id(&self) -> &Url {

View file

@ -1,4 +1,4 @@
use crate::backend::database::MyDataHandle;
use crate::backend::database::IbisData;
use crate::backend::error::MyResult;
use crate::backend::federation::activities::reject::RejectEdit;
@ -37,7 +37,7 @@ impl UpdateRemoteArticle {
pub async fn send(
edit: DbEdit,
article_instance: DbInstance,
data: &Data<MyDataHandle>,
data: &Data<IbisData>,
) -> MyResult<()> {
let local_instance = DbInstance::read_local_instance(&data.db_connection)?;
let id = generate_activity_id(local_instance.ap_id.inner())?;
@ -61,7 +61,7 @@ impl UpdateRemoteArticle {
#[async_trait::async_trait]
impl ActivityHandler for UpdateRemoteArticle {
type DataType = MyDataHandle;
type DataType = IbisData;
type Error = crate::backend::error::Error;
fn id(&self) -> &Url {

View file

@ -1,4 +1,4 @@
use crate::backend::database::MyDataHandle;
use crate::backend::database::IbisData;
use crate::config::IbisConfig;
use activitypub_federation::activity_sending::SendActivityTask;
use activitypub_federation::config::{Data, UrlVerifier};
@ -19,7 +19,7 @@ pub async fn send_activity<Activity, ActorType: Actor>(
actor: &ActorType,
activity: Activity,
recipients: Vec<Url>,
data: &Data<MyDataHandle>,
data: &Data<IbisData>,
) -> Result<(), <Activity as ActivityHandler>::Error>
where
Activity: ActivityHandler + Serialize + Debug + Send + Sync,

View file

@ -1,5 +1,5 @@
use crate::backend::database::article::DbArticleForm;
use crate::backend::database::MyDataHandle;
use crate::backend::database::IbisData;
use crate::backend::error::Error;
use crate::backend::federation::objects::edits_collection::DbEditCollection;
use crate::common::DbArticle;
@ -33,7 +33,7 @@ pub struct ApubArticle {
#[async_trait::async_trait]
impl Object for DbArticle {
type DataType = MyDataHandle;
type DataType = IbisData;
type Kind = ApubArticle;
type Error = Error;

View file

@ -1,4 +1,4 @@
use crate::backend::database::MyDataHandle;
use crate::backend::database::IbisData;
use crate::backend::error::Error;
use crate::backend::federation::objects::article::ApubArticle;
use crate::common::DbInstance;
@ -29,7 +29,7 @@ pub struct DbArticleCollection(Vec<DbArticle>);
#[async_trait::async_trait]
impl Collection for DbArticleCollection {
type Owner = DbInstance;
type DataType = MyDataHandle;
type DataType = IbisData;
type Kind = ArticleCollection;
type Error = Error;

View file

@ -1,5 +1,5 @@
use crate::backend::database::edit::DbEditForm;
use crate::backend::database::MyDataHandle;
use crate::backend::database::IbisData;
use crate::backend::error::Error;
use crate::common::DbPerson;
use crate::common::EditVersion;
@ -35,7 +35,7 @@ pub struct ApubEdit {
#[async_trait::async_trait]
impl Object for DbEdit {
type DataType = MyDataHandle;
type DataType = IbisData;
type Kind = ApubEdit;
type Error = Error;

View file

@ -1,4 +1,4 @@
use crate::backend::database::MyDataHandle;
use crate::backend::database::IbisData;
use crate::backend::error::Error;
use crate::backend::federation::objects::edit::ApubEdit;
use crate::common::DbArticle;
@ -30,7 +30,7 @@ pub struct DbEditCollection(pub Vec<DbEdit>);
#[async_trait::async_trait]
impl Collection for DbEditCollection {
type Owner = DbArticle;
type DataType = MyDataHandle;
type DataType = IbisData;
type Kind = ApubEditCollection;
type Error = Error;

View file

@ -1,5 +1,5 @@
use crate::backend::database::instance::DbInstanceForm;
use crate::backend::database::MyDataHandle;
use crate::backend::database::IbisData;
use crate::backend::error::Error;
use crate::backend::federation::objects::articles_collection::DbArticleCollection;
use crate::backend::federation::send_activity;
@ -38,7 +38,7 @@ impl DbInstance {
Ok(Url::parse(&format!("{}/followers", self.ap_id.inner()))?)
}
pub fn follower_ids(&self, data: &Data<MyDataHandle>) -> MyResult<Vec<Url>> {
pub fn follower_ids(&self, data: &Data<IbisData>) -> MyResult<Vec<Url>> {
Ok(DbInstance::read_followers(self.id, &data.db_connection)?
.into_iter()
.map(|f| f.ap_id.into())
@ -49,7 +49,7 @@ impl DbInstance {
&self,
activity: Activity,
extra_recipients: Vec<DbInstance>,
data: &Data<MyDataHandle>,
data: &Data<IbisData>,
) -> Result<(), <Activity as ActivityHandler>::Error>
where
Activity: ActivityHandler + Serialize + Debug + Send + Sync,
@ -72,7 +72,7 @@ impl DbInstance {
#[async_trait::async_trait]
impl Object for DbInstance {
type DataType = MyDataHandle;
type DataType = IbisData;
type Kind = ApubInstance;
type Error = Error;

View file

@ -1,5 +1,5 @@
use crate::backend::database::user::DbPersonForm;
use crate::backend::database::MyDataHandle;
use crate::backend::database::IbisData;
use crate::backend::error::Error;
use crate::common::DbPerson;
use activitypub_federation::kinds::actor::PersonType;
@ -27,7 +27,7 @@ pub struct ApubUser {
#[async_trait::async_trait]
impl Object for DbPerson {
type DataType = MyDataHandle;
type DataType = IbisData;
type Kind = ApubUser;
type Error = Error;

View file

@ -1,4 +1,4 @@
use crate::backend::database::MyDataHandle;
use crate::backend::database::IbisData;
use crate::backend::error::Error;
use crate::backend::error::MyResult;
use crate::backend::federation::activities::accept::Accept;
@ -45,7 +45,7 @@ pub fn federation_routes() -> Router {
#[debug_handler]
async fn http_get_instance(
data: Data<MyDataHandle>,
data: Data<IbisData>,
) -> MyResult<FederationJson<WithContext<ApubInstance>>> {
let local_instance = DbInstance::read_local_instance(&data.db_connection)?;
let json_instance = local_instance.into_json(&data).await?;
@ -55,7 +55,7 @@ async fn http_get_instance(
#[debug_handler]
async fn http_get_person(
Path(name): Path<String>,
data: Data<MyDataHandle>,
data: Data<IbisData>,
) -> MyResult<FederationJson<WithContext<ApubUser>>> {
let person = DbPerson::read_local_from_name(&name, &data)?.person;
let json_person = person.into_json(&data).await?;
@ -64,7 +64,7 @@ async fn http_get_person(
#[debug_handler]
async fn http_get_all_articles(
data: Data<MyDataHandle>,
data: Data<IbisData>,
) -> MyResult<FederationJson<WithContext<ArticleCollection>>> {
let local_instance = DbInstance::read_local_instance(&data.db_connection)?;
let collection = DbArticleCollection::read_local(&local_instance, &data).await?;
@ -74,7 +74,7 @@ async fn http_get_all_articles(
#[debug_handler]
async fn http_get_article(
Path(title): Path<String>,
data: Data<MyDataHandle>,
data: Data<IbisData>,
) -> MyResult<FederationJson<WithContext<ApubArticle>>> {
let article = DbArticle::read_local_title(&title, &data.db_connection)?;
let json = article.into_json(&data).await?;
@ -84,7 +84,7 @@ async fn http_get_article(
#[debug_handler]
async fn http_get_article_edits(
Path(title): Path<String>,
data: Data<MyDataHandle>,
data: Data<IbisData>,
) -> MyResult<FederationJson<WithContext<ApubEditCollection>>> {
let article = DbArticle::read_local_title(&title, &data.db_connection)?;
let json = DbEditCollection::read_local(&article, &data).await?;
@ -106,13 +106,10 @@ pub enum InboxActivities {
#[debug_handler]
pub async fn http_post_inbox(
data: Data<MyDataHandle>,
data: Data<IbisData>,
activity_data: ActivityData,
) -> impl IntoResponse {
receive_activity::<WithContext<InboxActivities>, UserOrInstance, MyDataHandle>(
activity_data,
&data,
)
receive_activity::<WithContext<InboxActivities>, UserOrInstance, IbisData>(activity_data, &data)
.await
}
@ -137,7 +134,7 @@ pub enum PersonOrInstanceType {
#[async_trait::async_trait]
impl Object for UserOrInstance {
type DataType = MyDataHandle;
type DataType = IbisData;
type Kind = PersonOrInstance;
type Error = Error;

View file

@ -104,11 +104,9 @@ async fn test_follow_instance() -> MyResult<()> {
assert_eq!(0, beta_instance.followers.len());
data.alpha.follow_instance(&data.beta.hostname).await?;
dbg!(&data.alpha.hostname, &data.beta.hostname);
// check that follow was federated
let alpha_user = data.alpha.my_profile().await?;
dbg!(&alpha_user);
assert_eq!(1, alpha_user.following.len());
assert_eq!(beta_instance.instance.ap_id, alpha_user.following[0].ap_id);