impl ToTombstone for Comment {
fn to_tombstone(&self) -> Result<Tombstone, Error> {
- create_tombstone(self.deleted, &self.ap_id, self.published, self.updated)
+ create_tombstone(self.deleted, &self.ap_id, self.published, self.updated, NoteType.to_string())
}
}
use super::*;
+use activitystreams::actor::kind::GroupType;
#[derive(Deserialize)]
pub struct CommunityQuery {
impl ToTombstone for Community {
fn to_tombstone(&self) -> Result<Tombstone, Error> {
- create_tombstone(self.deleted, &self.actor_id, self.published, self.updated)
+ create_tombstone(self.deleted, &self.actor_id, self.published, self.updated, GroupType.to_string())
}
}
object::{properties::ObjectProperties, Note, Page, Tombstone},
public, BaseBox,
};
+use activitystreams::object::kind::{NoteType, PageType};
+use crate::api::community::CommunityResponse;
+use crate::websocket::server::SendCommunityRoomMessage;
use actix_web::body::Body;
use actix_web::web::Path;
use actix_web::{web, HttpRequest, HttpResponse, Result};
use fetcher::{get_or_fetch_and_upsert_remote_community, get_or_fetch_and_upsert_remote_user};
use signatures::verify;
use signatures::{sign, PublicKey, PublicKeyExtension};
+use activitystreams::primitives::XsdString;
type GroupExt = Ext<Ext<Group, ApActorProperties>, PublicKeyExtension>;
type PersonExt = Ext<Ext<Person, ApActorProperties>, PublicKeyExtension>;
.content_type(APUB_JSON_CONTENT_TYPE)
.json(data)
}
+
fn create_apub_tombstone_response<T>(data: &T) -> HttpResponse<Body>
where
T: Serialize,
object_id: &str,
published: NaiveDateTime,
updated: Option<NaiveDateTime>,
+ former_type: String,
) -> Result<Tombstone, Error> {
if deleted {
let mut tombstone = Tombstone::default();
tombstone
.object_props
.set_id(object_id)?
- .set_published(convert_datetime(published))?;
+ .set_published(convert_datetime(published));
if let Some(updated) = updated {
tombstone
.object_props
.set_updated(convert_datetime(updated))?;
}
+ tombstone.tombstone_props.set_former_type_object_box(XsdString::from_string(former_type))?;
Ok(tombstone)
} else {
Err(format_err!(
impl ToTombstone for Post {
fn to_tombstone(&self) -> Result<Tombstone, Error> {
- create_tombstone(self.deleted, &self.ap_id, self.published, self.updated)
+ create_tombstone(self.deleted, &self.ap_id, self.published, self.updated, PageType.to_string())
}
}
use super::*;
-use crate::api::community::CommunityResponse;
-use crate::websocket::server::SendCommunityRoomMessage;
#[serde(untagged)]
#[derive(Serialize, Deserialize, Debug)]
receive_dislike_comment(&d, &request, &conn, chat_server)
}
(SharedAcceptedObjects::Delete(d), Some("Tombstone")) => {
- // TODO: is this deleting a community, post, comment or what?
- receive_delete_community(&d, &request, &conn, chat_server)
+ receive_delete(&d, &request, &conn, chat_server)
}
_ => Err(format_err!("Unknown incoming activity type.")),
}
Ok(HttpResponse::Ok().finish())
}
-fn receive_delete_community(
+fn receive_delete(
delete: &Delete,
request: &HttpRequest,
conn: &PgConnection,
.unwrap()
.to_owned()
.to_concrete::<Tombstone>()?;
+ // TODO: not sure how to handle formerType (should be a string)
+ // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-formertype
+ let former_type: &str = tombstone.tombstone_props.get_former_type_object_box().unwrap().to_concrete::<String>();
+ match former_type {
+ "Group" => {},
+ d => return Err(format_err!("Delete type {} not supported", d)),
+ }
let community_apub_id = tombstone.object_props.get_id().unwrap().to_string();
let community = Community::read_from_actor_id(conn, &community_apub_id)?;