Accept Create() activities with object type Article and Video
This commit is contained in:
parent
126c04febb
commit
1edcefee6d
3 changed files with 13 additions and 5 deletions
|
@ -16,7 +16,7 @@ use crate::activitypub::{
|
||||||
},
|
},
|
||||||
identifiers::parse_local_actor_id,
|
identifiers::parse_local_actor_id,
|
||||||
receiver::{parse_array, parse_property_value, HandlerError},
|
receiver::{parse_array, parse_property_value, HandlerError},
|
||||||
vocabulary::{DOCUMENT, HASHTAG, IMAGE, LINK, MENTION, NOTE},
|
vocabulary::*,
|
||||||
};
|
};
|
||||||
use crate::config::Instance;
|
use crate::config::Instance;
|
||||||
use crate::errors::{ConversionError, DatabaseError, ValidationError};
|
use crate::errors::{ConversionError, DatabaseError, ValidationError};
|
||||||
|
@ -127,9 +127,15 @@ pub async fn handle_note(
|
||||||
object: Object,
|
object: Object,
|
||||||
redirects: &HashMap<String, String>,
|
redirects: &HashMap<String, String>,
|
||||||
) -> Result<Post, HandlerError> {
|
) -> Result<Post, HandlerError> {
|
||||||
if object.object_type != NOTE {
|
match object.object_type.as_str() {
|
||||||
// Could be Page (in Lemmy) or some other type
|
NOTE => (),
|
||||||
log::warn!("processing object of type {}", object.object_type);
|
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)?;
|
let author_id = get_note_author_id(&object)?;
|
||||||
|
|
|
@ -224,7 +224,7 @@ pub async fn receive_activity(
|
||||||
require_actor_signature(&activity.actor, &signer_id)?;
|
require_actor_signature(&activity.actor, &signer_id)?;
|
||||||
handle_reject_follow(config, db_client, activity).await?
|
handle_reject_follow(config, db_client, activity).await?
|
||||||
},
|
},
|
||||||
(CREATE, NOTE | QUESTION | PAGE) => {
|
(CREATE, _) => {
|
||||||
let object: Object = serde_json::from_value(activity.object)
|
let object: Object = serde_json::from_value(activity.object)
|
||||||
.map_err(|_| ValidationError("invalid object"))?;
|
.map_err(|_| ValidationError("invalid object"))?;
|
||||||
let object_id = object.id.clone();
|
let object_id = object.id.clone();
|
||||||
|
|
|
@ -21,12 +21,14 @@ pub const PERSON: &str = "Person";
|
||||||
pub const SERVICE: &str = "Service";
|
pub const SERVICE: &str = "Service";
|
||||||
|
|
||||||
// Object types
|
// Object types
|
||||||
|
pub const ARTICLE: &str = "Article";
|
||||||
pub const DOCUMENT: &str = "Document";
|
pub const DOCUMENT: &str = "Document";
|
||||||
pub const IMAGE: &str = "Image";
|
pub const IMAGE: &str = "Image";
|
||||||
pub const MENTION: &str = "Mention";
|
pub const MENTION: &str = "Mention";
|
||||||
pub const NOTE: &str = "Note";
|
pub const NOTE: &str = "Note";
|
||||||
pub const PAGE: &str = "Page";
|
pub const PAGE: &str = "Page";
|
||||||
pub const TOMBSTONE: &str = "Tombstone";
|
pub const TOMBSTONE: &str = "Tombstone";
|
||||||
|
pub const VIDEO: &str = "Video";
|
||||||
|
|
||||||
// Collections
|
// Collections
|
||||||
pub const ORDERED_COLLECTION: &str = "OrderedCollection";
|
pub const ORDERED_COLLECTION: &str = "OrderedCollection";
|
||||||
|
|
Loading…
Reference in a new issue