Move ActorType, signatures, activity_queue to apub library

apub-lib-changes
Felix Ableitner 2021-10-04 16:52:20 +02:00
parent 455e0b5760
commit d3a3cf04e7
53 changed files with 383 additions and 390 deletions

15
Cargo.lock generated
View File

@ -1746,17 +1746,13 @@ dependencies = [
"anyhow", "anyhow",
"async-trait", "async-trait",
"awc", "awc",
"background-jobs",
"base64 0.13.0",
"bcrypt", "bcrypt",
"chrono", "chrono",
"diesel", "diesel",
"futures", "futures",
"http", "http",
"http-signature-normalization-actix", "http-signature-normalization-actix",
"http-signature-normalization-reqwest",
"itertools", "itertools",
"lazy_static",
"lemmy_api_common", "lemmy_api_common",
"lemmy_apub_lib", "lemmy_apub_lib",
"lemmy_db_queries", "lemmy_db_queries",
@ -1766,7 +1762,6 @@ dependencies = [
"lemmy_utils", "lemmy_utils",
"lemmy_websocket", "lemmy_websocket",
"log", "log",
"openssl",
"percent-encoding", "percent-encoding",
"rand 0.8.4", "rand 0.8.4",
"reqwest", "reqwest",
@ -1787,14 +1782,23 @@ name = "lemmy_apub_lib"
version = "0.13.0" version = "0.13.0"
dependencies = [ dependencies = [
"activitystreams", "activitystreams",
"actix-web",
"anyhow", "anyhow",
"async-trait", "async-trait",
"background-jobs",
"base64 0.13.0",
"http",
"http-signature-normalization-actix",
"http-signature-normalization-reqwest",
"lazy_static",
"lemmy_apub_lib_derive", "lemmy_apub_lib_derive",
"lemmy_utils", "lemmy_utils",
"log", "log",
"openssl",
"reqwest", "reqwest",
"serde", "serde",
"serde_json", "serde_json",
"sha2",
"url", "url",
] ]
@ -1927,6 +1931,7 @@ dependencies = [
"lemmy_api_common", "lemmy_api_common",
"lemmy_api_crud", "lemmy_api_crud",
"lemmy_apub", "lemmy_apub",
"lemmy_apub_lib",
"lemmy_db_queries", "lemmy_db_queries",
"lemmy_db_schema", "lemmy_db_schema",
"lemmy_db_views", "lemmy_db_views",

View File

@ -35,6 +35,7 @@ members = [
lemmy_api = { version = "=0.13.0", path = "./crates/api" } lemmy_api = { version = "=0.13.0", path = "./crates/api" }
lemmy_api_crud = { version = "=0.13.0", path = "./crates/api_crud" } lemmy_api_crud = { version = "=0.13.0", path = "./crates/api_crud" }
lemmy_apub = { version = "=0.13.0", path = "./crates/apub" } lemmy_apub = { version = "=0.13.0", path = "./crates/apub" }
lemmy_apub_lib = { version = "=0.13.0", path = "./crates/apub_lib" }
lemmy_utils = { version = "=0.13.0", path = "./crates/utils" } lemmy_utils = { version = "=0.13.0", path = "./crates/utils" }
lemmy_db_schema = { version = "=0.13.0", path = "./crates/db_schema" } lemmy_db_schema = { version = "=0.13.0", path = "./crates/db_schema" }
lemmy_db_queries = { version = "=0.13.0", path = "./crates/db_queries" } lemmy_db_queries = { version = "=0.13.0", path = "./crates/db_queries" }

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
set -e set -e
export LEMMY_TEST_SEND_SYNC=1 export APUB_TESTING_SEND_SYNC=1
export RUST_BACKTRACE=1 export RUST_BACKTRACE=1
export RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_queries=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug" export RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_queries=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug"

View File

@ -36,11 +36,8 @@ strum = "0.21.0"
strum_macros = "0.21.1" strum_macros = "0.21.1"
url = { version = "2.2.2", features = ["serde"] } url = { version = "2.2.2", features = ["serde"] }
percent-encoding = "2.1.0" percent-encoding = "2.1.0"
openssl = "0.10.36"
http = "0.2.5" http = "0.2.5"
http-signature-normalization-actix = { version = "0.5.0-beta.10", default-features = false, features = ["server", "sha-2"] } http-signature-normalization-actix = { version = "0.5.0-beta.10", default-features = false, features = ["server", "sha-2"] }
http-signature-normalization-reqwest = { version = "0.2.0", default-features = false, features = ["sha-2"] }
base64 = "0.13.0"
tokio = "1.12.0" tokio = "1.12.0"
futures = "0.3.17" futures = "0.3.17"
itertools = "0.10.1" itertools = "0.10.1"
@ -49,7 +46,5 @@ sha2 = "0.9.8"
async-trait = "0.1.51" async-trait = "0.1.51"
anyhow = "1.0.44" anyhow = "1.0.44"
thiserror = "1.0.29" thiserror = "1.0.29"
background-jobs = "0.10.0"
reqwest = { version = "0.11.4", features = ["json"] } reqwest = { version = "0.11.4", features = ["json"] }
lazy_static = "1.4.0"

View File

@ -1,24 +1,22 @@
use crate::{ use crate::{
activities::{ activities::{
comment::{collect_non_local_mentions, get_notif_recipients}, comment::{collect_non_local_mentions, get_notif_recipients},
community::announce::AnnouncableActivities, community::{announce::AnnouncableActivities, send_to_community},
extract_community, extract_community,
generate_activity_id, generate_activity_id,
verify_activity, verify_activity,
verify_person_in_community, verify_person_in_community,
CreateOrUpdateType, CreateOrUpdateType,
}, },
activity_queue::send_to_community_new, context::lemmy_context,
extensions::context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
objects::{comment::Note, FromApub, ToApub}, objects::{comment::Note, FromApub, ToApub},
ActorType,
}; };
use activitystreams::{base::AnyBase, link::Mention, primitives::OneOrMany, unparsed::Unparsed}; use activitystreams::{base::AnyBase, link::Mention, primitives::OneOrMany, unparsed::Unparsed};
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl, values::PublicUrl,
verify::verify_domains_match, verify::verify_domains_match,
}; };
@ -81,7 +79,7 @@ impl CreateOrUpdateComment {
}; };
let activity = AnnouncableActivities::CreateOrUpdateComment(create_or_update); let activity = AnnouncableActivities::CreateOrUpdateComment(create_or_update);
send_to_community_new(activity, &id, actor, &community, maa.inboxes, context).await send_to_community(activity, &id, actor, &community, maa.inboxes, context).await
} }
} }

View File

@ -1,4 +1,4 @@
use crate::{fetcher::object_id::ObjectId, ActorType}; use crate::fetcher::object_id::ObjectId;
use activitystreams::{ use activitystreams::{
base::BaseExt, base::BaseExt,
link::{LinkExt, Mention}, link::{LinkExt, Mention},
@ -6,7 +6,7 @@ use activitystreams::{
use anyhow::anyhow; use anyhow::anyhow;
use itertools::Itertools; use itertools::Itertools;
use lemmy_api_common::{blocking, send_local_notifs}; use lemmy_api_common::{blocking, send_local_notifs};
use lemmy_apub_lib::webfinger::WebfingerResponse; use lemmy_apub_lib::{traits::ActorType, webfinger::WebfingerResponse};
use lemmy_db_queries::{Crud, DbPool}; use lemmy_db_queries::{Crud, DbPool};
use lemmy_db_schema::{ use lemmy_db_schema::{
source::{comment::Comment, community::Community, person::Person, post::Post}, source::{comment::Comment, community::Community, person::Person, post::Post},
@ -68,7 +68,7 @@ pub async fn collect_non_local_mentions(
let parent_creator = get_comment_parent_creator(context.pool(), comment).await?; let parent_creator = get_comment_parent_creator(context.pool(), comment).await?;
let mut addressed_ccs = vec![community.actor_id(), parent_creator.actor_id()]; let mut addressed_ccs = vec![community.actor_id(), parent_creator.actor_id()];
// Note: dont include community inbox here, as we send to it separately with `send_to_community()` // Note: dont include community inbox here, as we send to it separately with `send_to_community()`
let mut inboxes = vec![parent_creator.get_shared_inbox_or_inbox_url()]; let mut inboxes = vec![parent_creator.shared_inbox_or_inbox_url()];
// Add the mention tag // Add the mention tag
let mut tags = Vec::new(); let mut tags = Vec::new();
@ -88,7 +88,7 @@ pub async fn collect_non_local_mentions(
addressed_ccs.push(actor_id.to_owned().to_string().parse()?); addressed_ccs.push(actor_id.to_owned().to_string().parse()?);
let mention_person = actor_id.dereference(context, &mut 0).await?; let mention_person = actor_id.dereference(context, &mut 0).await?;
inboxes.push(mention_person.get_shared_inbox_or_inbox_url()); inboxes.push(mention_person.shared_inbox_or_inbox_url());
let mut mention_tag = Mention::new(); let mut mention_tag = Mention::new();
mention_tag mention_tag

View File

@ -1,17 +1,15 @@
use crate::{ use crate::{
activities::{ activities::{
community::announce::AnnouncableActivities, community::{announce::AnnouncableActivities, send_to_community},
generate_activity_id, generate_activity_id,
verify_activity, verify_activity,
verify_add_remove_moderator_target, verify_add_remove_moderator_target,
verify_mod_action, verify_mod_action,
verify_person_in_community, verify_person_in_community,
}, },
activity_queue::send_to_community_new, context::lemmy_context,
extensions::context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
generate_moderators_url, generate_moderators_url,
ActorType,
}; };
use activitystreams::{ use activitystreams::{
activity::kind::AddType, activity::kind::AddType,
@ -22,7 +20,7 @@ use activitystreams::{
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl, values::PublicUrl,
}; };
use lemmy_db_queries::{source::community::CommunityModerator_, Joinable}; use lemmy_db_queries::{source::community::CommunityModerator_, Joinable};
@ -76,8 +74,8 @@ impl AddMod {
}; };
let activity = AnnouncableActivities::AddMod(add); let activity = AnnouncableActivities::AddMod(add);
let inboxes = vec![added_mod.get_shared_inbox_or_inbox_url()]; let inboxes = vec![added_mod.shared_inbox_or_inbox_url()];
send_to_community_new(activity, &id, actor, community, inboxes, context).await send_to_community(activity, &id, actor, community, inboxes, context).await
} }
} }

View File

@ -17,12 +17,11 @@ use crate::{
verify_community, verify_community,
voting::{undo_vote::UndoVote, vote::Vote}, voting::{undo_vote::UndoVote, vote::Vote},
}, },
activity_queue::send_activity_new, context::lemmy_context,
extensions::context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
http::is_activity_already_known, http::is_activity_already_known,
insert_activity, insert_activity,
ActorType, send_lemmy_activity,
CommunityType, CommunityType,
}; };
use activitystreams::{ use activitystreams::{
@ -33,7 +32,7 @@ use activitystreams::{
}; };
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl, values::PublicUrl,
}; };
use lemmy_db_schema::source::community::Community; use lemmy_db_schema::source::community::Community;
@ -97,7 +96,7 @@ impl AnnounceActivity {
unparsed: Default::default(), unparsed: Default::default(),
}; };
let inboxes = list_community_follower_inboxes(community, additional_inboxes, context).await?; let inboxes = list_community_follower_inboxes(community, additional_inboxes, context).await?;
send_activity_new(context, &announce, &announce.id, community, inboxes, false).await send_lemmy_activity(context, &announce, &announce.id, community, inboxes, false).await
} }
} }

View File

@ -1,15 +1,13 @@
use crate::{ use crate::{
activities::{ activities::{
community::announce::AnnouncableActivities, community::{announce::AnnouncableActivities, send_to_community},
generate_activity_id, generate_activity_id,
verify_activity, verify_activity,
verify_mod_action, verify_mod_action,
verify_person_in_community, verify_person_in_community,
}, },
activity_queue::send_to_community_new, context::lemmy_context,
extensions::context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
ActorType,
}; };
use activitystreams::{ use activitystreams::{
activity::kind::BlockType, activity::kind::BlockType,
@ -20,7 +18,7 @@ use activitystreams::{
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl, values::PublicUrl,
}; };
use lemmy_db_queries::{Bannable, Followable}; use lemmy_db_queries::{Bannable, Followable};
@ -87,8 +85,8 @@ impl BlockUserFromCommunity {
let block_id = block.id.clone(); let block_id = block.id.clone();
let activity = AnnouncableActivities::BlockUserFromCommunity(block); let activity = AnnouncableActivities::BlockUserFromCommunity(block);
let inboxes = vec![target.get_shared_inbox_or_inbox_url()]; let inboxes = vec![target.shared_inbox_or_inbox_url()];
send_to_community_new(activity, &block_id, actor, community, inboxes, context).await send_to_community(activity, &block_id, actor, community, inboxes, context).await
} }
} }

View File

@ -1,5 +1,12 @@
use crate::{check_is_apub_id_valid, CommunityType}; use crate::{
activities::community::announce::{AnnouncableActivities, AnnounceActivity},
check_is_apub_id_valid,
insert_activity,
send_lemmy_activity,
CommunityType,
};
use itertools::Itertools; use itertools::Itertools;
use lemmy_apub_lib::traits::ActorType;
use lemmy_db_schema::source::community::Community; use lemmy_db_schema::source::community::Community;
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;
use lemmy_websocket::LemmyContext; use lemmy_websocket::LemmyContext;
@ -33,3 +40,24 @@ async fn list_community_follower_inboxes(
.collect(), .collect(),
) )
} }
pub(crate) async fn send_to_community<T: ActorType>(
activity: AnnouncableActivities,
activity_id: &Url,
actor: &T,
community: &Community,
additional_inboxes: Vec<Url>,
context: &LemmyContext,
) -> Result<(), LemmyError> {
// if this is a local community, we need to do an announce from the community instead
if community.local {
insert_activity(activity_id, activity.clone(), true, false, context.pool()).await?;
AnnounceActivity::send(activity, community, additional_inboxes, context).await?;
} else {
let mut inboxes = additional_inboxes;
inboxes.push(community.shared_inbox_or_inbox_url());
send_lemmy_activity(context, &activity, activity_id, actor, inboxes, false).await?;
}
Ok(())
}

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
activities::{ activities::{
community::announce::AnnouncableActivities, community::{announce::AnnouncableActivities, send_to_community},
deletion::{delete::receive_remove_action, verify_delete_activity}, deletion::{delete::receive_remove_action, verify_delete_activity},
generate_activity_id, generate_activity_id,
verify_activity, verify_activity,
@ -8,11 +8,9 @@ use crate::{
verify_mod_action, verify_mod_action,
verify_person_in_community, verify_person_in_community,
}, },
activity_queue::send_to_community_new, context::lemmy_context,
extensions::context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
generate_moderators_url, generate_moderators_url,
ActorType,
}; };
use activitystreams::{ use activitystreams::{
activity::kind::RemoveType, activity::kind::RemoveType,
@ -23,7 +21,7 @@ use activitystreams::{
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl, values::PublicUrl,
}; };
use lemmy_db_queries::Joinable; use lemmy_db_queries::Joinable;
@ -78,8 +76,8 @@ impl RemoveMod {
}; };
let activity = AnnouncableActivities::RemoveMod(remove); let activity = AnnouncableActivities::RemoveMod(remove);
let inboxes = vec![removed_mod.get_shared_inbox_or_inbox_url()]; let inboxes = vec![removed_mod.shared_inbox_or_inbox_url()];
send_to_community_new(activity, &id, actor, community, inboxes, context).await send_to_community(activity, &id, actor, community, inboxes, context).await
} }
} }

View File

@ -1,15 +1,17 @@
use crate::{ use crate::{
activities::{ activities::{
community::{announce::AnnouncableActivities, block_user::BlockUserFromCommunity}, community::{
announce::AnnouncableActivities,
block_user::BlockUserFromCommunity,
send_to_community,
},
generate_activity_id, generate_activity_id,
verify_activity, verify_activity,
verify_mod_action, verify_mod_action,
verify_person_in_community, verify_person_in_community,
}, },
activity_queue::send_to_community_new, context::lemmy_context,
extensions::context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
ActorType,
}; };
use activitystreams::{ use activitystreams::{
activity::kind::UndoType, activity::kind::UndoType,
@ -20,7 +22,7 @@ use activitystreams::{
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl, values::PublicUrl,
}; };
use lemmy_db_queries::Bannable; use lemmy_db_queries::Bannable;
@ -74,8 +76,8 @@ impl UndoBlockUserFromCommunity {
}; };
let activity = AnnouncableActivities::UndoBlockUserFromCommunity(undo); let activity = AnnouncableActivities::UndoBlockUserFromCommunity(undo);
let inboxes = vec![target.get_shared_inbox_or_inbox_url()]; let inboxes = vec![target.shared_inbox_or_inbox_url()];
send_to_community_new(activity, &id, actor, community, inboxes, context).await send_to_community(activity, &id, actor, community, inboxes, context).await
} }
} }

View File

@ -1,16 +1,14 @@
use crate::{ use crate::{
activities::{ activities::{
community::announce::AnnouncableActivities, community::{announce::AnnouncableActivities, send_to_community},
generate_activity_id, generate_activity_id,
verify_activity, verify_activity,
verify_mod_action, verify_mod_action,
verify_person_in_community, verify_person_in_community,
}, },
activity_queue::send_to_community_new, context::lemmy_context,
extensions::context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
objects::{community::Group, ToApub}, objects::{community::Group, ToApub},
ActorType,
}; };
use activitystreams::{ use activitystreams::{
activity::kind::UpdateType, activity::kind::UpdateType,
@ -21,7 +19,7 @@ use activitystreams::{
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl, values::PublicUrl,
}; };
use lemmy_db_queries::Crud; use lemmy_db_queries::Crud;
@ -75,7 +73,7 @@ impl UpdateCommunity {
}; };
let activity = AnnouncableActivities::UpdateCommunity(Box::new(update)); let activity = AnnouncableActivities::UpdateCommunity(Box::new(update));
send_to_community_new(activity, &id, actor, community, vec![], context).await send_to_community(activity, &id, actor, community, vec![], context).await
} }
} }

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
activities::{ activities::{
community::announce::AnnouncableActivities, community::{announce::AnnouncableActivities, send_to_community},
deletion::{ deletion::{
receive_delete_action, receive_delete_action,
verify_delete_activity, verify_delete_activity,
@ -10,10 +10,8 @@ use crate::{
generate_activity_id, generate_activity_id,
verify_activity, verify_activity,
}, },
activity_queue::send_to_community_new, context::lemmy_context,
extensions::context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
ActorType,
}; };
use activitystreams::{ use activitystreams::{
activity::kind::DeleteType, activity::kind::DeleteType,
@ -25,7 +23,7 @@ use anyhow::anyhow;
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl, values::PublicUrl,
}; };
use lemmy_db_queries::{ use lemmy_db_queries::{
@ -171,7 +169,7 @@ impl Delete {
let delete_id = delete.id.clone(); let delete_id = delete.id.clone();
let activity = AnnouncableActivities::Delete(delete); let activity = AnnouncableActivities::Delete(delete);
send_to_community_new(activity, &delete_id, actor, community, vec![], context).await send_to_community(activity, &delete_id, actor, community, vec![], context).await
} }
} }

View File

@ -5,12 +5,11 @@ use crate::{
verify_person_in_community, verify_person_in_community,
}, },
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
ActorType,
}; };
use diesel::PgConnection; use diesel::PgConnection;
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
traits::{ActivityFields, ApubObject}, traits::{ActivityFields, ActorType, ApubObject},
verify::verify_domains_match, verify::verify_domains_match,
}; };
use lemmy_db_queries::source::{comment::Comment_, community::Community_, post::Post_}; use lemmy_db_queries::source::{comment::Comment_, community::Community_, post::Post_};

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
activities::{ activities::{
community::announce::AnnouncableActivities, community::{announce::AnnouncableActivities, send_to_community},
deletion::{ deletion::{
delete::Delete, delete::Delete,
receive_delete_action, receive_delete_action,
@ -11,10 +11,8 @@ use crate::{
generate_activity_id, generate_activity_id,
verify_activity, verify_activity,
}, },
activity_queue::send_to_community_new, context::lemmy_context,
extensions::context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
ActorType,
}; };
use activitystreams::{ use activitystreams::{
activity::kind::UndoType, activity::kind::UndoType,
@ -26,7 +24,7 @@ use anyhow::anyhow;
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl, values::PublicUrl,
}; };
use lemmy_db_queries::source::{comment::Comment_, community::Community_, post::Post_}; use lemmy_db_queries::source::{comment::Comment_, community::Community_, post::Post_};
@ -129,7 +127,7 @@ impl UndoDelete {
}; };
let activity = AnnouncableActivities::UndoDelete(undo); let activity = AnnouncableActivities::UndoDelete(undo);
send_to_community_new(activity, &id, actor, community, vec![], context).await send_to_community(activity, &id, actor, community, vec![], context).await
} }
pub(in crate::activities) async fn receive_undo_remove_action( pub(in crate::activities) async fn receive_undo_remove_action(

View File

@ -5,10 +5,9 @@ use crate::{
verify_activity, verify_activity,
verify_community, verify_community,
}, },
activity_queue::send_activity_new, context::lemmy_context,
extensions::context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
ActorType, send_lemmy_activity,
}; };
use activitystreams::{ use activitystreams::{
activity::kind::AcceptType, activity::kind::AcceptType,
@ -19,7 +18,7 @@ use activitystreams::{
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler}, traits::{ActivityFields, ActivityHandler, ActorType},
verify::verify_urls_match, verify::verify_urls_match,
}; };
use lemmy_db_queries::Followable; use lemmy_db_queries::Followable;
@ -72,9 +71,10 @@ impl AcceptFollowCommunity {
unparsed: Default::default(), unparsed: Default::default(),
}; };
let inbox = vec![person.inbox_url.into()]; let inbox = vec![person.inbox_url.into()];
send_activity_new(context, &accept, &accept.id, &community, inbox, true).await send_lemmy_activity(context, &accept, &accept.id, &community, inbox, true).await
} }
} }
/// Handle accepted follows /// Handle accepted follows
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
impl ActivityHandler for AcceptFollowCommunity { impl ActivityHandler for AcceptFollowCommunity {

View File

@ -5,10 +5,9 @@ use crate::{
verify_activity, verify_activity,
verify_person, verify_person,
}, },
activity_queue::send_activity_new, context::lemmy_context,
extensions::context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
ActorType, send_lemmy_activity,
}; };
use activitystreams::{ use activitystreams::{
activity::kind::FollowType, activity::kind::FollowType,
@ -19,7 +18,7 @@ use activitystreams::{
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler}, traits::{ActivityFields, ActivityHandler, ActorType},
verify::verify_urls_match, verify::verify_urls_match,
}; };
use lemmy_db_queries::Followable; use lemmy_db_queries::Followable;
@ -84,7 +83,7 @@ impl FollowCommunity {
let follow = FollowCommunity::new(actor, community, context)?; let follow = FollowCommunity::new(actor, community, context)?;
let inbox = vec![community.inbox_url.clone().into()]; let inbox = vec![community.inbox_url.clone().into()];
send_activity_new(context, &follow, &follow.id, actor, inbox, true).await send_lemmy_activity(context, &follow, &follow.id, actor, inbox, true).await
} }
} }

View File

@ -5,10 +5,9 @@ use crate::{
verify_activity, verify_activity,
verify_person, verify_person,
}, },
activity_queue::send_activity_new, context::lemmy_context,
extensions::context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
ActorType, send_lemmy_activity,
}; };
use activitystreams::{ use activitystreams::{
activity::kind::UndoType, activity::kind::UndoType,
@ -19,7 +18,7 @@ use activitystreams::{
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler}, traits::{ActivityFields, ActivityHandler, ActorType},
verify::verify_urls_match, verify::verify_urls_match,
}; };
use lemmy_db_queries::Followable; use lemmy_db_queries::Followable;
@ -66,8 +65,8 @@ impl UndoFollowCommunity {
context: lemmy_context(), context: lemmy_context(),
unparsed: Default::default(), unparsed: Default::default(),
}; };
let inbox = vec![community.get_shared_inbox_or_inbox_url()]; let inbox = vec![community.shared_inbox_or_inbox_url()];
send_activity_new(context, &undo, &undo.id, actor, inbox, true).await send_lemmy_activity(context, &undo, &undo.id, actor, inbox, true).await
} }
} }

View File

@ -22,7 +22,6 @@ pub mod deletion;
pub mod following; pub mod following;
pub mod post; pub mod post;
pub mod private_message; pub mod private_message;
pub mod send;
pub mod undo_remove; pub mod undo_remove;
pub mod voting; pub mod voting;

View File

@ -1,24 +1,22 @@
use crate::{ use crate::{
activities::{ activities::{
community::announce::AnnouncableActivities, community::{announce::AnnouncableActivities, send_to_community},
generate_activity_id, generate_activity_id,
verify_activity, verify_activity,
verify_mod_action, verify_mod_action,
verify_person_in_community, verify_person_in_community,
CreateOrUpdateType, CreateOrUpdateType,
}, },
activity_queue::send_to_community_new, context::lemmy_context,
extensions::context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
objects::{post::Page, FromApub, ToApub}, objects::{post::Page, FromApub, ToApub},
ActorType,
}; };
use activitystreams::{base::AnyBase, primitives::OneOrMany, unparsed::Unparsed}; use activitystreams::{base::AnyBase, primitives::OneOrMany, unparsed::Unparsed};
use anyhow::anyhow; use anyhow::anyhow;
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl, values::PublicUrl,
verify::{verify_domains_match, verify_urls_match}, verify::{verify_domains_match, verify_urls_match},
}; };
@ -74,7 +72,7 @@ impl CreateOrUpdatePost {
}; };
let activity = AnnouncableActivities::CreateOrUpdatePost(Box::new(create_or_update)); let activity = AnnouncableActivities::CreateOrUpdatePost(Box::new(create_or_update));
send_to_community_new(activity, &id, actor, &community, vec![], context).await send_to_community(activity, &id, actor, &community, vec![], context).await
} }
} }

View File

@ -1,16 +1,15 @@
use crate::{ use crate::{
activities::{generate_activity_id, verify_activity, verify_person, CreateOrUpdateType}, activities::{generate_activity_id, verify_activity, verify_person, CreateOrUpdateType},
activity_queue::send_activity_new, context::lemmy_context,
extensions::context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
objects::{private_message::Note, FromApub, ToApub}, objects::{private_message::Note, FromApub, ToApub},
ActorType, send_lemmy_activity,
}; };
use activitystreams::{base::AnyBase, primitives::OneOrMany, unparsed::Unparsed}; use activitystreams::{base::AnyBase, primitives::OneOrMany, unparsed::Unparsed};
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler}, traits::{ActivityFields, ActivityHandler, ActorType},
verify::verify_domains_match, verify::verify_domains_match,
}; };
use lemmy_db_queries::Crud; use lemmy_db_queries::Crud;
@ -59,8 +58,8 @@ impl CreateOrUpdatePrivateMessage {
kind, kind,
unparsed: Default::default(), unparsed: Default::default(),
}; };
let inbox = vec![recipient.get_shared_inbox_or_inbox_url()]; let inbox = vec![recipient.shared_inbox_or_inbox_url()];
send_activity_new(context, &create_or_update, &id, actor, inbox, true).await send_lemmy_activity(context, &create_or_update, &id, actor, inbox, true).await
} }
} }
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]

View File

@ -1,9 +1,8 @@
use crate::{ use crate::{
activities::{generate_activity_id, verify_activity, verify_person}, activities::{generate_activity_id, verify_activity, verify_person},
activity_queue::send_activity_new, context::lemmy_context,
extensions::context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
ActorType, send_lemmy_activity,
}; };
use activitystreams::{ use activitystreams::{
activity::kind::DeleteType, activity::kind::DeleteType,
@ -14,7 +13,7 @@ use activitystreams::{
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler}, traits::{ActivityFields, ActivityHandler, ActorType},
verify::verify_domains_match, verify::verify_domains_match,
}; };
use lemmy_db_queries::{source::private_message::PrivateMessage_, Crud}; use lemmy_db_queries::{source::private_message::PrivateMessage_, Crud};
@ -69,8 +68,8 @@ impl DeletePrivateMessage {
let recipient_id = pm.recipient_id; let recipient_id = pm.recipient_id;
let recipient = let recipient =
blocking(context.pool(), move |conn| Person::read(conn, recipient_id)).await??; blocking(context.pool(), move |conn| Person::read(conn, recipient_id)).await??;
let inbox = vec![recipient.get_shared_inbox_or_inbox_url()]; let inbox = vec![recipient.shared_inbox_or_inbox_url()];
send_activity_new(context, &delete, &delete_id, actor, inbox, true).await send_lemmy_activity(context, &delete, &delete_id, actor, inbox, true).await
} }
} }

View File

@ -5,10 +5,9 @@ use crate::{
verify_activity, verify_activity,
verify_person, verify_person,
}, },
activity_queue::send_activity_new, context::lemmy_context,
extensions::context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
ActorType, send_lemmy_activity,
}; };
use activitystreams::{ use activitystreams::{
activity::kind::UndoType, activity::kind::UndoType,
@ -19,7 +18,7 @@ use activitystreams::{
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler}, traits::{ActivityFields, ActivityHandler, ActorType},
verify::{verify_domains_match, verify_urls_match}, verify::{verify_domains_match, verify_urls_match},
}; };
use lemmy_db_queries::{source::private_message::PrivateMessage_, Crud}; use lemmy_db_queries::{source::private_message::PrivateMessage_, Crud};
@ -68,8 +67,8 @@ impl UndoDeletePrivateMessage {
context: lemmy_context(), context: lemmy_context(),
unparsed: Default::default(), unparsed: Default::default(),
}; };
let inbox = vec![recipient.get_shared_inbox_or_inbox_url()]; let inbox = vec![recipient.shared_inbox_or_inbox_url()];
send_activity_new(context, &undo, &id, actor, inbox, true).await send_lemmy_activity(context, &undo, &id, actor, inbox, true).await
} }
} }

View File

@ -1,66 +0,0 @@
use crate::{check_is_apub_id_valid, ActorType, CommunityType};
use itertools::Itertools;
use lemmy_api_common::blocking;
use lemmy_db_queries::DbPool;
use lemmy_db_schema::source::community::Community;
use lemmy_db_views_actor::community_follower_view::CommunityFollowerView;
use lemmy_utils::{settings::structs::Settings, LemmyError};
use url::Url;
impl ActorType for Community {
fn is_local(&self) -> bool {
self.local
}
fn actor_id(&self) -> Url {
self.actor_id.to_owned().into()
}
fn name(&self) -> String {
self.name.clone()
}
fn public_key(&self) -> Option<String> {
self.public_key.to_owned()
}
fn private_key(&self) -> Option<String> {
self.private_key.to_owned()
}
fn get_shared_inbox_or_inbox_url(&self) -> Url {
self
.shared_inbox_url
.clone()
.unwrap_or_else(|| self.inbox_url.to_owned())
.into()
}
}
#[async_trait::async_trait(?Send)]
impl CommunityType for Community {
fn followers_url(&self) -> Url {
self.followers_url.clone().into()
}
/// For a given community, returns the inboxes of all followers.
async fn get_follower_inboxes(
&self,
pool: &DbPool,
settings: &Settings,
) -> Result<Vec<Url>, LemmyError> {
let id = self.id;
let follows = blocking(pool, move |conn| {
CommunityFollowerView::for_community(conn, id)
})
.await??;
let inboxes = follows
.into_iter()
.filter(|f| !f.follower.local)
.map(|f| f.follower.shared_inbox_url.unwrap_or(f.follower.inbox_url))
.map(|i| i.into_inner())
.unique()
// Don't send to blocked instances
.filter(|inbox| check_is_apub_id_valid(inbox, false, settings).is_ok())
.collect();
Ok(inboxes)
}
}

View File

@ -1,2 +0,0 @@
pub(crate) mod community;
pub(crate) mod person;

View File

@ -1,31 +0,0 @@
use crate::ActorType;
use lemmy_db_schema::source::person::Person;
use url::Url;
impl ActorType for Person {
fn is_local(&self) -> bool {
self.local
}
fn actor_id(&self) -> Url {
self.actor_id.to_owned().into_inner()
}
fn name(&self) -> String {
self.name.clone()
}
fn public_key(&self) -> Option<String> {
self.public_key.to_owned()
}
fn private_key(&self) -> Option<String> {
self.private_key.to_owned()
}
fn get_shared_inbox_or_inbox_url(&self) -> Url {
self
.shared_inbox_url
.clone()
.unwrap_or_else(|| self.inbox_url.to_owned())
.into()
}
}

View File

@ -1,6 +1,6 @@
use crate::{ use crate::{
activities::{ activities::{
community::announce::AnnouncableActivities, community::{announce::AnnouncableActivities, send_to_community},
generate_activity_id, generate_activity_id,
verify_activity, verify_activity,
verify_person_in_community, verify_person_in_community,
@ -10,10 +10,8 @@ use crate::{
vote::{Vote, VoteType}, vote::{Vote, VoteType},
}, },
}, },
activity_queue::send_to_community_new, context::lemmy_context,
extensions::context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
ActorType,
PostOrComment, PostOrComment,
}; };
use activitystreams::{ use activitystreams::{
@ -25,7 +23,7 @@ use activitystreams::{
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl, values::PublicUrl,
verify::verify_urls_match, verify::verify_urls_match,
}; };
@ -85,7 +83,7 @@ impl UndoVote {
unparsed: Default::default(), unparsed: Default::default(),
}; };
let activity = AnnouncableActivities::UndoVote(undo_vote); let activity = AnnouncableActivities::UndoVote(undo_vote);
send_to_community_new(activity, &id, actor, &community, vec![], context).await send_to_community(activity, &id, actor, &community, vec![], context).await
} }
} }

View File

@ -1,15 +1,13 @@
use crate::{ use crate::{
activities::{ activities::{
community::announce::AnnouncableActivities, community::{announce::AnnouncableActivities, send_to_community},
generate_activity_id, generate_activity_id,
verify_activity, verify_activity,
verify_person_in_community, verify_person_in_community,
voting::{vote_comment, vote_post}, voting::{vote_comment, vote_post},
}, },
activity_queue::send_to_community_new, context::lemmy_context,
extensions::context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
ActorType,
PostOrComment, PostOrComment,
}; };
use activitystreams::{base::AnyBase, primitives::OneOrMany, unparsed::Unparsed}; use activitystreams::{base::AnyBase, primitives::OneOrMany, unparsed::Unparsed};
@ -17,7 +15,7 @@ use anyhow::anyhow;
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
traits::{ActivityFields, ActivityHandler}, traits::{ActivityFields, ActivityHandler, ActorType},
values::PublicUrl, values::PublicUrl,
}; };
use lemmy_db_queries::Crud; use lemmy_db_queries::Crud;
@ -110,7 +108,7 @@ impl Vote {
let vote_id = vote.id.clone(); let vote_id = vote.id.clone();
let activity = AnnouncableActivities::Vote(vote); let activity = AnnouncableActivities::Vote(vote);
send_to_community_new(activity, &vote_id, actor, &community, vec![], context).await send_to_community(activity, &vote_id, actor, &community, vec![], context).await
} }
} }

View File

@ -1,2 +0,0 @@
pub mod context;
pub mod signatures;

View File

@ -1,5 +1,6 @@
use crate::{check_is_apub_id_valid, APUB_JSON_CONTENT_TYPE}; use crate::check_is_apub_id_valid;
use anyhow::anyhow; use anyhow::anyhow;
use lemmy_apub_lib::APUB_JSON_CONTENT_TYPE;
use lemmy_utils::{request::retry, settings::structs::Settings, LemmyError}; use lemmy_utils::{request::retry, settings::structs::Settings, LemmyError};
use log::info; use log::info;
use reqwest::Client; use reqwest::Client;

View File

@ -5,8 +5,9 @@ pub mod object_id;
pub mod post_or_comment; pub mod post_or_comment;
pub mod search; pub mod search;
use crate::{fetcher::object_id::ObjectId, ActorType}; use crate::fetcher::object_id::ObjectId;
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use lemmy_apub_lib::traits::ActorType;
use lemmy_db_schema::{ use lemmy_db_schema::{
naive_now, naive_now,
source::{community::Community, person::Person}, source::{community::Community, person::Person},

View File

@ -1,12 +1,11 @@
use crate::{ use crate::{
fetcher::{deletable_apub_object::DeletableApubObject, should_refetch_actor}, fetcher::{deletable_apub_object::DeletableApubObject, should_refetch_actor},
objects::FromApub, objects::FromApub,
APUB_JSON_CONTENT_TYPE,
}; };
use anyhow::anyhow; use anyhow::anyhow;
use diesel::{NotFound, PgConnection}; use diesel::{NotFound, PgConnection};
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::traits::ApubObject; use lemmy_apub_lib::{traits::ApubObject, APUB_JSON_CONTENT_TYPE};
use lemmy_db_queries::DbPool; use lemmy_db_queries::DbPool;
use lemmy_db_schema::DbUrl; use lemmy_db_schema::DbUrl;
use lemmy_utils::{request::retry, settings::structs::Settings, LemmyError}; use lemmy_utils::{request::retry, settings::structs::Settings, LemmyError};

View File

@ -4,8 +4,9 @@ use crate::{
extract_community, extract_community,
following::{follow::FollowCommunity, undo::UndoFollowCommunity}, following::{follow::FollowCommunity, undo::UndoFollowCommunity},
}, },
extensions::context::lemmy_context, context::lemmy_context,
generate_moderators_url, generate_moderators_url,
generate_outbox_url,
http::{ http::{
create_apub_response, create_apub_response,
create_apub_tombstone_response, create_apub_tombstone_response,
@ -13,7 +14,6 @@ use crate::{
receive_activity, receive_activity,
}, },
objects::ToApub, objects::ToApub,
ActorType,
}; };
use activitystreams::{ use activitystreams::{
base::{AnyBase, BaseExt}, base::{AnyBase, BaseExt},
@ -147,7 +147,7 @@ pub(crate) async fn get_apub_community_outbox(
collection collection
.set_many_items(activities) .set_many_items(activities)
.set_many_contexts(lemmy_context()) .set_many_contexts(lemmy_context())
.set_id(community.get_outbox_url()?) .set_id(generate_outbox_url(&community.actor_id)?.into())
.set_total_items(len as u64); .set_total_items(len as u64);
Ok(create_apub_response(&collection)) Ok(create_apub_response(&collection))
} }

View File

@ -1,13 +1,11 @@
use crate::{ use crate::{
check_is_apub_id_valid, check_is_apub_id_valid,
extensions::signatures::verify_signature,
fetcher::get_or_fetch_and_upsert_actor, fetcher::get_or_fetch_and_upsert_actor,
http::{ http::{
community::{receive_group_inbox, GroupInboxActivities}, community::{receive_group_inbox, GroupInboxActivities},
person::{receive_person_inbox, PersonInboxActivities}, person::{receive_person_inbox, PersonInboxActivities},
}, },
insert_activity, insert_activity,
APUB_JSON_CONTENT_TYPE,
}; };
use actix_web::{ use actix_web::{
body::Body, body::Body,
@ -22,7 +20,9 @@ use http::StatusCode;
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
data::Data, data::Data,
signatures::verify_signature,
traits::{ActivityFields, ActivityHandler}, traits::{ActivityFields, ActivityHandler},
APUB_JSON_CONTENT_TYPE,
}; };
use lemmy_db_queries::{source::activity::Activity_, DbPool}; use lemmy_db_queries::{source::activity::Activity_, DbPool};
use lemmy_db_schema::source::activity::Activity; use lemmy_db_schema::source::activity::Activity;

View File

@ -8,7 +8,8 @@ use crate::{
undo_delete::UndoDeletePrivateMessage, undo_delete::UndoDeletePrivateMessage,
}, },
}, },
extensions::context::lemmy_context, context::lemmy_context,
generate_outbox_url,
http::{ http::{
create_apub_response, create_apub_response,
create_apub_tombstone_response, create_apub_tombstone_response,
@ -16,7 +17,6 @@ use crate::{
receive_activity, receive_activity,
}, },
objects::ToApub, objects::ToApub,
ActorType,
}; };
use activitystreams::{ use activitystreams::{
base::BaseExt, base::BaseExt,
@ -105,7 +105,7 @@ pub(crate) async fn get_apub_person_outbox(
collection collection
.set_many_items(Vec::<Url>::new()) .set_many_items(Vec::<Url>::new())
.set_many_contexts(lemmy_context()) .set_many_contexts(lemmy_context())
.set_id(person.get_outbox_url()?) .set_id(generate_outbox_url(&person.actor_id)?.into())
.set_total_items(0_u64); .set_total_items(0_u64);
Ok(create_apub_response(&collection)) Ok(create_apub_response(&collection))
} }

View File

@ -1,5 +1,4 @@
use crate::{ use crate::http::{
http::{
comment::get_apub_comment, comment::get_apub_comment,
community::{ community::{
community_inbox, community_inbox,
@ -13,11 +12,10 @@ use crate::{
person::{get_apub_person_http, get_apub_person_inbox, get_apub_person_outbox, person_inbox}, person::{get_apub_person_http, get_apub_person_inbox, get_apub_person_outbox, person_inbox},
post::get_apub_post, post::get_apub_post,
shared_inbox, shared_inbox,
},
APUB_JSON_CONTENT_TYPE,
}; };
use actix_web::*; use actix_web::*;
use http_signature_normalization_actix::digest::middleware::VerifyDigest; use http_signature_normalization_actix::digest::middleware::VerifyDigest;
use lemmy_apub_lib::APUB_JSON_CONTENT_TYPE;
use lemmy_utils::settings::structs::Settings; use lemmy_utils::settings::structs::Settings;
use sha2::{Digest, Sha256}; use sha2::{Digest, Sha256};

View File

@ -1,17 +1,14 @@
#[macro_use]
extern crate lazy_static;
pub mod activities; pub mod activities;
pub mod activity_queue; mod context;
pub mod extensions;
pub mod fetcher; pub mod fetcher;
pub mod http; pub mod http;
pub mod migrations; pub mod migrations;
pub mod objects; pub mod objects;
use crate::{extensions::signatures::PublicKey, fetcher::post_or_comment::PostOrComment}; use crate::fetcher::post_or_comment::PostOrComment;
use anyhow::{anyhow, Context}; use anyhow::{anyhow, Context};
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{activity_queue::send_activity, traits::ActorType};
use lemmy_db_queries::{source::activity::Activity_, DbPool}; use lemmy_db_queries::{source::activity::Activity_, DbPool};
use lemmy_db_schema::{ use lemmy_db_schema::{
source::{activity::Activity, person::Person}, source::{activity::Activity, person::Person},
@ -20,12 +17,12 @@ use lemmy_db_schema::{
}; };
use lemmy_db_views_actor::community_person_ban_view::CommunityPersonBanView; use lemmy_db_views_actor::community_person_ban_view::CommunityPersonBanView;
use lemmy_utils::{location_info, settings::structs::Settings, LemmyError}; use lemmy_utils::{location_info, settings::structs::Settings, LemmyError};
use lemmy_websocket::LemmyContext;
use log::info;
use serde::Serialize; use serde::Serialize;
use std::net::IpAddr; use std::net::IpAddr;
use url::{ParseError, Url}; use url::{ParseError, Url};
static APUB_JSON_CONTENT_TYPE: &str = "application/activity+json";
/// Checks if the ID is allowed for sending or receiving. /// Checks if the ID is allowed for sending or receiving.
/// ///
/// In particular, it checks for: /// In particular, it checks for:
@ -92,39 +89,6 @@ pub(crate) fn check_is_apub_id_valid(
Ok(()) Ok(())
} }
/// Common methods provided by ActivityPub actors (community and person). Not all methods are
/// implemented by all actors.
trait ActorType {
fn is_local(&self) -> bool;
fn actor_id(&self) -> Url;
fn name(&self) -> String;
// TODO: every actor should have a public key, so this shouldnt be an option (needs to be fixed in db)
fn public_key(&self) -> Option<String>;
fn private_key(&self) -> Option<String>;
fn get_shared_inbox_or_inbox_url(&self) -> Url;
/// Outbox URL is not generally used by Lemmy, so it can be generated on the fly (but only for
/// local actors).
fn get_outbox_url(&self) -> Result<Url, LemmyError> {
/* TODO
if !self.is_local() {
return Err(anyhow!("get_outbox_url() called for remote actor").into());
}
*/
Ok(Url::parse(&format!("{}/outbox", &self.actor_id()))?)
}
fn get_public_key(&self) -> Result<PublicKey, LemmyError> {
Ok(PublicKey {
id: format!("{}#main-key", self.actor_id()),
owner: self.actor_id(),
public_key_pem: self.public_key().context(location_info!())?,
})
}
}
#[async_trait::async_trait(?Send)] #[async_trait::async_trait(?Send)]
pub trait CommunityType { pub trait CommunityType {
fn followers_url(&self) -> Url; fn followers_url(&self) -> Url;
@ -192,6 +156,10 @@ pub fn generate_shared_inbox_url(actor_id: &DbUrl) -> Result<DbUrl, LemmyError>
Ok(Url::parse(&url)?.into()) Ok(Url::parse(&url)?.into())
} }
pub fn generate_outbox_url(actor_id: &DbUrl) -> Result<DbUrl, ParseError> {
Ok(Url::parse(&format!("{}/outbox", actor_id))?.into())
}
fn generate_moderators_url(community_id: &DbUrl) -> Result<DbUrl, LemmyError> { fn generate_moderators_url(community_id: &DbUrl) -> Result<DbUrl, LemmyError> {
Ok(Url::parse(&format!("{}/moderators", community_id))?.into()) Ok(Url::parse(&format!("{}/moderators", community_id))?.into())
} }
@ -254,3 +222,46 @@ async fn check_community_or_site_ban(
Ok(()) Ok(())
} }
pub(crate) async fn send_lemmy_activity<T: Serialize>(
context: &LemmyContext,
activity: &T,
activity_id: &Url,
actor: &dyn ActorType,
inboxes: Vec<Url>,
sensitive: bool,
) -> Result<(), LemmyError> {
if !context.settings().federation.enabled || inboxes.is_empty() {
return Ok(());
}
info!("Sending activity {}", activity_id.to_string());
// Don't send anything to ourselves
// TODO: this should be a debug assert
let hostname = context.settings().get_hostname_without_port()?;
let inboxes: Vec<&Url> = inboxes
.iter()
.filter(|i| i.domain().expect("valid inbox url") != hostname)
.collect();
let serialised_activity = serde_json::to_string(&activity)?;
insert_activity(
activity_id,
serialised_activity.clone(),
true,
sensitive,
context.pool(),
)
.await?;
send_activity(
serialised_activity,
actor,
inboxes,
context.client(),
context.activity_queue(),
)
.await
}

View File

@ -1,10 +1,9 @@
use crate::{ use crate::{
activities::verify_person_in_community, activities::verify_person_in_community,
extensions::context::lemmy_context, context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
migrations::CommentInReplyToMigration, migrations::CommentInReplyToMigration,
objects::{create_tombstone, FromApub, Source, ToApub}, objects::{create_tombstone, FromApub, Source, ToApub},
ActorType,
PostOrComment, PostOrComment,
}; };
use activitystreams::{ use activitystreams::{
@ -17,6 +16,7 @@ use anyhow::{anyhow, Context};
use chrono::{DateTime, FixedOffset}; use chrono::{DateTime, FixedOffset};
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
traits::ActorType,
values::{MediaTypeHtml, MediaTypeMarkdown, PublicUrl}, values::{MediaTypeHtml, MediaTypeMarkdown, PublicUrl},
verify::verify_domains_match, verify::verify_domains_match,
}; };

View File

@ -1,9 +1,11 @@
use crate::{ use crate::{
extensions::{context::lemmy_context, signatures::PublicKey}, check_is_apub_id_valid,
context::lemmy_context,
fetcher::community::{fetch_community_outbox, update_community_mods}, fetcher::community::{fetch_community_outbox, update_community_mods},
generate_moderators_url, generate_moderators_url,
generate_outbox_url,
objects::{create_tombstone, FromApub, ImageObject, Source, ToApub}, objects::{create_tombstone, FromApub, ImageObject, Source, ToApub},
ActorType, CommunityType,
}; };
use activitystreams::{ use activitystreams::{
actor::{kind::GroupType, Endpoints}, actor::{kind::GroupType, Endpoints},
@ -13,8 +15,11 @@ use activitystreams::{
unparsed::Unparsed, unparsed::Unparsed,
}; };
use chrono::{DateTime, FixedOffset}; use chrono::{DateTime, FixedOffset};
use itertools::Itertools;
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
signatures::PublicKey,
traits::ActorType,
values::{MediaTypeHtml, MediaTypeMarkdown}, values::{MediaTypeHtml, MediaTypeMarkdown},
verify::verify_domains_match, verify::verify_domains_match,
}; };
@ -23,6 +28,7 @@ use lemmy_db_schema::{
naive_now, naive_now,
source::community::{Community, CommunityForm}, source::community::{Community, CommunityForm},
}; };
use lemmy_db_views_actor::community_follower_view::CommunityFollowerView;
use lemmy_utils::{ use lemmy_utils::{
settings::structs::Settings, settings::structs::Settings,
utils::{check_slurs, check_slurs_opt, convert_datetime, markdown_to_html}, utils::{check_slurs, check_slurs_opt, convert_datetime, markdown_to_html},
@ -143,7 +149,7 @@ impl ToApub for Community {
sensitive: Some(self.nsfw), sensitive: Some(self.nsfw),
moderators: Some(generate_moderators_url(&self.actor_id)?.into()), moderators: Some(generate_moderators_url(&self.actor_id)?.into()),
inbox: self.inbox_url.clone().into(), inbox: self.inbox_url.clone().into(),
outbox: self.get_outbox_url()?, outbox: generate_outbox_url(&self.actor_id)?.into(),
followers: self.followers_url.clone().into(), followers: self.followers_url.clone().into(),
endpoints: Endpoints { endpoints: Endpoints {
shared_inbox: self.shared_inbox_url.clone().map(|s| s.into()), shared_inbox: self.shared_inbox_url.clone().map(|s| s.into()),
@ -189,3 +195,35 @@ impl FromApub for Community {
Ok(community) Ok(community)
} }
} }
#[async_trait::async_trait(?Send)]
impl CommunityType for Community {
fn followers_url(&self) -> Url {
self.followers_url.clone().into()
}
/// For a given community, returns the inboxes of all followers.
async fn get_follower_inboxes(
&self,
pool: &DbPool,
settings: &Settings,
) -> Result<Vec<Url>, LemmyError> {
let id = self.id;
let follows = blocking(pool, move |conn| {
CommunityFollowerView::for_community(conn, id)
})
.await??;
let inboxes = follows
.into_iter()
.filter(|f| !f.follower.local)
.map(|f| f.follower.shared_inbox_url.unwrap_or(f.follower.inbox_url))
.map(|i| i.into_inner())
.unique()
// Don't send to blocked instances
.filter(|inbox| check_is_apub_id_valid(inbox, false, settings).is_ok())
.collect();
Ok(inboxes)
}
}

View File

@ -1,8 +1,8 @@
use crate::{ use crate::{
check_is_apub_id_valid, check_is_apub_id_valid,
extensions::{context::lemmy_context, signatures::PublicKey}, context::lemmy_context,
generate_outbox_url,
objects::{FromApub, ImageObject, Source, ToApub}, objects::{FromApub, ImageObject, Source, ToApub},
ActorType,
}; };
use activitystreams::{ use activitystreams::{
actor::Endpoints, actor::Endpoints,
@ -14,6 +14,8 @@ use activitystreams::{
}; };
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
signatures::PublicKey,
traits::ActorType,
values::{MediaTypeHtml, MediaTypeMarkdown}, values::{MediaTypeHtml, MediaTypeMarkdown},
verify::verify_domains_match, verify::verify_domains_match,
}; };
@ -113,7 +115,7 @@ impl ToApub for DbPerson {
image, image,
matrix_user_id: self.matrix_user_id.clone(), matrix_user_id: self.matrix_user_id.clone(),
published: convert_datetime(self.published), published: convert_datetime(self.published),
outbox: self.get_outbox_url()?, outbox: generate_outbox_url(&self.actor_id)?.into(),
endpoints: Endpoints { endpoints: Endpoints {
shared_inbox: self.shared_inbox_url.clone().map(|s| s.into()), shared_inbox: self.shared_inbox_url.clone().map(|s| s.into()),
..Default::default() ..Default::default()

View File

@ -1,9 +1,8 @@
use crate::{ use crate::{
activities::{extract_community, verify_person_in_community}, activities::{extract_community, verify_person_in_community},
extensions::context::lemmy_context, context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
objects::{create_tombstone, FromApub, ImageObject, Source, ToApub}, objects::{create_tombstone, FromApub, ImageObject, Source, ToApub},
ActorType,
}; };
use activitystreams::{ use activitystreams::{
base::AnyBase, base::AnyBase,
@ -18,6 +17,7 @@ use activitystreams::{
use chrono::{DateTime, FixedOffset}; use chrono::{DateTime, FixedOffset};
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_apub_lib::{ use lemmy_apub_lib::{
traits::ActorType,
values::{MediaTypeHtml, MediaTypeMarkdown}, values::{MediaTypeHtml, MediaTypeMarkdown},
verify::verify_domains_match, verify::verify_domains_match,
}; };

View File

@ -1,5 +1,5 @@
use crate::{ use crate::{
extensions::context::lemmy_context, context::lemmy_context,
fetcher::object_id::ObjectId, fetcher::object_id::ObjectId,
objects::{create_tombstone, FromApub, Source, ToApub}, objects::{create_tombstone, FromApub, Source, ToApub},
}; };

View File

@ -16,3 +16,12 @@ serde_json = { version = "1.0.68", features = ["preserve_order"] }
anyhow = "1.0.44" anyhow = "1.0.44"
reqwest = { version = "0.11.4", features = ["json"] } reqwest = { version = "0.11.4", features = ["json"] }
log = "0.4.14" log = "0.4.14"
base64 = "0.13.0"
openssl = "0.10.36"
lazy_static = "1.4.0"
http = "0.2.5"
sha2 = "0.9.8"
actix-web = { version = "4.0.0-beta.9", default-features = false }
http-signature-normalization-actix = { version = "0.5.0-beta.10", default-features = false, features = ["server", "sha-2"] }
http-signature-normalization-reqwest = { version = "0.2.0", default-features = false, features = ["sha-2"] }
background-jobs = "0.10.0"

View File

@ -1,10 +1,4 @@
use crate::{ use crate::{signatures::sign_and_send, traits::ActorType, APUB_JSON_CONTENT_TYPE};
activities::community::announce::{AnnouncableActivities, AnnounceActivity},
extensions::signatures::sign_and_send,
insert_activity,
ActorType,
APUB_JSON_CONTENT_TYPE,
};
use anyhow::{anyhow, Context, Error}; use anyhow::{anyhow, Context, Error};
use background_jobs::{ use background_jobs::{
create_server, create_server,
@ -15,83 +9,31 @@ use background_jobs::{
QueueHandle, QueueHandle,
WorkerConfig, WorkerConfig,
}; };
use lemmy_db_schema::source::community::Community;
use lemmy_utils::{location_info, LemmyError}; use lemmy_utils::{location_info, LemmyError};
use lemmy_websocket::LemmyContext; use log::warn;
use log::{info, warn};
use reqwest::Client; use reqwest::Client;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::{collections::BTreeMap, env, fmt::Debug, future::Future, pin::Pin}; use std::{collections::BTreeMap, env, fmt::Debug, future::Future, pin::Pin};
use url::Url; use url::Url;
pub(crate) async fn send_to_community_new( pub async fn send_activity(
activity: AnnouncableActivities, activity: String,
activity_id: &Url,
actor: &dyn ActorType, actor: &dyn ActorType,
community: &Community, inboxes: Vec<&Url>,
additional_inboxes: Vec<Url>, client: &Client,
context: &LemmyContext, activity_queue: &QueueHandle,
) -> Result<(), LemmyError> { ) -> Result<(), LemmyError> {
// if this is a local community, we need to do an announce from the community instead
if community.local {
insert_activity(activity_id, activity.clone(), true, false, context.pool()).await?;
AnnounceActivity::send(activity, community, additional_inboxes, context).await?;
} else {
let mut inboxes = additional_inboxes;
inboxes.push(community.get_shared_inbox_or_inbox_url());
send_activity_new(context, &activity, activity_id, actor, inboxes, false).await?;
}
Ok(())
}
pub(crate) async fn send_activity_new<T>(
context: &LemmyContext,
activity: &T,
activity_id: &Url,
actor: &dyn ActorType,
inboxes: Vec<Url>,
sensitive: bool,
) -> Result<(), LemmyError>
where
T: Serialize,
{
if !context.settings().federation.enabled || inboxes.is_empty() {
return Ok(());
}
info!("Sending activity {}", activity_id.to_string());
// Don't send anything to ourselves
// TODO: this should be a debug assert
let hostname = context.settings().get_hostname_without_port()?;
let inboxes: Vec<&Url> = inboxes
.iter()
.filter(|i| i.domain().expect("valid inbox url") != hostname)
.collect();
let serialised_activity = serde_json::to_string(&activity)?;
insert_activity(
activity_id,
serialised_activity.clone(),
true,
sensitive,
context.pool(),
)
.await?;
for i in inboxes { for i in inboxes {
let message = SendActivityTask { let message = SendActivityTask {
activity: serialised_activity.to_owned(), activity: activity.clone(),
inbox: i.to_owned(), inbox: i.to_owned(),
actor_id: actor.actor_id(), actor_id: actor.actor_id(),
private_key: actor.private_key().context(location_info!())?, private_key: actor.private_key().context(location_info!())?,
}; };
if env::var("LEMMY_TEST_SEND_SYNC").is_ok() { if env::var("APUB_TESTING_SEND_SYNC").is_ok() {
do_send(message, context.client()).await?; do_send(message, client).await?;
} else { } else {
context.activity_queue.queue::<SendActivityTask>(message)?; activity_queue.queue::<SendActivityTask>(message)?;
} }
} }

View File

@ -1,5 +1,12 @@
#[macro_use]
extern crate lazy_static;
pub mod activity_queue;
pub mod data; pub mod data;
pub mod signatures;
pub mod traits; pub mod traits;
pub mod values; pub mod values;
pub mod verify; pub mod verify;
pub mod webfinger; pub mod webfinger;
pub static APUB_JSON_CONTENT_TYPE: &str = "application/activity+json";

View File

@ -23,7 +23,7 @@ lazy_static! {
/// Creates an HTTP post request to `inbox_url`, with the given `client` and `headers`, and /// Creates an HTTP post request to `inbox_url`, with the given `client` and `headers`, and
/// `activity` as request body. The request is signed with `private_key` and then sent. /// `activity` as request body. The request is signed with `private_key` and then sent.
pub(crate) async fn sign_and_send( pub async fn sign_and_send(
client: &Client, client: &Client,
headers: BTreeMap<String, String>, headers: BTreeMap<String, String>,
inbox_url: &Url, inbox_url: &Url,
@ -62,7 +62,7 @@ pub(crate) async fn sign_and_send(
} }
/// Verifies the HTTP signature on an incoming inbox request. /// Verifies the HTTP signature on an incoming inbox request.
pub(crate) fn verify_signature(request: &HttpRequest, public_key: &str) -> Result<(), LemmyError> { pub fn verify_signature(request: &HttpRequest, public_key: &str) -> Result<(), LemmyError> {
let verified = CONFIG2 let verified = CONFIG2
.begin_verify( .begin_verify(
request.method(), request.method(),

View File

@ -1,7 +1,8 @@
use crate::data::Data; use crate::{data::Data, signatures::PublicKey};
use activitystreams::chrono::NaiveDateTime; use activitystreams::chrono::NaiveDateTime;
use anyhow::Context;
pub use lemmy_apub_lib_derive::*; pub use lemmy_apub_lib_derive::*;
use lemmy_utils::LemmyError; use lemmy_utils::{location_info, LemmyError};
use url::Url; use url::Url;
pub trait ActivityFields { pub trait ActivityFields {
@ -36,3 +37,31 @@ pub trait ApubObject {
where where
Self: Sized; Self: Sized;
} }
/// Common methods provided by ActivityPub actors (community and person). Not all methods are
/// implemented by all actors.
pub trait ActorType {
fn is_local(&self) -> bool;
fn actor_id(&self) -> Url;
fn name(&self) -> String;
// TODO: this should not be an option (needs db migration in lemmy)
fn public_key(&self) -> Option<String>;
fn private_key(&self) -> Option<String>;
fn inbox_url(&self) -> Url;
fn shared_inbox_url(&self) -> Option<Url>;
fn shared_inbox_or_inbox_url(&self) -> Url {
self.shared_inbox_url().unwrap_or_else(|| self.inbox_url())
}
fn get_public_key(&self) -> Result<PublicKey, LemmyError> {
Ok(PublicKey {
id: format!("{}#main-key", self.actor_id()),
owner: self.actor_id(),
public_key_pem: self.public_key().context(location_info!())?,
})
}
}

View File

@ -6,7 +6,7 @@ use crate::{
}; };
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use diesel::{ExpressionMethods, PgConnection, QueryDsl, RunQueryDsl}; use diesel::{ExpressionMethods, PgConnection, QueryDsl, RunQueryDsl};
use lemmy_apub_lib::traits::ApubObject; use lemmy_apub_lib::traits::{ActorType, ApubObject};
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;
use serde::Serialize; use serde::Serialize;
use url::Url; use url::Url;
@ -148,3 +148,29 @@ impl ApubObject for Community {
) )
} }
} }
impl ActorType for Community {
fn is_local(&self) -> bool {
self.local
}
fn actor_id(&self) -> Url {
self.actor_id.to_owned().into()
}
fn name(&self) -> String {
self.name.clone()
}
fn public_key(&self) -> Option<String> {
self.public_key.to_owned()
}
fn private_key(&self) -> Option<String> {
self.private_key.to_owned()
}
fn inbox_url(&self) -> Url {
self.inbox_url.clone().into()
}
fn shared_inbox_url(&self) -> Option<Url> {
self.shared_inbox_url.clone().map(|s| s.into_inner())
}
}

View File

@ -5,7 +5,7 @@ use crate::{
}; };
use chrono::NaiveDateTime; use chrono::NaiveDateTime;
use diesel::{ExpressionMethods, PgConnection, QueryDsl, RunQueryDsl}; use diesel::{ExpressionMethods, PgConnection, QueryDsl, RunQueryDsl};
use lemmy_apub_lib::traits::ApubObject; use lemmy_apub_lib::traits::{ActorType, ApubObject};
use lemmy_utils::LemmyError; use lemmy_utils::LemmyError;
use serde::Serialize; use serde::Serialize;
use url::Url; use url::Url;
@ -195,3 +195,31 @@ impl ApubObject for Person {
) )
} }
} }
impl ActorType for Person {
fn is_local(&self) -> bool {
self.local
}
fn actor_id(&self) -> Url {
self.actor_id.to_owned().into_inner()
}
fn name(&self) -> String {
self.name.clone()
}
fn public_key(&self) -> Option<String> {
self.public_key.to_owned()
}
fn private_key(&self) -> Option<String> {
self.private_key.to_owned()
}
fn inbox_url(&self) -> Url {
self.inbox_url.clone().into()
}
fn shared_inbox_url(&self) -> Option<Url> {
self.shared_inbox_url.clone().map(|s| s.into_inner())
}
}

View File

@ -40,7 +40,7 @@ services:
volumes: volumes:
- ./lemmy_alpha.hjson:/config/config.hjson - ./lemmy_alpha.hjson:/config/config.hjson
environment: environment:
- LEMMY_TEST_SEND_SYNC=1 - APUB_TESTING_SEND_SYNC
- RUST_BACKTRACE=1 - RUST_BACKTRACE=1
- RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_queries=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug" - RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_queries=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug"
depends_on: depends_on:
@ -69,7 +69,7 @@ services:
volumes: volumes:
- ./lemmy_beta.hjson:/config/config.hjson - ./lemmy_beta.hjson:/config/config.hjson
environment: environment:
- LEMMY_TEST_SEND_SYNC=1 - APUB_TESTING_SEND_SYNC
- RUST_BACKTRACE=1 - RUST_BACKTRACE=1
- RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_queries=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug" - RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_queries=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug"
depends_on: depends_on:
@ -98,7 +98,7 @@ services:
volumes: volumes:
- ./lemmy_gamma.hjson:/config/config.hjson - ./lemmy_gamma.hjson:/config/config.hjson
environment: environment:
- LEMMY_TEST_SEND_SYNC=1 - APUB_TESTING_SEND_SYNC
- RUST_BACKTRACE=1 - RUST_BACKTRACE=1
- RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_queries=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug" - RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_queries=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug"
depends_on: depends_on:
@ -128,7 +128,7 @@ services:
volumes: volumes:
- ./lemmy_delta.hjson:/config/config.hjson - ./lemmy_delta.hjson:/config/config.hjson
environment: environment:
- LEMMY_TEST_SEND_SYNC=1 - APUB_TESTING_SEND_SYNC
- RUST_BACKTRACE=1 - RUST_BACKTRACE=1
- RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_queries=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug" - RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_queries=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug"
depends_on: depends_on:
@ -158,7 +158,7 @@ services:
volumes: volumes:
- ./lemmy_epsilon.hjson:/config/config.hjson - ./lemmy_epsilon.hjson:/config/config.hjson
environment: environment:
- LEMMY_TEST_SEND_SYNC=1 - APUB_TESTING_SEND_SYNC
- RUST_BACKTRACE=1 - RUST_BACKTRACE=1
- RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_queries=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug" - RUST_LOG="warn,lemmy_server=debug,lemmy_api=debug,lemmy_api_common=debug,lemmy_api_crud=debug,lemmy_apub=debug,lemmy_db_queries=debug,lemmy_db_schema=debug,lemmy_db_views=debug,lemmy_db_views_actor=debug,lemmy_db_views_moderator=debug,lemmy_routes=debug,lemmy_utils=debug,lemmy_websocket=debug"
depends_on: depends_on:

View File

@ -10,7 +10,7 @@ use diesel::{
use lemmy_api::match_websocket_operation; use lemmy_api::match_websocket_operation;
use lemmy_api_common::blocking; use lemmy_api_common::blocking;
use lemmy_api_crud::match_websocket_operation_crud; use lemmy_api_crud::match_websocket_operation_crud;
use lemmy_apub::activity_queue::create_activity_queue; use lemmy_apub_lib::activity_queue::create_activity_queue;
use lemmy_db_queries::{get_database_url_from_env, source::secret::Secret_}; use lemmy_db_queries::{get_database_url_from_env, source::secret::Secret_};
use lemmy_db_schema::source::secret::Secret; use lemmy_db_schema::source::secret::Secret;
use lemmy_routes::{feeds, images, nodeinfo, webfinger}; use lemmy_routes::{feeds, images, nodeinfo, webfinger};