[[package]]
name = "activitypub_federation"
-version = "0.2.3"
+version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dd9ae511df7135c271dca3ef3751f5528891c965e47d8d7a70fed9d2f1e5b6b1"
+checksum = "85eee18b953107c2ce1f9e217b533464b061c4416179aa65c6adb102379fbaff"
dependencies = [
- "activitypub_federation_derive",
"actix-web",
"anyhow",
"async-trait",
"chrono",
"derive_builder 0.11.2",
"dyn-clone",
+ "enum_delegate",
"http",
"http-signature-normalization-actix",
"http-signature-normalization-reqwest",
"url",
]
-[[package]]
-name = "activitypub_federation_derive"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "07520b54fc0f22ad30b90399b2a2689c6e5c113df0642ca3fa2f7ee823e54126"
-dependencies = [
- "proc-macro2 1.0.47",
- "quote 1.0.21",
- "syn 1.0.103",
-]
-
[[package]]
name = "activitystreams-kinds"
version = "0.2.1"
[[package]]
name = "chrono"
-version = "0.4.22"
+version = "0.4.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bfd4d1b31faaa3a89d7934dbded3111da0d2ef28e3ebccdb4f0179f5929d1ef1"
+checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f"
dependencies = [
"iana-time-zone",
"js-sys",
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5320ae4c3782150d900b79807611a59a99fc9a1d61d686faafc24b93fc8d7ca"
+[[package]]
+name = "enum_delegate"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a8ea75f31022cba043afe037940d73684327e915f88f62478e778c3de914cd0a"
+dependencies = [
+ "enum_delegate_lib",
+ "proc-macro2 1.0.47",
+ "quote 1.0.21",
+ "syn 1.0.103",
+]
+
+[[package]]
+name = "enum_delegate_lib"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2e1f6c3800b304a6be0012039e2a45a322a093539c45ab818d9e6895a39c90fe"
+dependencies = [
+ "proc-macro2 1.0.47",
+ "quote 1.0.21",
+ "rand 0.8.5",
+ "syn 1.0.103",
+]
+
[[package]]
name = "event-listener"
version = "2.5.3"
"async-trait",
"chrono",
"diesel",
+ "enum_delegate",
"futures",
"html2md",
"http",
[[package]]
name = "once_cell"
-version = "1.15.0"
+version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e82dad04139b71a90c080c8463fe0dc7902db5192d939bd0950f074d014339e1"
+checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860"
[[package]]
name = "openssl"
lemmy_api_common = { version = "=0.16.5", path = "crates/api_common" }
lemmy_websocket = { version = "=0.16.5", path = "./crates/websocket" }
lemmy_routes = { version = "=0.16.5", path = "./crates/routes" }
-activitypub_federation = "0.2.3"
+activitypub_federation = "0.3.2"
diesel = "2.0.2"
diesel_migrations = "2.0.0"
diesel-async = "0.1.1"
lemmy_db_views_actor = { version = "=0.16.5", path = "../db_views_actor", features = ["full"] }
lemmy_api_common = { version = "=0.16.5", path = "../api_common", features = ["full"] }
lemmy_websocket = { version = "=0.16.5", path = "../websocket" }
-activitypub_federation = "0.2.3"
+activitypub_federation = "0.3.2"
diesel = "2.0.2"
bcrypt = "0.13.0"
chrono = { version = "0.4.22", features = ["serde"], default-features = false }
lemmy_db_views_actor = { version = "=0.16.5", path = "../db_views_actor", features = ["full"] }
lemmy_api_common = { version = "=0.16.5", path = "../api_common", features = ["full"] }
lemmy_websocket = { version = "=0.16.5", path = "../websocket" }
-activitypub_federation = "0.2.3"
+activitypub_federation = "0.3.2"
bcrypt = "0.13.0"
serde_json = { version = "1.0.87", features = ["preserve_order"] }
serde = { version = "1.0.147", features = ["derive"] }
let check = context
.chat_server()
.send(CheckCaptcha {
- uuid: data
- .captcha_uuid
- .to_owned()
- .unwrap_or_else(|| "".to_string()),
- answer: data
- .captcha_answer
- .to_owned()
- .unwrap_or_else(|| "".to_string()),
+ uuid: data.captcha_uuid.to_owned().unwrap_or_default(),
+ answer: data.captcha_answer.to_owned().unwrap_or_default(),
})
.await?;
if !check {
lemmy_db_views_actor = { version = "=0.16.5", path = "../db_views_actor", features = ["full"] }
lemmy_api_common = { version = "=0.16.5", path = "../api_common", features = ["full"] }
lemmy_websocket = { version = "=0.16.5", path = "../websocket" }
-activitypub_federation = "0.2.3"
+activitypub_federation = "0.3.2"
diesel = "2.0.2"
activitystreams-kinds = "0.2.1"
chrono = { version = "0.4.22", features = ["serde"], default-features = false }
html2md = "0.2.13"
once_cell = "1.15.0"
tokio = "1.21.2"
+enum_delegate = "0.2.0"
[dev-dependencies]
serial_test = "0.9.0"
// anyway.
// TODO: for compatibility with other projects, it would be much better to read this from cc or tags
let mentions = scrape_text_for_mentions(&comment.content);
- send_local_notifs(mentions, comment, &*actor, &post, do_send_email, context).await
+ send_local_notifs(mentions, comment, &actor, &post, do_send_email, context).await
}
let community: ApubCommunity = Community::read(context.pool(), community_id).await?.into();
let create_or_update = CreateOrUpdatePost::new(post, actor, &community, kind, context).await?;
- let activity = AnnouncableActivities::CreateOrUpdatePost(Box::new(create_or_update));
+ let activity = AnnouncableActivities::CreateOrUpdatePost(create_or_update);
send_activity_in_community(activity, actor, &community, vec![], context).await?;
Ok(())
}
objects::page::Page,
},
};
-use activitypub_federation::{deser::context::WithContext, traits::activity_handler};
+use activitypub_federation::{data::Data, deser::context::WithContext, traits::ActivityHandler};
use lemmy_utils::error::LemmyError;
use lemmy_websocket::LemmyContext;
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
#[serde(untagged)]
-#[activity_handler(LemmyContext, LemmyError)]
+#[enum_delegate::implement(ActivityHandler)]
pub enum SharedInboxActivities {
PersonInboxActivities(Box<WithContext<PersonInboxActivities>>),
GroupInboxActivities(Box<WithContext<GroupInboxActivities>>),
#[derive(Debug, Deserialize, Serialize)]
#[serde(untagged)]
-#[activity_handler(LemmyContext, LemmyError)]
+#[enum_delegate::implement(ActivityHandler)]
pub enum GroupInboxActivities {
FollowCommunity(FollowCommunity),
UndoFollowCommunity(UndoFollowCommunity),
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(untagged)]
-#[activity_handler(LemmyContext, LemmyError)]
+#[enum_delegate::implement(ActivityHandler)]
pub enum PersonInboxActivities {
AcceptFollowCommunity(AcceptFollowCommunity),
CreateOrUpdatePrivateMessage(CreateOrUpdatePrivateMessage),
/// inbox can fall through to be parsed as GroupInboxActivities::AnnouncableActivities.
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(untagged)]
-#[activity_handler(LemmyContext, LemmyError)]
+#[enum_delegate::implement(ActivityHandler)]
pub enum PersonInboxActivitiesWithAnnouncable {
- PersonInboxActivities(PersonInboxActivities),
- AnnouncableActivities(AnnouncableActivities),
+ PersonInboxActivities(Box<PersonInboxActivities>),
+ AnnouncableActivities(Box<AnnouncableActivities>),
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(untagged)]
-#[activity_handler(LemmyContext, LemmyError)]
+#[enum_delegate::implement(ActivityHandler)]
pub enum AnnouncableActivities {
CreateOrUpdateComment(CreateOrUpdateComment),
- CreateOrUpdatePost(Box<CreateOrUpdatePost>),
+ CreateOrUpdatePost(CreateOrUpdatePost),
Vote(Vote),
UndoVote(UndoVote),
Delete(Delete),
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(untagged)]
-#[activity_handler(LemmyContext, LemmyError)]
+#[enum_delegate::implement(ActivityHandler)]
#[allow(clippy::enum_variant_names)]
pub enum SiteInboxActivities {
BlockUser(BlockUser),
let create =
CreateOrUpdatePost::new(post, &person, &data.0, CreateOrUpdateType::Create, &data.1)
.await?;
- let announcable = AnnouncableActivities::CreateOrUpdatePost(Box::new(create));
+ let announcable = AnnouncableActivities::CreateOrUpdatePost(create);
let announce = AnnounceActivity::new(announcable.try_into()?, &data.0, &data.1)?;
ordered_items.push(announce);
}
}
if !comment.deleted && !comment.removed {
- Ok(create_apub_response(&comment.into_apub(&**context).await?))
+ Ok(create_apub_response(&comment.into_apub(&context).await?))
} else {
Ok(create_apub_tombstone_response(comment.ap_id.clone()))
}
.into();
if !community.deleted && !community.removed {
- let apub = community.into_apub(&**context).await?;
+ let apub = community.into_apub(&context).await?;
Ok(create_apub_response(&apub))
} else {
pub mod routes;
pub mod site;
-#[tracing::instrument(skip_all)]
pub async fn shared_inbox(
request: HttpRequest,
payload: String,
for<'de2> <ActorT as ApubObject>::ApubType: serde::Deserialize<'de2>,
{
let activity_value: Value = serde_json::from_str(&payload)?;
- debug!("Received activity {:#}", payload.as_str());
+ debug!("Parsing activity {}", payload);
let activity: Activity = serde_json::from_value(activity_value.clone())?;
// Log the activity, so we avoid receiving and parsing it twice.
let insert = insert_activity(activity.id(), activity_value, false, true, context.pool()).await?;
strum = "0.24.1"
strum_macros = "0.24.3"
serde_json = { version = "1.0.87", features = ["preserve_order"], optional = true }
-activitypub_federation = { version = "0.2.3", optional = true }
+activitypub_federation = {version = "0.3.2", optional = true }
lemmy_utils = { version = "=0.16.5", path = "../utils", optional = true }
bcrypt = { version = "0.13.0", optional = true }
diesel = { version = "2.0.2", features = ["postgres","chrono", "serde_json"], optional = true }
});
pub fn naive_from_unix(time: i64) -> NaiveDateTime {
- NaiveDateTime::from_timestamp(time, 0)
+ NaiveDateTime::from_timestamp_opt(time, 0).expect("convert datetime")
}
pub fn convert_datetime(datetime: NaiveDateTime) -> DateTime<FixedOffset> {
- DateTime::<FixedOffset>::from_utc(datetime, FixedOffset::east(0))
+ DateTime::<FixedOffset>::from_utc(
+ datetime,
+ FixedOffset::east_opt(0).expect("create fixed offset"),
+ )
}
pub fn remove_slurs(test: &str, slur_regex: &Option<Regex>) -> String {
handle_error(span, response.status(), error.as_response_error());
} else {
let code: i32 = response.response().status().as_u16().into();
- span.record("http.status_code", &code);
- span.record("otel.status_code", &"OK");
+ span.record("http.status_code", code);
+ span.record("otel.status_code", "OK");
}
}
Err(error) => {
fn handle_error(span: Span, status_code: StatusCode, response_error: &dyn ResponseError) {
let code: i32 = status_code.as_u16().into();
- span.record("http.status_code", &code);
+ span.record("http.status_code", code);
if status_code.is_client_error() {
- span.record("otel.status_code", &"OK");
+ span.record("otel.status_code", "OK");
} else {
- span.record("otel.status_code", &"ERROR");
+ span.record("otel.status_code", "ERROR");
}
// pre-formatting errors is a workaround for https://github.com/tokio-rs/tracing/issues/1565