mirror of https://github.com/LemmyNet/lemmy.git
Trying to add expires to blockcommunity apub.
parent
3131679054
commit
69a34eeb56
|
@ -259,6 +259,7 @@ impl Perform for BanFromCommunity {
|
||||||
&community,
|
&community,
|
||||||
&banned_person,
|
&banned_person,
|
||||||
&local_user_view.person.clone().into(),
|
&local_user_view.person.clone().into(),
|
||||||
|
expires,
|
||||||
context,
|
context,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
|
@ -9,5 +9,6 @@
|
||||||
],
|
],
|
||||||
"target": "http://enterprise.lemmy.ml/c/main",
|
"target": "http://enterprise.lemmy.ml/c/main",
|
||||||
"type": "Block",
|
"type": "Block",
|
||||||
|
"expires": "2021-11-01T12:23:50.151874+00:00",
|
||||||
"id": "http://enterprise.lemmy.ml/activities/block/5d42fffb-0903-4625-86d4-0b39bb344fc2"
|
"id": "http://enterprise.lemmy.ml/activities/block/5d42fffb-0903-4625-86d4-0b39bb344fc2"
|
||||||
}
|
}
|
|
@ -12,6 +12,7 @@ use crate::{
|
||||||
protocol::activities::community::block_user::BlockUserFromCommunity,
|
protocol::activities::community::block_user::BlockUserFromCommunity,
|
||||||
};
|
};
|
||||||
use activitystreams_kinds::{activity::BlockType, public};
|
use activitystreams_kinds::{activity::BlockType, public};
|
||||||
|
use chrono::NaiveDateTime;
|
||||||
use lemmy_api_common::blocking;
|
use lemmy_api_common::blocking;
|
||||||
use lemmy_apub_lib::{
|
use lemmy_apub_lib::{
|
||||||
data::Data,
|
data::Data,
|
||||||
|
@ -27,7 +28,7 @@ use lemmy_db_schema::{
|
||||||
},
|
},
|
||||||
traits::{Bannable, Followable},
|
traits::{Bannable, Followable},
|
||||||
};
|
};
|
||||||
use lemmy_utils::LemmyError;
|
use lemmy_utils::{utils::convert_datetime, LemmyError};
|
||||||
use lemmy_websocket::LemmyContext;
|
use lemmy_websocket::LemmyContext;
|
||||||
|
|
||||||
impl BlockUserFromCommunity {
|
impl BlockUserFromCommunity {
|
||||||
|
@ -35,6 +36,7 @@ impl BlockUserFromCommunity {
|
||||||
community: &ApubCommunity,
|
community: &ApubCommunity,
|
||||||
target: &ApubPerson,
|
target: &ApubPerson,
|
||||||
actor: &ApubPerson,
|
actor: &ApubPerson,
|
||||||
|
expires: Option<NaiveDateTime>,
|
||||||
context: &LemmyContext,
|
context: &LemmyContext,
|
||||||
) -> Result<BlockUserFromCommunity, LemmyError> {
|
) -> Result<BlockUserFromCommunity, LemmyError> {
|
||||||
Ok(BlockUserFromCommunity {
|
Ok(BlockUserFromCommunity {
|
||||||
|
@ -48,6 +50,7 @@ impl BlockUserFromCommunity {
|
||||||
BlockType::Block,
|
BlockType::Block,
|
||||||
&context.settings().get_protocol_and_hostname(),
|
&context.settings().get_protocol_and_hostname(),
|
||||||
)?,
|
)?,
|
||||||
|
expires: expires.map(convert_datetime),
|
||||||
unparsed: Default::default(),
|
unparsed: Default::default(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -57,9 +60,10 @@ impl BlockUserFromCommunity {
|
||||||
community: &ApubCommunity,
|
community: &ApubCommunity,
|
||||||
target: &ApubPerson,
|
target: &ApubPerson,
|
||||||
actor: &ApubPerson,
|
actor: &ApubPerson,
|
||||||
|
expires: Option<NaiveDateTime>,
|
||||||
context: &LemmyContext,
|
context: &LemmyContext,
|
||||||
) -> Result<(), LemmyError> {
|
) -> Result<(), LemmyError> {
|
||||||
let block = BlockUserFromCommunity::new(community, target, actor, context)?;
|
let block = BlockUserFromCommunity::new(community, target, actor, expires, context)?;
|
||||||
let block_id = block.id.clone();
|
let block_id = block.id.clone();
|
||||||
|
|
||||||
let activity = AnnouncableActivities::BlockUserFromCommunity(block);
|
let activity = AnnouncableActivities::BlockUserFromCommunity(block);
|
||||||
|
@ -101,8 +105,7 @@ impl ActivityHandler for BlockUserFromCommunity {
|
||||||
let community_user_ban_form = CommunityPersonBanForm {
|
let community_user_ban_form = CommunityPersonBanForm {
|
||||||
community_id: community.id,
|
community_id: community.id,
|
||||||
person_id: blocked_user.id,
|
person_id: blocked_user.id,
|
||||||
// TODO how to carry across the ban expiration time?
|
expires: Some(self.expires.map(|u| u.naive_local())),
|
||||||
expires: None,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
blocking(context.pool(), move |conn: &'_ _| {
|
blocking(context.pool(), move |conn: &'_ _| {
|
||||||
|
|
|
@ -36,7 +36,7 @@ impl UndoBlockUserFromCommunity {
|
||||||
actor: &ApubPerson,
|
actor: &ApubPerson,
|
||||||
context: &LemmyContext,
|
context: &LemmyContext,
|
||||||
) -> Result<(), LemmyError> {
|
) -> Result<(), LemmyError> {
|
||||||
let block = BlockUserFromCommunity::new(community, target, actor, context)?;
|
let block = BlockUserFromCommunity::new(community, target, actor, None, context)?;
|
||||||
|
|
||||||
let id = generate_activity_id(
|
let id = generate_activity_id(
|
||||||
UndoType::Undo,
|
UndoType::Undo,
|
||||||
|
|
|
@ -3,6 +3,7 @@ use crate::{
|
||||||
protocol::Unparsed,
|
protocol::Unparsed,
|
||||||
};
|
};
|
||||||
use activitystreams_kinds::activity::BlockType;
|
use activitystreams_kinds::activity::BlockType;
|
||||||
|
use chrono::{DateTime, FixedOffset};
|
||||||
use lemmy_apub_lib::object_id::ObjectId;
|
use lemmy_apub_lib::object_id::ObjectId;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
@ -22,4 +23,5 @@ pub struct BlockUserFromCommunity {
|
||||||
pub(crate) id: Url,
|
pub(crate) id: Url,
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub(crate) unparsed: Unparsed,
|
pub(crate) unparsed: Unparsed,
|
||||||
|
pub(crate) expires: Option<DateTime<FixedOffset>>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue