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