From: Dessalines Date: Mon, 25 May 2020 20:15:23 +0000 (-0400) Subject: Merge branch 'federated_embeds' into federation X-Git-Url: http://these/git/%7B%60%24%7BwebArchiveUrl%7D/%22%7B%7D/readmes/%7B%7D/%22%7Burl%7D/%7Bthis.imageSrc%7D?a=commitdiff_plain;h=a9af247f1eebf928c63f4127184c206287f6ead9;p=lemmy.git Merge branch 'federated_embeds' into federation --- a9af247f1eebf928c63f4127184c206287f6ead9 diff --cc server/src/apub/post.rs index 23f18a5c,d32ba3ae..9ee04298 --- a/server/src/apub/post.rs +++ b/server/src/apub/post.rs @@@ -1,39 -1,4 +1,41 @@@ -use super::*; +use crate::{ + apub::{ + activities::{populate_object_props, send_activity}, + create_apub_response, + create_apub_tombstone_response, + create_tombstone, + extensions::page_extension::PageExtension, + fetcher::{get_or_fetch_and_upsert_remote_community, get_or_fetch_and_upsert_remote_user}, ++ get_apub_protocol_string, + ActorType, + ApubLikeableType, + ApubObjectType, + FromApub, + PageExt, + ToApub, + }, + convert_datetime, + db::{ + activity::insert_activity, + community::Community, + post::{Post, PostForm}, + user::User_, + Crud, + }, + routes::DbPoolParam, ++ Settings, +}; +use activitystreams::{ + activity::{Create, Delete, Dislike, Like, Remove, Undo, Update}, + context, - object::{kind::PageType, properties::ObjectProperties, Page, Tombstone}, ++ object::{kind::PageType, properties::ObjectProperties, AnyImage, Image, Page, Tombstone}, + BaseBox, +}; +use activitystreams_ext::Ext1; +use actix_web::{body::Body, web::Path, HttpResponse, Result}; +use diesel::PgConnection; +use failure::Error; +use serde::Deserialize; #[derive(Deserialize)] pub struct PostQuery { diff --cc server/src/apub/user.rs index a2958b15,395dda9c..0a651d1f --- a/server/src/apub/user.rs +++ b/server/src/apub/user.rs @@@ -1,33 -1,4 +1,33 @@@ -use super::*; +use crate::{ + apub::{ + activities::send_activity, + create_apub_response, + extensions::signatures::PublicKey, + ActorType, + FromApub, + PersonExt, + ToApub, + }, + convert_datetime, + db::{ + activity::insert_activity, + user::{UserForm, User_}, + }, + naive_now, + routes::DbPoolParam, +}; +use activitystreams::{ + activity::{Follow, Undo}, + actor::{properties::ApActorProperties, Person}, + context, + endpoint::EndpointProperties, - object::{properties::ObjectProperties, Tombstone}, ++ object::{properties::ObjectProperties, AnyImage, Image, Tombstone}, +}; +use activitystreams_ext::Ext2; +use actix_web::{body::Body, web::Path, HttpResponse, Result}; +use diesel::PgConnection; +use failure::Error; +use serde::Deserialize; #[derive(Deserialize)] pub struct UserQuery { @@@ -177,10 -157,20 +186,20 @@@ impl FromApub for UserForm type ApubType = PersonExt; /// Parse an ActivityPub person received from another instance into a Lemmy user. fn from_apub(person: &PersonExt, _conn: &PgConnection) -> Result { - let oprops = &person.base.base.object_props; - let aprops = &person.base.extension; - let public_key: &PublicKey = &person.extension.public_key; + let oprops = &person.inner.object_props; + let aprops = &person.ext_one; + let public_key: &PublicKey = &person.ext_two.public_key; + let avatar = match oprops.get_icon_any_image() { + Some(any_image) => any_image + .to_owned() + .into_concrete::()? + .object_props + .get_url_xsd_any_uri() + .map(|u| u.to_string()), + None => None, + }; + Ok(UserForm { name: oprops.get_name_xsd_string().unwrap().to_string(), preferred_username: aprops.get_preferred_username().map(|u| u.to_string()),