mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-24 17:00:36 +00:00
Remove to field from follow activities
This commit is contained in:
parent
20cddf5e81
commit
3249060f67
9 changed files with 21 additions and 38 deletions
|
@ -1,13 +1,7 @@
|
||||||
{
|
{
|
||||||
"actor": "http://enterprise.lemmy.ml/c/main",
|
"actor": "http://enterprise.lemmy.ml/c/main",
|
||||||
"to": [
|
|
||||||
"http://ds9.lemmy.ml/u/lemmy_alpha"
|
|
||||||
],
|
|
||||||
"object": {
|
"object": {
|
||||||
"actor": "http://ds9.lemmy.ml/u/lemmy_alpha",
|
"actor": "http://ds9.lemmy.ml/u/lemmy_alpha",
|
||||||
"to": [
|
|
||||||
"http://enterprise.lemmy.ml/c/main"
|
|
||||||
],
|
|
||||||
"object": "http://enterprise.lemmy.ml/c/main",
|
"object": "http://enterprise.lemmy.ml/c/main",
|
||||||
"type": "Follow",
|
"type": "Follow",
|
||||||
"id": "http://ds9.lemmy.ml/activities/follow/6abcd50b-b8ca-4952-86b0-a6dd8cc12866"
|
"id": "http://ds9.lemmy.ml/activities/follow/6abcd50b-b8ca-4952-86b0-a6dd8cc12866"
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
{
|
{
|
||||||
"actor": "http://ds9.lemmy.ml/u/lemmy_alpha",
|
"actor": "http://ds9.lemmy.ml/u/lemmy_alpha",
|
||||||
"to": [
|
|
||||||
"http://enterprise.lemmy.ml/c/main"
|
|
||||||
],
|
|
||||||
"object": "http://enterprise.lemmy.ml/c/main",
|
"object": "http://enterprise.lemmy.ml/c/main",
|
||||||
"type": "Follow",
|
"type": "Follow",
|
||||||
"id": "http://ds9.lemmy.ml/activities/follow/6abcd50b-b8ca-4952-86b0-a6dd8cc12866"
|
"id": "http://ds9.lemmy.ml/activities/follow/6abcd50b-b8ca-4952-86b0-a6dd8cc12866"
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
{
|
{
|
||||||
"actor": "http://ds9.lemmy.ml/u/lemmy_alpha",
|
"actor": "http://ds9.lemmy.ml/u/lemmy_alpha",
|
||||||
"to": [
|
|
||||||
"http://enterprise.lemmy.ml/c/main"
|
|
||||||
],
|
|
||||||
"object": {
|
"object": {
|
||||||
"actor": "http://ds9.lemmy.ml/u/lemmy_alpha",
|
"actor": "http://ds9.lemmy.ml/u/lemmy_alpha",
|
||||||
"to": [
|
|
||||||
"http://enterprise.lemmy.ml/c/main"
|
|
||||||
],
|
|
||||||
"object": "http://enterprise.lemmy.ml/c/main",
|
"object": "http://enterprise.lemmy.ml/c/main",
|
||||||
"type": "Follow",
|
"type": "Follow",
|
||||||
"id": "http://ds9.lemmy.ml/activities/follow/dc2f1bc5-f3a0-4daa-a46b-428cbfbd023c"
|
"id": "http://ds9.lemmy.ml/activities/follow/dc2f1bc5-f3a0-4daa-a46b-428cbfbd023c"
|
||||||
|
|
|
@ -28,7 +28,6 @@ impl AcceptFollowCommunity {
|
||||||
.await?;
|
.await?;
|
||||||
let accept = AcceptFollowCommunity {
|
let accept = AcceptFollowCommunity {
|
||||||
actor: ObjectId::new(community.actor_id()),
|
actor: ObjectId::new(community.actor_id()),
|
||||||
to: [ObjectId::new(person.actor_id())],
|
|
||||||
object: follow,
|
object: follow,
|
||||||
kind: AcceptType::Accept,
|
kind: AcceptType::Accept,
|
||||||
id: generate_activity_id(
|
id: generate_activity_id(
|
||||||
|
@ -52,8 +51,7 @@ impl ActivityHandler for AcceptFollowCommunity {
|
||||||
request_counter: &mut i32,
|
request_counter: &mut i32,
|
||||||
) -> Result<(), LemmyError> {
|
) -> Result<(), LemmyError> {
|
||||||
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
|
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
|
||||||
verify_urls_match(self.to[0].inner(), self.object.actor.inner())?;
|
verify_urls_match(self.actor.inner(), self.object.object.inner())?;
|
||||||
verify_urls_match(self.actor.inner(), self.object.to[0].inner())?;
|
|
||||||
self.object.verify(context, request_counter).await?;
|
self.object.verify(context, request_counter).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -63,11 +61,15 @@ impl ActivityHandler for AcceptFollowCommunity {
|
||||||
context: &Data<LemmyContext>,
|
context: &Data<LemmyContext>,
|
||||||
request_counter: &mut i32,
|
request_counter: &mut i32,
|
||||||
) -> Result<(), LemmyError> {
|
) -> Result<(), LemmyError> {
|
||||||
let actor = self.actor.dereference(context, request_counter).await?;
|
let person = self.actor.dereference(context, request_counter).await?;
|
||||||
let to = self.to[0].dereference(context, request_counter).await?;
|
let community = self
|
||||||
|
.object
|
||||||
|
.actor
|
||||||
|
.dereference(context, request_counter)
|
||||||
|
.await?;
|
||||||
// This will throw an error if no follow was requested
|
// This will throw an error if no follow was requested
|
||||||
blocking(context.pool(), move |conn| {
|
blocking(context.pool(), move |conn| {
|
||||||
CommunityFollower::follow_accepted(conn, actor.id, to.id)
|
CommunityFollower::follow_accepted(conn, person.id, community.id)
|
||||||
})
|
})
|
||||||
.await??;
|
.await??;
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ use lemmy_apub_lib::{
|
||||||
data::Data,
|
data::Data,
|
||||||
object_id::ObjectId,
|
object_id::ObjectId,
|
||||||
traits::{ActivityHandler, ActorType},
|
traits::{ActivityHandler, ActorType},
|
||||||
verify::verify_urls_match,
|
|
||||||
};
|
};
|
||||||
use lemmy_db_schema::{
|
use lemmy_db_schema::{
|
||||||
source::community::{CommunityFollower, CommunityFollowerForm},
|
source::community::{CommunityFollower, CommunityFollowerForm},
|
||||||
|
@ -32,7 +31,6 @@ impl FollowCommunity {
|
||||||
) -> Result<FollowCommunity, LemmyError> {
|
) -> Result<FollowCommunity, LemmyError> {
|
||||||
Ok(FollowCommunity {
|
Ok(FollowCommunity {
|
||||||
actor: ObjectId::new(actor.actor_id()),
|
actor: ObjectId::new(actor.actor_id()),
|
||||||
to: [ObjectId::new(community.actor_id())],
|
|
||||||
object: ObjectId::new(community.actor_id()),
|
object: ObjectId::new(community.actor_id()),
|
||||||
kind: FollowType::Follow,
|
kind: FollowType::Follow,
|
||||||
id: generate_activity_id(
|
id: generate_activity_id(
|
||||||
|
@ -72,9 +70,8 @@ impl ActivityHandler for FollowCommunity {
|
||||||
request_counter: &mut i32,
|
request_counter: &mut i32,
|
||||||
) -> Result<(), LemmyError> {
|
) -> Result<(), LemmyError> {
|
||||||
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
|
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
|
||||||
verify_urls_match(self.to[0].inner(), self.object.inner())?;
|
|
||||||
verify_person(&self.actor, context, request_counter).await?;
|
verify_person(&self.actor, context, request_counter).await?;
|
||||||
let community = self.to[0].dereference(context, request_counter).await?;
|
let community = self.object.dereference(context, request_counter).await?;
|
||||||
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
|
verify_person_in_community(&self.actor, &community, context, request_counter).await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -84,11 +81,11 @@ impl ActivityHandler for FollowCommunity {
|
||||||
context: &Data<LemmyContext>,
|
context: &Data<LemmyContext>,
|
||||||
request_counter: &mut i32,
|
request_counter: &mut i32,
|
||||||
) -> Result<(), LemmyError> {
|
) -> Result<(), LemmyError> {
|
||||||
let actor = self.actor.dereference(context, request_counter).await?;
|
let person = self.actor.dereference(context, request_counter).await?;
|
||||||
let community = self.to[0].dereference(context, request_counter).await?;
|
let community = self.object.dereference(context, request_counter).await?;
|
||||||
let community_follower_form = CommunityFollowerForm {
|
let community_follower_form = CommunityFollowerForm {
|
||||||
community_id: community.id,
|
community_id: community.id,
|
||||||
person_id: actor.id,
|
person_id: person.id,
|
||||||
pending: false,
|
pending: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@ impl UndoFollowCommunity {
|
||||||
let object = FollowCommunity::new(actor, community, context)?;
|
let object = FollowCommunity::new(actor, community, context)?;
|
||||||
let undo = UndoFollowCommunity {
|
let undo = UndoFollowCommunity {
|
||||||
actor: ObjectId::new(actor.actor_id()),
|
actor: ObjectId::new(actor.actor_id()),
|
||||||
to: [ObjectId::new(community.actor_id())],
|
|
||||||
object,
|
object,
|
||||||
kind: UndoType::Undo,
|
kind: UndoType::Undo,
|
||||||
id: generate_activity_id(
|
id: generate_activity_id(
|
||||||
|
@ -50,7 +49,6 @@ impl ActivityHandler for UndoFollowCommunity {
|
||||||
request_counter: &mut i32,
|
request_counter: &mut i32,
|
||||||
) -> Result<(), LemmyError> {
|
) -> Result<(), LemmyError> {
|
||||||
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
|
verify_activity(&self.id, self.actor.inner(), &context.settings())?;
|
||||||
verify_urls_match(self.to[0].inner(), self.object.object.inner())?;
|
|
||||||
verify_urls_match(self.actor.inner(), self.object.actor.inner())?;
|
verify_urls_match(self.actor.inner(), self.object.actor.inner())?;
|
||||||
verify_person(&self.actor, context, request_counter).await?;
|
verify_person(&self.actor, context, request_counter).await?;
|
||||||
self.object.verify(context, request_counter).await?;
|
self.object.verify(context, request_counter).await?;
|
||||||
|
@ -62,12 +60,16 @@ impl ActivityHandler for UndoFollowCommunity {
|
||||||
context: &Data<LemmyContext>,
|
context: &Data<LemmyContext>,
|
||||||
request_counter: &mut i32,
|
request_counter: &mut i32,
|
||||||
) -> Result<(), LemmyError> {
|
) -> Result<(), LemmyError> {
|
||||||
let actor = self.actor.dereference(context, request_counter).await?;
|
let person = self.actor.dereference(context, request_counter).await?;
|
||||||
let community = self.to[0].dereference(context, request_counter).await?;
|
let community = self
|
||||||
|
.object
|
||||||
|
.object
|
||||||
|
.dereference(context, request_counter)
|
||||||
|
.await?;
|
||||||
|
|
||||||
let community_follower_form = CommunityFollowerForm {
|
let community_follower_form = CommunityFollowerForm {
|
||||||
community_id: community.id,
|
community_id: community.id,
|
||||||
person_id: actor.id,
|
person_id: person.id,
|
||||||
pending: false,
|
pending: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
objects::{community::ApubCommunity, person::ApubPerson},
|
objects::community::ApubCommunity,
|
||||||
protocol::activities::following::follow::FollowCommunity,
|
protocol::activities::following::follow::FollowCommunity,
|
||||||
};
|
};
|
||||||
use activitystreams::{activity::kind::AcceptType, unparsed::Unparsed};
|
use activitystreams::{activity::kind::AcceptType, unparsed::Unparsed};
|
||||||
|
@ -11,7 +11,6 @@ use url::Url;
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct AcceptFollowCommunity {
|
pub struct AcceptFollowCommunity {
|
||||||
pub(crate) actor: ObjectId<ApubCommunity>,
|
pub(crate) actor: ObjectId<ApubCommunity>,
|
||||||
pub(crate) to: [ObjectId<ApubPerson>; 1],
|
|
||||||
pub(crate) object: FollowCommunity,
|
pub(crate) object: FollowCommunity,
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
pub(crate) kind: AcceptType,
|
pub(crate) kind: AcceptType,
|
||||||
|
|
|
@ -8,7 +8,6 @@ use url::Url;
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct FollowCommunity {
|
pub struct FollowCommunity {
|
||||||
pub(crate) actor: ObjectId<ApubPerson>,
|
pub(crate) actor: ObjectId<ApubPerson>,
|
||||||
pub(crate) to: [ObjectId<ApubCommunity>; 1],
|
|
||||||
pub(crate) object: ObjectId<ApubCommunity>,
|
pub(crate) object: ObjectId<ApubCommunity>,
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
pub(crate) kind: FollowType,
|
pub(crate) kind: FollowType,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
objects::{community::ApubCommunity, person::ApubPerson},
|
objects::person::ApubPerson,
|
||||||
protocol::activities::following::follow::FollowCommunity,
|
protocol::activities::following::follow::FollowCommunity,
|
||||||
};
|
};
|
||||||
use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
|
use activitystreams::{activity::kind::UndoType, unparsed::Unparsed};
|
||||||
|
@ -11,7 +11,6 @@ use url::Url;
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct UndoFollowCommunity {
|
pub struct UndoFollowCommunity {
|
||||||
pub(crate) actor: ObjectId<ApubPerson>,
|
pub(crate) actor: ObjectId<ApubPerson>,
|
||||||
pub(crate) to: [ObjectId<ApubCommunity>; 1],
|
|
||||||
pub(crate) object: FollowCommunity,
|
pub(crate) object: FollowCommunity,
|
||||||
#[serde(rename = "type")]
|
#[serde(rename = "type")]
|
||||||
pub(crate) kind: UndoType,
|
pub(crate) kind: UndoType,
|
||||||
|
|
Loading…
Reference in a new issue