Accept Create() activities with object type Article and Video

This commit is contained in:
silverpill 2022-11-21 23:24:40 +00:00
parent 126c04febb
commit 1edcefee6d
3 changed files with 13 additions and 5 deletions

View file

@ -16,7 +16,7 @@ use crate::activitypub::{
},
identifiers::parse_local_actor_id,
receiver::{parse_array, parse_property_value, HandlerError},
vocabulary::{DOCUMENT, HASHTAG, IMAGE, LINK, MENTION, NOTE},
vocabulary::*,
};
use crate::config::Instance;
use crate::errors::{ConversionError, DatabaseError, ValidationError};
@ -127,9 +127,15 @@ pub async fn handle_note(
object: Object,
redirects: &HashMap<String, String>,
) -> Result<Post, HandlerError> {
if object.object_type != NOTE {
// Could be Page (in Lemmy) or some other type
log::warn!("processing object of type {}", object.object_type);
match object.object_type.as_str() {
NOTE => (),
ARTICLE | QUESTION | PAGE | VIDEO => {
log::info!("processing object of type {}", object.object_type);
},
other_type => {
log::warn!("discarding object of type {}", other_type);
return Err(ValidationError("unsupported type").into());
},
};
let author_id = get_note_author_id(&object)?;

View file

@ -224,7 +224,7 @@ pub async fn receive_activity(
require_actor_signature(&activity.actor, &signer_id)?;
handle_reject_follow(config, db_client, activity).await?
},
(CREATE, NOTE | QUESTION | PAGE) => {
(CREATE, _) => {
let object: Object = serde_json::from_value(activity.object)
.map_err(|_| ValidationError("invalid object"))?;
let object_id = object.id.clone();

View file

@ -21,12 +21,14 @@ pub const PERSON: &str = "Person";
pub const SERVICE: &str = "Service";
// Object types
pub const ARTICLE: &str = "Article";
pub const DOCUMENT: &str = "Document";
pub const IMAGE: &str = "Image";
pub const MENTION: &str = "Mention";
pub const NOTE: &str = "Note";
pub const PAGE: &str = "Page";
pub const TOMBSTONE: &str = "Tombstone";
pub const VIDEO: &str = "Video";
// Collections
pub const ORDERED_COLLECTION: &str = "OrderedCollection";