mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-30 00:01:25 +00:00
add cc field for all activities which i forgot before
This commit is contained in:
parent
27c12ce411
commit
074febb960
19 changed files with 43 additions and 39 deletions
|
@ -16,6 +16,7 @@ pub struct CreateComment {
|
||||||
actor: Url,
|
actor: Url,
|
||||||
to: PublicUrl,
|
to: PublicUrl,
|
||||||
object: NoteExt,
|
object: NoteExt,
|
||||||
|
cc: Vec<Url>,
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: CreateType,
|
kind: CreateType,
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ pub struct DeleteComment {
|
||||||
actor: Url,
|
actor: Url,
|
||||||
to: PublicUrl,
|
to: PublicUrl,
|
||||||
object: Url,
|
object: Url,
|
||||||
cc: Vec<Url>,
|
cc: [Url; 1],
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: DeleteType,
|
kind: DeleteType,
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ pub struct DislikeComment {
|
||||||
actor: Url,
|
actor: Url,
|
||||||
to: PublicUrl,
|
to: PublicUrl,
|
||||||
object: Url,
|
object: Url,
|
||||||
cc: Vec<Url>,
|
cc: [Url; 1],
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: DislikeType,
|
kind: DislikeType,
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ pub struct LikeComment {
|
||||||
actor: Url,
|
actor: Url,
|
||||||
to: PublicUrl,
|
to: PublicUrl,
|
||||||
object: Url,
|
object: Url,
|
||||||
cc: Vec<Url>,
|
cc: [Url; 1],
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: LikeType,
|
kind: LikeType,
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub struct RemoveComment {
|
||||||
actor: Url,
|
actor: Url,
|
||||||
to: PublicUrl,
|
to: PublicUrl,
|
||||||
object: Url,
|
object: Url,
|
||||||
cc: Vec<Url>,
|
cc: [Url; 1],
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: RemoveType,
|
kind: RemoveType,
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ impl VerifyActivity for Activity<RemoveComment> {
|
||||||
async fn verify(&self, context: &LemmyContext) -> Result<(), LemmyError> {
|
async fn verify(&self, context: &LemmyContext) -> Result<(), LemmyError> {
|
||||||
verify_domains_match(&self.inner.actor, self.id_unchecked())?;
|
verify_domains_match(&self.inner.actor, self.id_unchecked())?;
|
||||||
check_is_apub_id_valid(&self.inner.actor, false)?;
|
check_is_apub_id_valid(&self.inner.actor, false)?;
|
||||||
verify_mod_action(self.inner.actor.clone(), self.inner.cc.clone(), context).await
|
verify_mod_action(self.inner.actor.clone(), self.inner.cc[0].clone(), context).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ pub struct UpdateComment {
|
||||||
actor: Url,
|
actor: Url,
|
||||||
to: PublicUrl,
|
to: PublicUrl,
|
||||||
object: NoteExt,
|
object: NoteExt,
|
||||||
|
cc: Vec<Url>,
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: UpdateType,
|
kind: UpdateType,
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ pub struct DeleteCommunity {
|
||||||
actor: Url,
|
actor: Url,
|
||||||
to: PublicUrl,
|
to: PublicUrl,
|
||||||
pub(in crate::activities_new::community) object: Url,
|
pub(in crate::activities_new::community) object: Url,
|
||||||
cc: Url,
|
cc: [Url; 1],
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: DeleteType,
|
kind: DeleteType,
|
||||||
}
|
}
|
||||||
|
@ -41,14 +41,14 @@ impl VerifyActivity for Activity<DeleteCommunity> {
|
||||||
.await?;
|
.await?;
|
||||||
// remote mod action on local community
|
// remote mod action on local community
|
||||||
if let Ok(c) = community {
|
if let Ok(c) = community {
|
||||||
verify_domains_match(&self.inner.object, &self.inner.cc)?;
|
verify_domains_match(&self.inner.object, &self.inner.cc[0])?;
|
||||||
check_is_apub_id_valid(&self.inner.actor, false)?;
|
check_is_apub_id_valid(&self.inner.actor, false)?;
|
||||||
verify_is_community_mod(self.inner.actor.clone(), c.actor_id(), context).await
|
verify_is_community_mod(self.inner.actor.clone(), c.actor_id(), context).await
|
||||||
}
|
}
|
||||||
// community action sent to followers
|
// community action sent to followers
|
||||||
else {
|
else {
|
||||||
verify_domains_match(&self.inner.actor, &self.inner.object)?;
|
verify_domains_match(&self.inner.actor, &self.inner.object)?;
|
||||||
verify_domains_match(&self.inner.actor, &self.inner.cc)
|
verify_domains_match(&self.inner.actor, &self.inner.cc[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub struct RemoveCommunity {
|
||||||
actor: Url,
|
actor: Url,
|
||||||
to: PublicUrl,
|
to: PublicUrl,
|
||||||
pub(in crate::activities_new::community) object: Url,
|
pub(in crate::activities_new::community) object: Url,
|
||||||
cc: Url,
|
cc: [Url; 1],
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: RemoveType,
|
kind: RemoveType,
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ impl VerifyActivity for Activity<RemoveCommunity> {
|
||||||
async fn verify(&self, _context: &LemmyContext) -> Result<(), LemmyError> {
|
async fn verify(&self, _context: &LemmyContext) -> Result<(), LemmyError> {
|
||||||
check_is_apub_id_valid(&self.inner.actor, false)?;
|
check_is_apub_id_valid(&self.inner.actor, false)?;
|
||||||
verify_domains_match(&self.inner.actor, &self.inner.object)?;
|
verify_domains_match(&self.inner.actor, &self.inner.object)?;
|
||||||
verify_domains_match(&self.inner.actor, &self.inner.cc)
|
verify_domains_match(&self.inner.actor, &self.inner.cc[0])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ pub struct UndoDeleteCommunity {
|
||||||
actor: Url,
|
actor: Url,
|
||||||
to: PublicUrl,
|
to: PublicUrl,
|
||||||
object: Activity<DeleteCommunity>,
|
object: Activity<DeleteCommunity>,
|
||||||
cc: Url,
|
cc: [Url; 1],
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: DeleteType,
|
kind: DeleteType,
|
||||||
}
|
}
|
||||||
|
@ -45,14 +45,14 @@ impl VerifyActivity for Activity<UndoDeleteCommunity> {
|
||||||
.await?;
|
.await?;
|
||||||
// remote mod action on local community
|
// remote mod action on local community
|
||||||
if let Ok(c) = community {
|
if let Ok(c) = community {
|
||||||
verify_domains_match(&self.inner.object.inner.object, &self.inner.cc)?;
|
verify_domains_match(&self.inner.object.inner.object, &self.inner.cc[0])?;
|
||||||
check_is_apub_id_valid(&self.inner.actor, false)?;
|
check_is_apub_id_valid(&self.inner.actor, false)?;
|
||||||
verify_is_community_mod(self.inner.actor.clone(), c.actor_id(), context).await?;
|
verify_is_community_mod(self.inner.actor.clone(), c.actor_id(), context).await?;
|
||||||
}
|
}
|
||||||
// community action sent to followers
|
// community action sent to followers
|
||||||
else {
|
else {
|
||||||
verify_domains_match(&self.inner.actor, &self.inner.object.inner.object)?;
|
verify_domains_match(&self.inner.actor, &self.inner.object.inner.object)?;
|
||||||
verify_domains_match(&self.inner.actor, &self.inner.cc)?;
|
verify_domains_match(&self.inner.actor, &self.inner.cc[0])?;
|
||||||
}
|
}
|
||||||
self.inner.object.verify(context).await
|
self.inner.object.verify(context).await
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub struct UndoRemoveCommunity {
|
||||||
actor: Url,
|
actor: Url,
|
||||||
to: PublicUrl,
|
to: PublicUrl,
|
||||||
object: Activity<RemoveCommunity>,
|
object: Activity<RemoveCommunity>,
|
||||||
cc: Url,
|
cc: [Url; 1],
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: RemoveType,
|
kind: RemoveType,
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ impl VerifyActivity for Activity<UndoRemoveCommunity> {
|
||||||
async fn verify(&self, context: &LemmyContext) -> Result<(), LemmyError> {
|
async fn verify(&self, context: &LemmyContext) -> Result<(), LemmyError> {
|
||||||
check_is_apub_id_valid(&self.inner.actor, false)?;
|
check_is_apub_id_valid(&self.inner.actor, false)?;
|
||||||
verify_domains_match(&self.inner.actor, &self.inner.object.inner.object)?;
|
verify_domains_match(&self.inner.actor, &self.inner.object.inner.object)?;
|
||||||
verify_domains_match(&self.inner.actor, &self.inner.cc)?;
|
verify_domains_match(&self.inner.actor, &self.inner.cc[0])?;
|
||||||
self.inner.object.verify(context).await
|
self.inner.object.verify(context).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ pub struct UpdateCommunity {
|
||||||
actor: Url,
|
actor: Url,
|
||||||
to: PublicUrl,
|
to: PublicUrl,
|
||||||
object: GroupExt,
|
object: GroupExt,
|
||||||
cc: Url,
|
cc: [Url; 1],
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: UpdateType,
|
kind: UpdateType,
|
||||||
}
|
}
|
||||||
|
@ -28,9 +28,9 @@ pub struct UpdateCommunity {
|
||||||
#[async_trait::async_trait(?Send)]
|
#[async_trait::async_trait(?Send)]
|
||||||
impl VerifyActivity for Activity<UpdateCommunity> {
|
impl VerifyActivity for Activity<UpdateCommunity> {
|
||||||
async fn verify(&self, context: &LemmyContext) -> Result<(), LemmyError> {
|
async fn verify(&self, context: &LemmyContext) -> Result<(), LemmyError> {
|
||||||
self.inner.object.id(self.inner.cc.as_str())?;
|
self.inner.object.id(self.inner.cc[0].as_str())?;
|
||||||
check_is_apub_id_valid(&self.inner.actor, false)?;
|
check_is_apub_id_valid(&self.inner.actor, false)?;
|
||||||
verify_is_community_mod(self.inner.actor.clone(), self.inner.cc.clone(), context).await
|
verify_is_community_mod(self.inner.actor.clone(), self.inner.cc[0].clone(), context).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ impl ReceiveActivity for Activity<UpdateCommunity> {
|
||||||
context: &LemmyContext,
|
context: &LemmyContext,
|
||||||
request_counter: &mut i32,
|
request_counter: &mut i32,
|
||||||
) -> Result<(), LemmyError> {
|
) -> Result<(), LemmyError> {
|
||||||
let cc = self.inner.cc.clone().into();
|
let cc = self.inner.cc[0].clone().into();
|
||||||
let community = blocking(context.pool(), move |conn| {
|
let community = blocking(context.pool(), move |conn| {
|
||||||
Community::read_from_apub_id(conn, &cc)
|
Community::read_from_apub_id(conn, &cc)
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use anyhow::{anyhow, Context};
|
use anyhow::anyhow;
|
||||||
use lemmy_api_common::blocking;
|
use lemmy_api_common::blocking;
|
||||||
use lemmy_db_queries::ApubObject;
|
use lemmy_db_queries::ApubObject;
|
||||||
use lemmy_db_schema::source::{community::Community, person::Person};
|
use lemmy_db_schema::source::{community::Community, person::Person};
|
||||||
use lemmy_db_views_actor::community_view::CommunityView;
|
use lemmy_db_views_actor::community_view::CommunityView;
|
||||||
use lemmy_utils::{location_info, LemmyError};
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
@ -15,20 +15,13 @@ pub mod private_message;
|
||||||
|
|
||||||
async fn verify_mod_action(
|
async fn verify_mod_action(
|
||||||
actor_id: Url,
|
actor_id: Url,
|
||||||
activity_cc: Vec<Url>,
|
activity_cc: Url,
|
||||||
context: &LemmyContext,
|
context: &LemmyContext,
|
||||||
) -> Result<(), LemmyError> {
|
) -> Result<(), LemmyError> {
|
||||||
let mut cc = activity_cc.into_iter();
|
let community = blocking(context.pool(), move |conn| {
|
||||||
let community: Community = loop {
|
Community::read_from_apub_id(conn, &activity_cc.into())
|
||||||
let current = cc.next().context(location_info!())?;
|
})
|
||||||
let community = blocking(context.pool(), move |conn| {
|
.await??;
|
||||||
Community::read_from_apub_id(conn, ¤t.into())
|
|
||||||
})
|
|
||||||
.await?;
|
|
||||||
if let Ok(c) = community {
|
|
||||||
break c;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
if community.local {
|
if community.local {
|
||||||
let actor = blocking(&context.pool(), move |conn| {
|
let actor = blocking(&context.pool(), move |conn| {
|
||||||
|
|
|
@ -19,6 +19,7 @@ pub struct CreatePost {
|
||||||
actor: Url,
|
actor: Url,
|
||||||
to: PublicUrl,
|
to: PublicUrl,
|
||||||
object: PageExt,
|
object: PageExt,
|
||||||
|
cc: Vec<Url>,
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: CreateType,
|
kind: CreateType,
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ pub struct DeletePost {
|
||||||
actor: Url,
|
actor: Url,
|
||||||
to: PublicUrl,
|
to: PublicUrl,
|
||||||
object: Url,
|
object: Url,
|
||||||
|
cc: [Url; 1],
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: DeleteType,
|
kind: DeleteType,
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ pub struct DislikePost {
|
||||||
actor: Url,
|
actor: Url,
|
||||||
to: PublicUrl,
|
to: PublicUrl,
|
||||||
object: Url,
|
object: Url,
|
||||||
|
cc: [Url; 1],
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: DislikeType,
|
kind: DislikeType,
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ pub struct LikePost {
|
||||||
actor: Url,
|
actor: Url,
|
||||||
to: PublicUrl,
|
to: PublicUrl,
|
||||||
object: Url,
|
object: Url,
|
||||||
|
cc: [Url; 1],
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: LikeType,
|
kind: LikeType,
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ pub struct RemovePost {
|
||||||
actor: Url,
|
actor: Url,
|
||||||
to: PublicUrl,
|
to: PublicUrl,
|
||||||
object: Url,
|
object: Url,
|
||||||
cc: Vec<Url>,
|
cc: [Url; 1],
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: RemoveType,
|
kind: RemoveType,
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ impl VerifyActivity for Activity<RemovePost> {
|
||||||
async fn verify(&self, context: &LemmyContext) -> Result<(), LemmyError> {
|
async fn verify(&self, context: &LemmyContext) -> Result<(), LemmyError> {
|
||||||
verify_domains_match(&self.inner.actor, self.id_unchecked())?;
|
verify_domains_match(&self.inner.actor, self.id_unchecked())?;
|
||||||
check_is_apub_id_valid(&self.inner.actor, false)?;
|
check_is_apub_id_valid(&self.inner.actor, false)?;
|
||||||
verify_mod_action(self.inner.actor.clone(), self.inner.cc.clone(), context).await
|
verify_mod_action(self.inner.actor.clone(), self.inner.cc[0].clone(), context).await
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@ pub struct UpdatePost {
|
||||||
actor: Url,
|
actor: Url,
|
||||||
to: PublicUrl,
|
to: PublicUrl,
|
||||||
object: PageExt,
|
object: PageExt,
|
||||||
|
cc: Vec<Url>,
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
kind: UpdateType,
|
kind: UpdateType,
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,13 @@ use crate::activities_new::{
|
||||||
remove::RemoveComment,
|
remove::RemoveComment,
|
||||||
update::UpdateComment,
|
update::UpdateComment,
|
||||||
},
|
},
|
||||||
community::{delete::DeleteCommunity, update::UpdateCommunity},
|
community::{
|
||||||
|
delete::DeleteCommunity,
|
||||||
|
remove::RemoveCommunity,
|
||||||
|
undo_delete::UndoDeleteCommunity,
|
||||||
|
undo_remove::UndoRemoveCommunity,
|
||||||
|
update::UpdateCommunity,
|
||||||
|
},
|
||||||
follow::AcceptFollowCommunity,
|
follow::AcceptFollowCommunity,
|
||||||
post::{
|
post::{
|
||||||
create::CreatePost,
|
create::CreatePost,
|
||||||
|
@ -29,9 +35,6 @@ use lemmy_apub_lib::{ReceiveActivity, VerifyActivity};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::LemmyError;
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use crate::activities_new::community::remove::RemoveCommunity;
|
|
||||||
use crate::activities_new::community::undo_remove::UndoRemoveCommunity;
|
|
||||||
use crate::activities_new::community::undo_delete::UndoDeleteCommunity;
|
|
||||||
|
|
||||||
// TODO: would be nice if we could move this to lemmy_apub_lib crate. doing that gives error:
|
// TODO: would be nice if we could move this to lemmy_apub_lib crate. doing that gives error:
|
||||||
// "only traits defined in the current crate can be implemented for arbitrary types"
|
// "only traits defined in the current crate can be implemented for arbitrary types"
|
||||||
|
@ -57,6 +60,7 @@ impl<Kind> Activity<Kind> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: this is probably wrong, it contains all activities
|
||||||
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
|
||||||
pub enum PersonAcceptedActivitiesNew {
|
pub enum PersonAcceptedActivitiesNew {
|
||||||
AcceptFollowCommunity(AcceptFollowCommunity),
|
AcceptFollowCommunity(AcceptFollowCommunity),
|
||||||
|
|
Loading…
Reference in a new issue