mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-23 19:31:33 +00:00
Dont handle activities twice in inbox
This commit is contained in:
parent
eee394cf85
commit
14bf45d099
1 changed files with 5 additions and 9 deletions
|
@ -65,10 +65,12 @@ pub async fn shared_inbox(
|
||||||
let activity_any_base = activity.clone().into_any_base()?;
|
let activity_any_base = activity.clone().into_any_base()?;
|
||||||
let mut res: Option<HttpResponse> = None;
|
let mut res: Option<HttpResponse> = None;
|
||||||
let to_and_cc = get_activity_to_and_cc(&activity)?;
|
let to_and_cc = get_activity_to_and_cc(&activity)?;
|
||||||
// If to_and_cc contains a local community, pass to receive_community_message()
|
|
||||||
// Handle community first, so in case the sender is banned by the community, it will error out.
|
// Handle community first, so in case the sender is banned by the community, it will error out.
|
||||||
// If we handled the user receive first, the activity would be inserted to the database before the
|
// If we handled the user receive first, the activity would be inserted to the database before the
|
||||||
// community could check for bans.
|
// community could check for bans.
|
||||||
|
// Note that an activity can be addressed to a community and to a user (or multiple users) at the
|
||||||
|
// same time. In this case we still only handle it once, to avoid duplicate websocket
|
||||||
|
// notifications.
|
||||||
let community = extract_local_community_from_destinations(&to_and_cc, context.pool()).await?;
|
let community = extract_local_community_from_destinations(&to_and_cc, context.pool()).await?;
|
||||||
if let Some(community) = community {
|
if let Some(community) = community {
|
||||||
let community_activity = CommunityAcceptedActivities::from_any_base(activity_any_base.clone())?
|
let community_activity = CommunityAcceptedActivities::from_any_base(activity_any_base.clone())?
|
||||||
|
@ -83,10 +85,7 @@ pub async fn shared_inbox(
|
||||||
)
|
)
|
||||||
.await?,
|
.await?,
|
||||||
);
|
);
|
||||||
}
|
} else if is_addressed_to_local_user(&to_and_cc, context.pool()).await? {
|
||||||
|
|
||||||
// If to_and_cc contains a local user, pass to receive_user_message()
|
|
||||||
if is_addressed_to_local_user(&to_and_cc, context.pool()).await? {
|
|
||||||
let user_activity = UserAcceptedActivities::from_any_base(activity_any_base.clone())?
|
let user_activity = UserAcceptedActivities::from_any_base(activity_any_base.clone())?
|
||||||
.context(location_info!())?;
|
.context(location_info!())?;
|
||||||
// `to_user` is only used for follow activities (which we dont receive here), so no need to pass
|
// `to_user` is only used for follow activities (which we dont receive here), so no need to pass
|
||||||
|
@ -99,10 +98,7 @@ pub async fn shared_inbox(
|
||||||
request_counter,
|
request_counter,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
} else if is_addressed_to_community_followers(&to_and_cc, context.pool())
|
||||||
|
|
||||||
// If to_and_cc contains followers collection of a community, pass to receive_user_message()
|
|
||||||
if is_addressed_to_community_followers(&to_and_cc, context.pool())
|
|
||||||
.await?
|
.await?
|
||||||
.is_some()
|
.is_some()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue