ActorType,
};
use activitystreams::{
- base::{Extends, ExtendsExt},
+ base::{BaseExt, Extends, ExtendsExt},
object::AsObject,
};
use anyhow::{anyhow, Context, Error};
use lemmy_db::{community::Community, user::User_, DbPool};
use lemmy_utils::{location_info, settings::Settings, LemmyError};
use lemmy_websocket::LemmyContext;
-use log::warn;
+use log::{debug, warn};
use reqwest::Client;
-use serde::{Deserialize, Serialize};
+use serde::{export::fmt::Debug, Deserialize, Serialize};
use std::{collections::BTreeMap, future::Future, pin::Pin};
use url::Url;
context: &LemmyContext,
) -> Result<(), LemmyError>
where
- T: AsObject<Kind> + Extends<Kind>,
+ T: AsObject<Kind> + Extends<Kind> + Debug + BaseExt<Kind>,
Kind: Serialize,
<T as Extends<Kind>>::Error: From<serde_json::Error> + Send + Sync + 'static,
{
if check_is_apub_id_valid(&to).is_ok() {
+ debug!("Sending activity {:?} to {}", &activity.id_unchecked(), &to);
send_activity_internal(
context.activity_queue(),
activity,
sender_shared_inbox: Option<Url>,
) -> Result<(), LemmyError>
where
- T: AsObject<Kind> + Extends<Kind>,
+ T: AsObject<Kind> + Extends<Kind> + Debug + BaseExt<Kind>,
Kind: Serialize,
<T as Extends<Kind>>::Error: From<serde_json::Error> + Send + Sync + 'static,
{
.unique()
.map(|inbox| inbox.to_owned())
.collect();
+ debug!(
+ "Sending activity {:?} to followers of {}",
+ &activity.id_unchecked(),
+ &community.actor_id
+ );
send_activity_internal(
context.activity_queue(),
context: &LemmyContext,
) -> Result<(), LemmyError>
where
- T: AsObject<Kind> + Extends<Kind>,
+ T: AsObject<Kind> + Extends<Kind> + Debug + BaseExt<Kind>,
Kind: Serialize,
<T as Extends<Kind>>::Error: From<serde_json::Error> + Send + Sync + 'static,
{
} else {
let inbox = community.get_shared_inbox_url()?;
check_is_apub_id_valid(&inbox)?;
+ debug!(
+ "Sending activity {:?} to community {}",
+ &activity.id_unchecked(),
+ &community.actor_id
+ );
send_activity_internal(
context.activity_queue(),
activity,
context: &LemmyContext,
) -> Result<(), LemmyError>
where
- T: AsObject<Kind> + Extends<Kind>,
+ T: AsObject<Kind> + Extends<Kind> + Debug + BaseExt<Kind>,
Kind: Serialize,
<T as Extends<Kind>>::Error: From<serde_json::Error> + Send + Sync + 'static,
{
+ dbg!(&mentions, &activity.id_unchecked());
+ debug!(
+ "Sending mentions activity {:?} to {:?}",
+ &activity.id_unchecked(),
+ &mentions
+ );
let mentions = mentions
.iter()
.filter(|inbox| check_is_apub_id_valid(inbox).is_ok())
insert_into_db: bool,
) -> Result<(), LemmyError>
where
- T: AsObject<Kind> + Extends<Kind>,
+ T: AsObject<Kind> + Extends<Kind> + Debug,
Kind: Serialize,
<T as Extends<Kind>>::Error: From<serde_json::Error> + Send + Sync + 'static,
{
) -> Result<HttpResponse, LemmyError> {
let activity = input.into_inner();
- let json = serde_json::to_string_pretty(&activity)?;
- debug!("Shared inbox received activity: {}", json);
-
- // TODO: if we already received an activity with identical ID, then ignore this (same in other inboxes)
-
let sender = &activity
.actor()?
.to_owned()
.single_xsd_any_uri()
.context(location_info!())?;
let community = get_community_id_from_activity(&activity)?;
+ debug!(
+ "Shared inbox received activity {:?} from {}",
+ &activity.id_unchecked(),
+ &sender
+ );
check_is_apub_id_valid(sender)?;
check_is_apub_id_valid(&community)?;