Transform incoming events into posts
Support for Event objects from Rebased.
This commit is contained in:
parent
777dd74373
commit
e5c1be2f93
2 changed files with 12 additions and 9 deletions
|
@ -76,15 +76,17 @@ pub fn get_note_content(object: &Object) -> Result<String, ValidationError> {
|
||||||
object.name.as_deref().unwrap_or("").to_string()
|
object.name.as_deref().unwrap_or("").to_string()
|
||||||
};
|
};
|
||||||
if object.object_type != NOTE {
|
if object.object_type != NOTE {
|
||||||
if let Some(ref value) = object.url {
|
// Append link to object
|
||||||
// Append link to object
|
let object_url = if let Some(ref value) = object.url {
|
||||||
let object_url = parse_object_url(value)
|
parse_object_url(value)
|
||||||
.map_err(|_| ValidationError("invalid object URL"))?;
|
.map_err(|_| ValidationError("invalid object URL"))?
|
||||||
content += &format!(
|
} else {
|
||||||
r#"<p><a href="{0}">{0}</a></p>"#,
|
object.id.clone()
|
||||||
object_url,
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
content += &format!(
|
||||||
|
r#"<p><a href="{0}">{0}</a></p>"#,
|
||||||
|
object_url,
|
||||||
|
);
|
||||||
};
|
};
|
||||||
if content.len() > CONTENT_MAX_SIZE {
|
if content.len() > CONTENT_MAX_SIZE {
|
||||||
return Err(ValidationError("content is too long"));
|
return Err(ValidationError("content is too long"));
|
||||||
|
@ -130,7 +132,7 @@ pub async fn handle_note(
|
||||||
) -> Result<Post, HandlerError> {
|
) -> Result<Post, HandlerError> {
|
||||||
match object.object_type.as_str() {
|
match object.object_type.as_str() {
|
||||||
NOTE => (),
|
NOTE => (),
|
||||||
ARTICLE | QUESTION | PAGE | VIDEO => {
|
ARTICLE | EVENT | QUESTION | PAGE | VIDEO => {
|
||||||
log::info!("processing object of type {}", object.object_type);
|
log::info!("processing object of type {}", object.object_type);
|
||||||
},
|
},
|
||||||
other_type => {
|
other_type => {
|
||||||
|
|
|
@ -23,6 +23,7 @@ pub const SERVICE: &str = "Service";
|
||||||
// Object types
|
// Object types
|
||||||
pub const ARTICLE: &str = "Article";
|
pub const ARTICLE: &str = "Article";
|
||||||
pub const DOCUMENT: &str = "Document";
|
pub const DOCUMENT: &str = "Document";
|
||||||
|
pub const EVENT: &str = "Event";
|
||||||
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";
|
||||||
|
|
Loading…
Reference in a new issue