1
0
Fork 0
mirror of https://github.com/Nutomic/ibis.git synced 2024-12-03 17:11:08 +00:00

Use nightly cargo fmt for better imports formatting

This commit is contained in:
Felix Ableitner 2024-03-05 16:38:07 +01:00
parent b2b20dcd2a
commit d5ce966ea1
53 changed files with 613 additions and 442 deletions

4
.rustfmt.toml Normal file
View file

@ -0,0 +1,4 @@
edition = "2021"
imports_layout = "HorizontalVertical"
imports_granularity = "Crate"
group_imports = "One"

View file

@ -3,13 +3,14 @@ variables:
steps:
cargo_fmt:
image: *rust_image
image: rustlang/rust:nightly
environment:
# store cargo data in repo folder so that it gets cached between steps
CARGO_HOME: .cargo_home
commands:
- rustup component add rustfmt
- cargo fmt -- --check
- cargo +nightly fmt -- --check
check_config_defaults_updated:
image: *rust_image

View file

@ -1,27 +1,38 @@
use crate::backend::database::article::DbArticleForm;
use crate::backend::database::conflict::{DbConflict, DbConflictForm};
use crate::backend::database::edit::DbEditForm;
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;
use crate::backend::utils::generate_article_version;
use crate::common::utils::extract_domain;
use crate::common::utils::http_protocol_str;
use crate::common::validation::can_edit_article;
use crate::common::{ApiConflict, ResolveObject};
use crate::common::{ArticleView, DbArticle, DbEdit};
use crate::common::{CreateArticleForm, EditArticleForm, EditVersion, ForkArticleForm};
use crate::common::{DbInstance, SearchArticleForm};
use crate::common::{GetArticleForm, ListArticlesForm};
use crate::common::{LocalUserView, ProtectArticleForm};
use activitypub_federation::config::Data;
use activitypub_federation::fetch::object_id::ObjectId;
use crate::{
backend::{
database::{
article::DbArticleForm,
conflict::{DbConflict, DbConflictForm},
edit::DbEditForm,
IbisData,
},
error::MyResult,
federation::activities::{create_article::CreateArticle, submit_article_update},
utils::generate_article_version,
},
common::{
utils::{extract_domain, http_protocol_str},
validation::can_edit_article,
ApiConflict,
ArticleView,
CreateArticleForm,
DbArticle,
DbEdit,
DbInstance,
EditArticleForm,
EditVersion,
ForkArticleForm,
GetArticleForm,
ListArticlesForm,
LocalUserView,
ProtectArticleForm,
ResolveObject,
SearchArticleForm,
},
};
use activitypub_federation::{config::Data, fetch::object_id::ObjectId};
use anyhow::anyhow;
use axum::extract::Query;
use axum::Extension;
use axum::Form;
use axum::Json;
use axum::{extract::Query, Extension, Form, Json};
use axum_macros::debug_handler;
use chrono::Utc;
use diffy::create_patch;

View file

@ -1,13 +1,9 @@
use crate::backend::database::IbisData;
use crate::backend::error::MyResult;
use crate::backend::federation::activities::follow::Follow;
use crate::common::{DbInstance, InstanceView, ResolveObject};
use crate::common::{FollowInstance, LocalUserView};
use activitypub_federation::config::Data;
use activitypub_federation::fetch::object_id::ObjectId;
use axum::extract::Query;
use axum::Extension;
use axum::{Form, Json};
use crate::{
backend::{database::IbisData, error::MyResult, federation::activities::follow::Follow},
common::{DbInstance, FollowInstance, InstanceView, LocalUserView, ResolveObject},
};
use activitypub_federation::{config::Data, fetch::object_id::ObjectId};
use axum::{extract::Query, Extension, Form, Json};
use axum_macros::debug_handler;
/// Retrieve the local instance info.

View file

@ -1,29 +1,42 @@
use crate::backend::api::article::protect_article;
use crate::backend::api::article::{
create_article, list_articles, resolve_article, search_article,
use crate::{
backend::{
api::{
article::{
create_article,
edit_article,
fork_article,
get_article,
list_articles,
protect_article,
resolve_article,
search_article,
},
instance::{follow_instance, get_local_instance, resolve_instance},
user::{
get_user,
login_user,
logout_user,
my_profile,
register_user,
validate,
AUTH_COOKIE,
},
},
database::{conflict::DbConflict, IbisData},
error::MyResult,
},
common::{ApiConflict, LocalUserView},
};
use crate::backend::api::article::{edit_article, fork_article, get_article};
use crate::backend::api::instance::get_local_instance;
use crate::backend::api::instance::{follow_instance, resolve_instance};
use crate::backend::api::user::validate;
use crate::backend::api::user::{get_user, register_user};
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::IbisData;
use crate::backend::error::MyResult;
use crate::common::ApiConflict;
use crate::common::LocalUserView;
use activitypub_federation::config::Data;
use axum::routing::{get, post};
use axum::{
http::Request,
http::StatusCode,
http::{Request, StatusCode},
middleware::{self, Next},
response::Response,
routing::{get, post},
Extension,
Json,
Router,
};
use axum::{Json, Router};
use axum_extra::extract::CookieJar;
use axum_macros::debug_handler;
use futures::future::try_join_all;

View file

@ -1,18 +1,26 @@
use crate::backend::database::{read_jwt_secret, IbisData};
use crate::backend::error::MyResult;
use crate::common::{DbPerson, GetUserForm, LocalUserView, LoginUserForm, RegisterUserForm};
use crate::{
backend::{
database::{read_jwt_secret, IbisData},
error::MyResult,
},
common::{DbPerson, GetUserForm, LocalUserView, LoginUserForm, RegisterUserForm},
};
use activitypub_federation::config::Data;
use anyhow::anyhow;
use axum::extract::Query;
use axum::{Form, Json};
use axum::{extract::Query, Form, Json};
use axum_extra::extract::cookie::{Cookie, CookieJar, Expiration, SameSite};
use axum_macros::debug_handler;
use bcrypt::verify;
use chrono::Utc;
use jsonwebtoken::DecodingKey;
use jsonwebtoken::Validation;
use jsonwebtoken::{decode, get_current_timestamp};
use jsonwebtoken::{encode, EncodingKey, Header};
use jsonwebtoken::{
decode,
encode,
get_current_timestamp,
DecodingKey,
EncodingKey,
Header,
Validation,
};
use serde::{Deserialize, Serialize};
use time::{Duration, OffsetDateTime};

View file

@ -1,17 +1,24 @@
use crate::backend::database::schema::{article, edit, instance};
use crate::backend::database::IbisData;
use crate::backend::error::MyResult;
use crate::backend::federation::objects::edits_collection::DbEditCollection;
use crate::common::DbEdit;
use crate::common::EditVersion;
use crate::common::{ArticleView, DbArticle};
use activitypub_federation::fetch::collection_id::CollectionId;
use activitypub_federation::fetch::object_id::ObjectId;
use diesel::dsl::max;
use diesel::ExpressionMethods;
use crate::{
backend::{
database::{
schema::{article, edit, instance},
IbisData,
},
error::MyResult,
federation::objects::edits_collection::DbEditCollection,
},
common::{ArticleView, DbArticle, DbEdit, EditVersion},
};
use activitypub_federation::fetch::{collection_id::CollectionId, object_id::ObjectId};
use diesel::{
insert_into, AsChangeset, BoolExpressionMethods, Insertable, PgTextExpressionMethods, QueryDsl,
dsl::max,
insert_into,
AsChangeset,
BoolExpressionMethods,
ExpressionMethods,
Insertable,
PgTextExpressionMethods,
QueryDsl,
RunQueryDsl,
};
use std::ops::DerefMut;

View file

@ -1,16 +1,23 @@
use crate::backend::database::schema::conflict;
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;
use crate::common::DbEdit;
use crate::common::DbLocalUser;
use crate::common::EditVersion;
use crate::common::{ApiConflict, DbArticle};
use crate::{
backend::{
database::{schema::conflict, IbisData},
error::MyResult,
federation::activities::submit_article_update,
utils::generate_article_version,
},
common::{ApiConflict, DbArticle, DbEdit, DbLocalUser, EditVersion},
};
use activitypub_federation::config::Data;
use diesel::ExpressionMethods;
use diesel::{
delete, insert_into, Identifiable, Insertable, QueryDsl, Queryable, RunQueryDsl, Selectable,
delete,
insert_into,
ExpressionMethods,
Identifiable,
Insertable,
QueryDsl,
Queryable,
RunQueryDsl,
Selectable,
};
use diffy::{apply, merge, Patch};
use serde::{Deserialize, Serialize};

View file

@ -1,12 +1,14 @@
use crate::backend::database::schema::{edit, person};
use crate::backend::error::MyResult;
use crate::backend::IbisData;
use crate::common::{DbArticle, DbEdit};
use crate::common::{EditVersion, EditView};
use crate::{
backend::{
database::schema::{edit, person},
error::MyResult,
IbisData,
},
common::{DbArticle, DbEdit, EditVersion, EditView},
};
use activitypub_federation::fetch::object_id::ObjectId;
use chrono::{DateTime, Utc};
use diesel::ExpressionMethods;
use diesel::{insert_into, AsChangeset, Insertable, QueryDsl, RunQueryDsl};
use diesel::{insert_into, AsChangeset, ExpressionMethods, Insertable, QueryDsl, RunQueryDsl};
use diffy::create_patch;
use std::ops::DerefMut;

View file

@ -1,16 +1,29 @@
use crate::backend::database::schema::{instance, instance_follow};
use crate::backend::database::IbisData;
use crate::backend::error::MyResult;
use crate::backend::federation::objects::articles_collection::DbArticleCollection;
use crate::common::{DbInstance, DbPerson, InstanceView};
use activitypub_federation::config::Data;
use activitypub_federation::fetch::collection_id::CollectionId;
use activitypub_federation::fetch::object_id::ObjectId;
use crate::{
backend::{
database::{
schema::{instance, instance_follow},
IbisData,
},
error::MyResult,
federation::objects::articles_collection::DbArticleCollection,
},
common::{DbInstance, DbPerson, InstanceView},
};
use activitypub_federation::{
config::Data,
fetch::{collection_id::CollectionId, object_id::ObjectId},
};
use chrono::{DateTime, Utc};
use diesel::ExpressionMethods;
use diesel::{insert_into, AsChangeset, Insertable, JoinOnDsl, QueryDsl, RunQueryDsl};
use std::fmt::Debug;
use std::ops::DerefMut;
use diesel::{
insert_into,
AsChangeset,
ExpressionMethods,
Insertable,
JoinOnDsl,
QueryDsl,
RunQueryDsl,
};
use std::{fmt::Debug, ops::DerefMut};
#[derive(Debug, Clone, Insertable, AsChangeset)]
#[diesel(table_name = instance, check_for_backend(diesel::pg::Pg))]

View file

@ -1,11 +1,10 @@
use crate::backend::config::IbisConfig;
use crate::backend::database::schema::jwt_secret;
use crate::backend::error::MyResult;
use diesel::r2d2::ConnectionManager;
use diesel::r2d2::Pool;
use diesel::PgConnection;
use diesel::{QueryDsl, RunQueryDsl};
use crate::backend::{config::IbisConfig, database::schema::jwt_secret, error::MyResult};
use diesel::{
r2d2::{ConnectionManager, Pool},
PgConnection,
QueryDsl,
RunQueryDsl,
};
use std::ops::DerefMut;
pub mod article;

View file

@ -1,18 +1,30 @@
use crate::backend::database::schema::{instance, instance_follow};
use crate::backend::database::schema::{local_user, person};
use crate::backend::database::IbisData;
use crate::backend::error::MyResult;
use crate::common::utils::http_protocol_str;
use crate::common::{DbInstance, DbLocalUser, DbPerson, LocalUserView};
use activitypub_federation::config::Data;
use activitypub_federation::fetch::object_id::ObjectId;
use activitypub_federation::http_signatures::generate_actor_keypair;
use bcrypt::hash;
use bcrypt::DEFAULT_COST;
use crate::{
backend::{
database::{
schema::{instance, instance_follow, local_user, person},
IbisData,
},
error::MyResult,
},
common::{utils::http_protocol_str, DbInstance, DbLocalUser, DbPerson, LocalUserView},
};
use activitypub_federation::{
config::Data,
fetch::object_id::ObjectId,
http_signatures::generate_actor_keypair,
};
use bcrypt::{hash, DEFAULT_COST};
use chrono::{DateTime, Local, Utc};
use diesel::{insert_into, AsChangeset, Insertable, RunQueryDsl};
use diesel::{ExpressionMethods, JoinOnDsl};
use diesel::{PgTextExpressionMethods, QueryDsl};
use diesel::{
insert_into,
AsChangeset,
ExpressionMethods,
Insertable,
JoinOnDsl,
PgTextExpressionMethods,
QueryDsl,
RunQueryDsl,
};
use std::ops::DerefMut;
#[derive(Debug, Clone, Insertable, AsChangeset)]

View file

@ -1,11 +1,17 @@
use crate::backend::error::MyResult;
use crate::backend::federation::send_activity;
use crate::backend::utils::generate_activity_id;
use crate::backend::{database::IbisData, federation::activities::follow::Follow};
use crate::common::DbInstance;
use activitypub_federation::traits::Actor;
use crate::{
backend::{
database::IbisData,
error::MyResult,
federation::{activities::follow::Follow, send_activity},
utils::generate_activity_id,
},
common::DbInstance,
};
use activitypub_federation::{
config::Data, fetch::object_id::ObjectId, kinds::activity::AcceptType, traits::ActivityHandler,
config::Data,
fetch::object_id::ObjectId,
kinds::activity::AcceptType,
traits::{ActivityHandler, Actor},
};
use serde::{Deserialize, Serialize};
use url::Url;

View file

@ -1,13 +1,16 @@
use crate::backend::database::IbisData;
use crate::backend::error::MyResult;
use crate::backend::federation::objects::article::ApubArticle;
use crate::backend::utils::generate_activity_id;
use crate::common::DbArticle;
use crate::common::DbInstance;
use activitypub_federation::kinds::activity::CreateType;
use crate::{
backend::{
database::IbisData,
error::MyResult,
federation::objects::article::ApubArticle,
utils::generate_activity_id,
},
common::{DbArticle, DbInstance},
};
use activitypub_federation::{
config::Data,
fetch::object_id::ObjectId,
kinds::activity::CreateType,
protocol::helpers::deserialize_one_or_many,
traits::{ActivityHandler, Object},
};

View file

@ -1,15 +1,17 @@
use crate::backend::error::MyResult;
use crate::backend::federation::send_activity;
use crate::backend::{
database::IbisData, federation::activities::accept::Accept, generate_activity_id,
use crate::{
backend::{
database::IbisData,
error::MyResult,
federation::{activities::accept::Accept, send_activity},
generate_activity_id,
},
common::{DbInstance, DbPerson},
};
use crate::common::DbInstance;
use crate::common::DbPerson;
use activitypub_federation::protocol::verification::verify_urls_match;
use activitypub_federation::{
config::Data,
fetch::object_id::ObjectId,
kinds::activity::FollowType,
protocol::verification::verify_urls_match,
traits::{ActivityHandler, Actor},
};
use serde::{Deserialize, Serialize};

View file

@ -1,11 +1,14 @@
use crate::backend::database::edit::DbEditForm;
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;
use crate::common::DbInstance;
use crate::common::EditVersion;
use crate::common::{DbArticle, DbEdit};
use crate::{
backend::{
database::{edit::DbEditForm, IbisData},
error::Error,
federation::activities::{
update_local_article::UpdateLocalArticle,
update_remote_article::UpdateRemoteArticle,
},
},
common::{DbArticle, DbEdit, DbInstance, EditVersion},
};
use activitypub_federation::config::Data;
use chrono::Utc;

View file

@ -1,17 +1,22 @@
use crate::backend::database::conflict::{DbConflict, DbConflictForm};
use crate::backend::database::IbisData;
use crate::backend::error::MyResult;
use crate::backend::federation::objects::edit::ApubEdit;
use crate::backend::utils::generate_activity_id;
use crate::common::DbInstance;
use crate::common::EditVersion;
use activitypub_federation::kinds::activity::RejectType;
use crate::{
backend::{
database::{
conflict::{DbConflict, DbConflictForm},
IbisData,
},
error::MyResult,
federation::{objects::edit::ApubEdit, send_activity},
utils::generate_activity_id,
},
common::{DbInstance, EditVersion},
};
use activitypub_federation::{
config::Data, fetch::object_id::ObjectId, protocol::helpers::deserialize_one_or_many,
config::Data,
fetch::object_id::ObjectId,
kinds::activity::RejectType,
protocol::helpers::deserialize_one_or_many,
traits::ActivityHandler,
};
use crate::backend::federation::send_activity;
use serde::{Deserialize, Serialize};
use url::Url;

View file

@ -1,14 +1,16 @@
use crate::backend::database::IbisData;
use crate::backend::error::MyResult;
use crate::backend::federation::objects::article::ApubArticle;
use crate::backend::utils::generate_activity_id;
use crate::common::DbArticle;
use crate::common::DbInstance;
use activitypub_federation::kinds::activity::UpdateType;
use crate::{
backend::{
database::IbisData,
error::MyResult,
federation::objects::article::ApubArticle,
utils::generate_activity_id,
},
common::{DbArticle, DbInstance},
};
use activitypub_federation::{
config::Data,
fetch::object_id::ObjectId,
kinds::activity::UpdateType,
protocol::helpers::deserialize_one_or_many,
traits::{ActivityHandler, Object},
};

View file

@ -1,19 +1,20 @@
use crate::backend::database::IbisData;
use crate::backend::error::MyResult;
use crate::backend::federation::activities::reject::RejectEdit;
use crate::backend::federation::activities::update_local_article::UpdateLocalArticle;
use crate::backend::federation::objects::edit::ApubEdit;
use crate::backend::federation::send_activity;
use crate::backend::utils::generate_activity_id;
use crate::common::validation::can_edit_article;
use crate::common::DbArticle;
use crate::common::DbEdit;
use crate::common::DbInstance;
use activitypub_federation::kinds::activity::UpdateType;
use crate::{
backend::{
database::IbisData,
error::MyResult,
federation::{
activities::{reject::RejectEdit, update_local_article::UpdateLocalArticle},
objects::edit::ApubEdit,
send_activity,
},
utils::generate_activity_id,
},
common::{validation::can_edit_article, DbArticle, DbEdit, DbInstance},
};
use activitypub_federation::{
config::Data,
fetch::object_id::ObjectId,
kinds::activity::UpdateType,
protocol::helpers::deserialize_one_or_many,
traits::{ActivityHandler, Object},
};

View file

@ -1,10 +1,11 @@
use crate::backend::config::IbisConfig;
use crate::backend::database::IbisData;
use activitypub_federation::activity_queue::queue_activity;
use activitypub_federation::config::{Data, UrlVerifier};
use activitypub_federation::error::Error as ActivityPubError;
use activitypub_federation::protocol::context::WithContext;
use activitypub_federation::traits::{ActivityHandler, Actor};
use crate::backend::{config::IbisConfig, database::IbisData};
use activitypub_federation::{
activity_queue::queue_activity,
config::{Data, UrlVerifier},
error::Error as ActivityPubError,
protocol::context::WithContext,
traits::{ActivityHandler, Actor},
};
use async_trait::async_trait;
use serde::Serialize;
use std::fmt::Debug;

View file

@ -1,17 +1,17 @@
use crate::backend::database::article::DbArticleForm;
use crate::backend::database::IbisData;
use crate::backend::error::Error;
use crate::backend::federation::objects::edits_collection::DbEditCollection;
use crate::common::DbArticle;
use crate::common::DbInstance;
use crate::common::EditVersion;
use activitypub_federation::config::Data;
use activitypub_federation::fetch::collection_id::CollectionId;
use activitypub_federation::kinds::object::ArticleType;
use activitypub_federation::kinds::public;
use activitypub_federation::protocol::verification::verify_domains_match;
use crate::{
backend::{
database::{article::DbArticleForm, IbisData},
error::Error,
federation::objects::edits_collection::DbEditCollection,
},
common::{DbArticle, DbInstance, EditVersion},
};
use activitypub_federation::{
fetch::object_id::ObjectId, protocol::helpers::deserialize_one_or_many, traits::Object,
config::Data,
fetch::{collection_id::CollectionId, object_id::ObjectId},
kinds::{object::ArticleType, public},
protocol::{helpers::deserialize_one_or_many, verification::verify_domains_match},
traits::Object,
};
use serde::{Deserialize, Serialize};
use url::Url;

View file

@ -1,17 +1,14 @@
use crate::backend::database::IbisData;
use crate::backend::error::Error;
use crate::backend::federation::objects::article::ApubArticle;
use crate::common::DbInstance;
use crate::common::DbArticle;
use activitypub_federation::kinds::collection::CollectionType;
use activitypub_federation::protocol::verification::verify_domains_match;
use crate::{
backend::{database::IbisData, error::Error, federation::objects::article::ApubArticle},
common::{DbArticle, DbInstance},
};
use activitypub_federation::{
config::Data,
kinds::collection::CollectionType,
protocol::verification::verify_domains_match,
traits::{Collection, Object},
};
use futures::future;
use futures::future::try_join_all;
use futures::{future, future::try_join_all};
use serde::{Deserialize, Serialize};
use url::Url;

View file

@ -1,13 +1,16 @@
use crate::backend::database::edit::DbEditForm;
use crate::backend::database::IbisData;
use crate::backend::error::Error;
use crate::common::DbPerson;
use crate::common::EditVersion;
use crate::common::{DbArticle, DbEdit};
use activitypub_federation::config::Data;
use activitypub_federation::fetch::object_id::ObjectId;
use activitypub_federation::protocol::verification::verify_domains_match;
use activitypub_federation::traits::Object;
use crate::{
backend::{
database::{edit::DbEditForm, IbisData},
error::Error,
},
common::{DbArticle, DbEdit, DbPerson, EditVersion},
};
use activitypub_federation::{
config::Data,
fetch::object_id::ObjectId,
protocol::verification::verify_domains_match,
traits::Object,
};
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use url::Url;

View file

@ -1,18 +1,14 @@
use crate::backend::database::IbisData;
use crate::backend::error::Error;
use crate::backend::federation::objects::edit::ApubEdit;
use crate::common::DbArticle;
use crate::common::DbEdit;
use crate::common::DbInstance;
use activitypub_federation::kinds::collection::OrderedCollectionType;
use activitypub_federation::protocol::verification::verify_domains_match;
use crate::{
backend::{database::IbisData, error::Error, federation::objects::edit::ApubEdit},
common::{DbArticle, DbEdit, DbInstance},
};
use activitypub_federation::{
config::Data,
kinds::collection::OrderedCollectionType,
protocol::verification::verify_domains_match,
traits::{Collection, Object},
};
use futures::future;
use futures::future::try_join_all;
use futures::{future, future::try_join_all};
use serde::{Deserialize, Serialize};
use url::Url;

View file

@ -1,19 +1,17 @@
use crate::backend::database::instance::DbInstanceForm;
use crate::backend::database::IbisData;
use crate::backend::error::Error;
use crate::backend::error::MyResult;
use crate::backend::federation::objects::articles_collection::DbArticleCollection;
use crate::backend::federation::send_activity;
use crate::common::utils::extract_domain;
use crate::common::DbInstance;
use activitypub_federation::fetch::collection_id::CollectionId;
use activitypub_federation::kinds::actor::ServiceType;
use activitypub_federation::traits::ActivityHandler;
use crate::{
backend::{
database::{instance::DbInstanceForm, IbisData},
error::{Error, MyResult},
federation::{objects::articles_collection::DbArticleCollection, send_activity},
},
common::{utils::extract_domain, DbInstance},
};
use activitypub_federation::{
config::Data,
fetch::object_id::ObjectId,
fetch::{collection_id::CollectionId, object_id::ObjectId},
kinds::actor::ServiceType,
protocol::{public_key::PublicKey, verification::verify_domains_match},
traits::{Actor, Object},
traits::{ActivityHandler, Actor, Object},
};
use chrono::{DateTime, Local, Utc};
use serde::{Deserialize, Serialize};

View file

@ -1,11 +1,14 @@
use crate::backend::database::user::DbPersonForm;
use crate::backend::database::IbisData;
use crate::backend::error::Error;
use crate::common::DbPerson;
use activitypub_federation::kinds::actor::PersonType;
use crate::{
backend::{
database::{user::DbPersonForm, IbisData},
error::Error,
},
common::DbPerson,
};
use activitypub_federation::{
config::Data,
fetch::object_id::ObjectId,
kinds::actor::PersonType,
protocol::{public_key::PublicKey, verification::verify_domains_match},
traits::{Actor, Object},
};

View file

@ -1,33 +1,42 @@
use crate::backend::database::IbisData;
use crate::backend::error::Error;
use crate::backend::error::MyResult;
use crate::backend::federation::activities::accept::Accept;
use crate::backend::federation::activities::create_article::CreateArticle;
use crate::backend::federation::activities::follow::Follow;
use crate::backend::federation::activities::reject::RejectEdit;
use crate::backend::federation::activities::update_local_article::UpdateLocalArticle;
use crate::backend::federation::activities::update_remote_article::UpdateRemoteArticle;
use crate::backend::federation::objects::article::ApubArticle;
use crate::backend::federation::objects::articles_collection::{
ArticleCollection, DbArticleCollection,
use crate::{
backend::{
database::IbisData,
error::{Error, MyResult},
federation::{
activities::{
accept::Accept,
create_article::CreateArticle,
follow::Follow,
reject::RejectEdit,
update_local_article::UpdateLocalArticle,
update_remote_article::UpdateRemoteArticle,
},
objects::{
article::ApubArticle,
articles_collection::{ArticleCollection, DbArticleCollection},
edits_collection::{ApubEditCollection, DbEditCollection},
instance::ApubInstance,
user::ApubUser,
},
},
},
common::{DbArticle, DbInstance, DbPerson},
};
use activitypub_federation::{
axum::{
inbox::{receive_activity, ActivityData},
json::FederationJson,
},
config::Data,
protocol::context::WithContext,
traits::{ActivityHandler, Actor, Collection, Object},
};
use axum::{
extract::Path,
response::IntoResponse,
routing::{get, post},
Router,
};
use crate::backend::federation::objects::edits_collection::{ApubEditCollection, DbEditCollection};
use crate::backend::federation::objects::instance::ApubInstance;
use crate::backend::federation::objects::user::ApubUser;
use crate::common::DbArticle;
use crate::common::DbInstance;
use crate::common::DbPerson;
use activitypub_federation::axum::inbox::{receive_activity, ActivityData};
use activitypub_federation::axum::json::FederationJson;
use activitypub_federation::config::Data;
use activitypub_federation::protocol::context::WithContext;
use activitypub_federation::traits::Actor;
use activitypub_federation::traits::Object;
use activitypub_federation::traits::{ActivityHandler, Collection};
use axum::extract::Path;
use axum::response::IntoResponse;
use axum::routing::{get, post};
use axum::Router;
use axum_macros::debug_handler;
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};

View file

@ -1,38 +1,45 @@
use crate::backend::config::IbisConfig;
use crate::backend::database::article::DbArticleForm;
use crate::backend::database::instance::DbInstanceForm;
use crate::backend::database::IbisData;
use crate::backend::error::Error;
use crate::backend::error::MyResult;
use crate::backend::federation::activities::submit_article_update;
use crate::backend::federation::routes::federation_routes;
use crate::backend::federation::VerifyUrlData;
use crate::backend::utils::generate_activity_id;
use crate::common::utils::http_protocol_str;
use crate::common::{DbArticle, DbInstance, DbPerson, EditVersion, MAIN_PAGE_NAME};
use crate::frontend::app::App;
use activitypub_federation::config::{Data, FederationConfig, FederationMiddleware};
use activitypub_federation::fetch::collection_id::CollectionId;
use activitypub_federation::fetch::object_id::ObjectId;
use activitypub_federation::http_signatures::generate_actor_keypair;
use crate::{
backend::{
config::IbisConfig,
database::{article::DbArticleForm, instance::DbInstanceForm, IbisData},
error::{Error, MyResult},
federation::{activities::submit_article_update, routes::federation_routes, VerifyUrlData},
utils::generate_activity_id,
},
common::{
utils::http_protocol_str,
DbArticle,
DbInstance,
DbPerson,
EditVersion,
MAIN_PAGE_NAME,
},
frontend::app::App,
};
use activitypub_federation::{
config::{Data, FederationConfig, FederationMiddleware},
fetch::{collection_id::CollectionId, object_id::ObjectId},
http_signatures::generate_actor_keypair,
};
use api::api_routes;
use axum::debug_handler;
use axum::headers::HeaderMap;
use axum::http::{HeaderValue, Request};
use axum::response::IntoResponse;
use axum::routing::get;
use axum::Server;
use axum::ServiceExt;
use axum::{middleware::Next, response::Response, Router};
use axum::{
debug_handler,
headers::HeaderMap,
http::{HeaderValue, Request},
middleware::Next,
response::{IntoResponse, Response},
routing::get,
Router,
Server,
ServiceExt,
};
use chrono::Local;
use diesel::r2d2::ConnectionManager;
use diesel::r2d2::Pool;
use diesel::PgConnection;
use diesel_migrations::embed_migrations;
use diesel_migrations::EmbeddedMigrations;
use diesel_migrations::MigrationHarness;
use leptos::leptos_config::get_config_from_str;
use leptos::*;
use diesel::{
r2d2::{ConnectionManager, Pool},
PgConnection,
};
use diesel_migrations::{embed_migrations, EmbeddedMigrations, MigrationHarness};
use leptos::{leptos_config::get_config_from_str, *};
use leptos_axum::{generate_route_list, LeptosRoutes};
use log::info;
use tower::Layer;

View file

@ -1,14 +1,12 @@
use crate::backend::error::MyResult;
use crate::common::EditView;
use crate::common::{utils, EditVersion};
use activitypub_federation::fetch::object_id::ObjectId;
use activitypub_federation::traits::Object;
use crate::{
backend::error::MyResult,
common::{utils, utils::extract_domain, EditVersion, EditView},
};
use activitypub_federation::{fetch::object_id::ObjectId, traits::Object};
use anyhow::anyhow;
use diffy::{apply, Patch};
use rand::{distributions::Alphanumeric, thread_rng, Rng};
use serde::Deserialize;
use crate::common::utils::extract_domain;
use url::{ParseError, Url};
pub fn generate_activity_id<T>(for_url: &ObjectId<T>) -> Result<Url, ParseError>

View file

@ -1,6 +1,5 @@
use crate::common::DbArticle;
use anyhow::anyhow;
use anyhow::Result;
use anyhow::{anyhow, Result};
pub fn can_edit_article(article: &DbArticle, is_admin: bool) -> Result<()> {
let err = anyhow!("Article is protected, only admins on origin instance can edit");

View file

@ -1,11 +1,28 @@
use crate::common::utils::http_protocol_str;
use crate::common::{ApiConflict, ListArticlesForm, ProtectArticleForm};
use crate::common::{ArticleView, LoginUserForm, RegisterUserForm};
use crate::common::{CreateArticleForm, EditArticleForm, ForkArticleForm, LocalUserView};
use crate::common::{DbArticle, GetArticleForm};
use crate::common::{DbInstance, FollowInstance, InstanceView, SearchArticleForm};
use crate::common::{DbPerson, GetUserForm, ResolveObject};
use crate::frontend::error::MyResult;
use crate::{
common::{
utils::http_protocol_str,
ApiConflict,
ArticleView,
CreateArticleForm,
DbArticle,
DbInstance,
DbPerson,
EditArticleForm,
FollowInstance,
ForkArticleForm,
GetArticleForm,
GetUserForm,
InstanceView,
ListArticlesForm,
LocalUserView,
LoginUserForm,
ProtectArticleForm,
RegisterUserForm,
ResolveObject,
SearchArticleForm,
},
frontend::error::MyResult,
};
use anyhow::anyhow;
use reqwest::{Client, RequestBuilder, StatusCode};
use serde::{Deserialize, Serialize};

View file

@ -1,29 +1,44 @@
use crate::common::LocalUserView;
use crate::frontend::api::ApiClient;
use crate::frontend::backend_hostname;
use crate::frontend::components::nav::Nav;
use crate::frontend::pages::article::actions::ArticleActions;
use crate::frontend::pages::article::create::CreateArticle;
use crate::frontend::pages::article::edit::EditArticle;
use crate::frontend::pages::article::history::ArticleHistory;
use crate::frontend::pages::article::list::ListArticles;
use crate::frontend::pages::article::read::ReadArticle;
use crate::frontend::pages::conflicts::Conflicts;
use crate::frontend::pages::diff::EditDiff;
use crate::frontend::pages::instance_details::InstanceDetails;
use crate::frontend::pages::login::Login;
use crate::frontend::pages::register::Register;
use crate::frontend::pages::search::Search;
use crate::frontend::pages::user_profile::UserProfile;
use leptos::{
component, create_local_resource, create_rw_signal, expect_context, provide_context,
use_context, view, IntoView, RwSignal, SignalGet, SignalGetUntracked, SignalUpdate,
use crate::{
common::LocalUserView,
frontend::{
api::ApiClient,
backend_hostname,
components::nav::Nav,
pages::{
article::{
actions::ArticleActions,
create::CreateArticle,
edit::EditArticle,
history::ArticleHistory,
list::ListArticles,
read::ReadArticle,
},
conflicts::Conflicts,
diff::EditDiff,
instance_details::InstanceDetails,
login::Login,
register::Register,
search::Search,
user_profile::UserProfile,
},
},
};
use leptos_meta::provide_meta_context;
use leptos_meta::*;
use leptos_router::Route;
use leptos_router::Router;
use leptos_router::Routes;
use leptos::{
component,
create_local_resource,
create_rw_signal,
expect_context,
provide_context,
use_context,
view,
IntoView,
RwSignal,
SignalGet,
SignalGetUntracked,
SignalUpdate,
};
use leptos_meta::{provide_meta_context, *};
use leptos_router::{Route, Router, Routes};
use reqwest::Client;
// https://book.leptos.dev/15_global_state.html

View file

@ -1,7 +1,7 @@
use crate::common::validation::can_edit_article;
use crate::common::ArticleView;
use crate::frontend::app::GlobalState;
use crate::frontend::article_link;
use crate::{
common::{validation::can_edit_article, ArticleView},
frontend::{app::GlobalState, article_link},
};
use leptos::*;
use leptos_router::*;

View file

@ -1,6 +1,5 @@
use crate::frontend::app::GlobalState;
use leptos::*;
use leptos::{component, use_context, view, IntoView, RwSignal, SignalWith};
use leptos::{component, use_context, view, IntoView, RwSignal, SignalWith, *};
use leptos_router::*;
#[component]

View file

@ -1,6 +1,11 @@
use crate::frontend::backend_hostname;
use markdown_it::parser::inline::{InlineRule, InlineState};
use markdown_it::{MarkdownIt, Node, NodeValue, Renderer};
use markdown_it::{
parser::inline::{InlineRule, InlineState},
MarkdownIt,
Node,
NodeValue,
Renderer,
};
pub fn markdown_parser() -> MarkdownIt {
let mut parser = MarkdownIt::new();

View file

@ -1,5 +1,4 @@
use crate::common::utils::extract_domain;
use crate::common::{DbArticle, DbPerson};
use crate::common::{utils::extract_domain, DbArticle, DbPerson};
use leptos::*;
pub mod api;

View file

@ -1,10 +1,14 @@
use crate::common::ForkArticleForm;
use crate::frontend::app::GlobalState;
use crate::frontend::article_link;
use crate::frontend::article_title;
use crate::frontend::components::article_nav::ArticleNav;
use crate::frontend::pages::article_resource;
use crate::frontend::DbArticle;
use crate::{
common::ForkArticleForm,
frontend::{
app::GlobalState,
article_link,
article_title,
components::article_nav::ArticleNav,
pages::article_resource,
DbArticle,
},
};
use leptos::*;
use leptos_router::Redirect;

View file

@ -1,5 +1,4 @@
use crate::common::CreateArticleForm;
use crate::frontend::app::GlobalState;
use crate::{common::CreateArticleForm, frontend::app::GlobalState};
use leptos::*;
use leptos_router::Redirect;

View file

@ -1,8 +1,12 @@
use crate::common::{ApiConflict, ArticleView, EditArticleForm};
use crate::frontend::app::GlobalState;
use crate::frontend::article_title;
use crate::frontend::components::article_nav::ArticleNav;
use crate::frontend::pages::article_resource;
use crate::{
common::{ApiConflict, ArticleView, EditArticleForm},
frontend::{
app::GlobalState,
article_title,
components::article_nav::ArticleNav,
pages::article_resource,
},
};
use leptos::*;
use leptos_router::use_params_map;

View file

@ -1,6 +1,9 @@
use crate::frontend::components::article_nav::ArticleNav;
use crate::frontend::pages::article_resource;
use crate::frontend::{article_title, user_link};
use crate::frontend::{
article_title,
components::article_nav::ArticleNav,
pages::article_resource,
user_link,
};
use leptos::*;
#[component]

View file

@ -1,6 +1,7 @@
use crate::common::ListArticlesForm;
use crate::frontend::app::GlobalState;
use crate::frontend::{article_link, article_title};
use crate::{
common::ListArticlesForm,
frontend::{app::GlobalState, article_link, article_title},
};
use leptos::*;
use web_sys::wasm_bindgen::JsCast;

View file

@ -1,7 +1,9 @@
use crate::frontend::article_title;
use crate::frontend::components::article_nav::ArticleNav;
use crate::frontend::markdown::markdown_parser;
use crate::frontend::pages::article_resource;
use crate::frontend::{
article_title,
components::article_nav::ArticleNav,
markdown::markdown_parser,
pages::article_resource,
};
use leptos::*;
#[component]

View file

@ -1,6 +1,4 @@
use crate::frontend::app::GlobalState;
use crate::frontend::article_link;
use crate::frontend::article_title;
use crate::frontend::{app::GlobalState, article_link, article_title};
use leptos::*;
#[component]

View file

@ -1,6 +1,4 @@
use crate::frontend::components::article_nav::ArticleNav;
use crate::frontend::pages::article_resource;
use crate::frontend::user_link;
use crate::frontend::{components::article_nav::ArticleNav, pages::article_resource, user_link};
use leptos::*;
use leptos_router::*;

View file

@ -1,6 +1,7 @@
use crate::common::utils::http_protocol_str;
use crate::common::{DbInstance, FollowInstance};
use crate::frontend::app::GlobalState;
use crate::{
common::{utils::http_protocol_str, DbInstance, FollowInstance},
frontend::app::GlobalState,
};
use leptos::*;
use leptos_router::use_params_map;
use url::Url;

View file

@ -1,6 +1,7 @@
use crate::common::LoginUserForm;
use crate::frontend::app::GlobalState;
use crate::frontend::components::credentials::*;
use crate::{
common::LoginUserForm,
frontend::{app::GlobalState, components::credentials::*},
};
use leptos::*;
use leptos_router::Redirect;

View file

@ -1,5 +1,7 @@
use crate::common::{ArticleView, GetArticleForm, MAIN_PAGE_NAME};
use crate::frontend::app::GlobalState;
use crate::{
common::{ArticleView, GetArticleForm, MAIN_PAGE_NAME},
frontend::app::GlobalState,
};
use leptos::{create_resource, Resource, SignalGet};
use leptos_router::use_params_map;

View file

@ -1,7 +1,7 @@
use crate::common::{LocalUserView, RegisterUserForm};
use crate::frontend::app::GlobalState;
use crate::frontend::components::credentials::*;
use crate::frontend::error::MyResult;
use crate::{
common::{LocalUserView, RegisterUserForm},
frontend::{app::GlobalState, components::credentials::*, error::MyResult},
};
use leptos::{logging::log, *};
#[component]

View file

@ -1,6 +1,7 @@
use crate::common::{DbArticle, DbInstance, SearchArticleForm};
use crate::frontend::app::GlobalState;
use crate::frontend::{article_link, article_title};
use crate::{
common::{DbArticle, DbInstance, SearchArticleForm},
frontend::{app::GlobalState, article_link, article_title},
};
use leptos::*;
use leptos_router::use_query_map;
use serde::{Deserialize, Serialize};

View file

@ -1,6 +1,7 @@
use crate::common::{DbPerson, GetUserForm};
use crate::frontend::app::GlobalState;
use crate::frontend::user_title;
use crate::{
common::{DbPerson, GetUserForm},
frontend::{app::GlobalState, user_title},
};
use leptos::*;
use leptos_router::use_params_map;

View file

@ -23,8 +23,7 @@ pub async fn main() -> ibis_lib::backend::error::MyResult<()> {
#[cfg(not(feature = "ssr"))]
fn main() {
use ibis_lib::frontend::app::App;
use leptos::mount_to_body;
use leptos::view;
use leptos::{mount_to_body, view};
_ = console_log::init_with_level(log::Level::Debug);
console_error_panic_hook::set_once();

View file

@ -1,19 +1,26 @@
#![allow(clippy::unwrap_used)]
use ibis_lib::backend::config::{IbisConfig, IbisConfigDatabase, IbisConfigFederation};
use ibis_lib::backend::start;
use ibis_lib::common::RegisterUserForm;
use ibis_lib::frontend::api::ApiClient;
use ibis_lib::frontend::error::MyResult;
use ibis_lib::{
backend::{
config::{IbisConfig, IbisConfigDatabase, IbisConfigFederation},
start,
},
common::RegisterUserForm,
frontend::{api::ApiClient, error::MyResult},
};
use reqwest::ClientBuilder;
use std::env::current_dir;
use std::fs::{create_dir_all, remove_dir_all};
use std::ops::Deref;
use std::process::{Command, Stdio};
use std::sync::atomic::{AtomicI32, Ordering};
use std::sync::Once;
use std::thread::{sleep, spawn};
use std::time::Duration;
use std::{
env::current_dir,
fs::{create_dir_all, remove_dir_all},
ops::Deref,
process::{Command, Stdio},
sync::{
atomic::{AtomicI32, Ordering},
Once,
},
thread::{sleep, spawn},
time::Duration,
};
use tokio::task::JoinHandle;
use tracing::log::LevelFilter;

View file

@ -5,14 +5,23 @@ extern crate ibis_lib;
mod common;
use crate::common::{TestData, TEST_ARTICLE_DEFAULT_TEXT};
use ibis_lib::common::utils::extract_domain;
use ibis_lib::common::{
ArticleView, EditArticleForm, ForkArticleForm, GetArticleForm, GetUserForm, ListArticlesForm,
ProtectArticleForm,
use ibis_lib::{
common::{
utils::extract_domain,
ArticleView,
CreateArticleForm,
EditArticleForm,
ForkArticleForm,
GetArticleForm,
GetUserForm,
ListArticlesForm,
LoginUserForm,
ProtectArticleForm,
RegisterUserForm,
SearchArticleForm,
},
frontend::error::MyResult,
};
use ibis_lib::common::{CreateArticleForm, SearchArticleForm};
use ibis_lib::common::{LoginUserForm, RegisterUserForm};
use ibis_lib::frontend::error::MyResult;
use pretty_assertions::{assert_eq, assert_ne};
use url::Url;