Adding unique ap_ids. Fixes #1100
This commit is contained in:
parent
8ac0fa6d6c
commit
5b4722b66c
28 changed files with 202 additions and 119 deletions
|
@ -113,7 +113,7 @@ mod tests {
|
||||||
lang: "browser".into(),
|
lang: "browser".into(),
|
||||||
show_avatars: true,
|
show_avatars: true,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
actor_id: "changeme_862362".into(),
|
actor_id: None,
|
||||||
bio: None,
|
bio: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
|
|
|
@ -39,13 +39,13 @@ pub struct CommentForm {
|
||||||
pub published: Option<chrono::NaiveDateTime>,
|
pub published: Option<chrono::NaiveDateTime>,
|
||||||
pub updated: Option<chrono::NaiveDateTime>,
|
pub updated: Option<chrono::NaiveDateTime>,
|
||||||
pub deleted: Option<bool>,
|
pub deleted: Option<bool>,
|
||||||
pub ap_id: String,
|
pub ap_id: Option<String>,
|
||||||
pub local: bool,
|
pub local: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CommentForm {
|
impl CommentForm {
|
||||||
pub fn get_ap_id(&self) -> Result<Url, ParseError> {
|
pub fn get_ap_id(&self) -> Result<Url, ParseError> {
|
||||||
Url::parse(&self.ap_id)
|
Url::parse(&self.ap_id.as_ref().unwrap_or(&"not_a_url".to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ impl Crud<CommentForm> for Comment {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create(conn: &PgConnection, comment_form: &CommentForm) -> Result<Self, Error> {
|
fn create(conn: &PgConnection, comment_form: &CommentForm) -> Result<Self, Error> {
|
||||||
println!("creating {}", &comment_form.ap_id);
|
// println!("creating {}", &comment_form.ap_id.as_ref().unwrap());
|
||||||
use crate::schema::comment::dsl::*;
|
use crate::schema::comment::dsl::*;
|
||||||
insert_into(comment)
|
insert_into(comment)
|
||||||
.values(comment_form)
|
.values(comment_form)
|
||||||
|
@ -165,7 +165,7 @@ impl Comment {
|
||||||
|
|
||||||
pub fn upsert(conn: &PgConnection, comment_form: &CommentForm) -> Result<Self, Error> {
|
pub fn upsert(conn: &PgConnection, comment_form: &CommentForm) -> Result<Self, Error> {
|
||||||
println!("Comment::upsert() (entered into function)");
|
println!("Comment::upsert() (entered into function)");
|
||||||
let existing = Self::read_from_apub_id(conn, &comment_form.ap_id);
|
let existing = Self::read_from_apub_id(conn, &comment_form.ap_id.as_ref().unwrap());
|
||||||
println!("Comment::upsert() (checked if comment exists)");
|
println!("Comment::upsert() (checked if comment exists)");
|
||||||
let x = match existing {
|
let x = match existing {
|
||||||
Err(NotFound {}) => Ok(Self::create(conn, &comment_form)?),
|
Err(NotFound {}) => Ok(Self::create(conn, &comment_form)?),
|
||||||
|
@ -278,7 +278,7 @@ mod tests {
|
||||||
lang: "browser".into(),
|
lang: "browser".into(),
|
||||||
show_avatars: true,
|
show_avatars: true,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
actor_id: "changeme_283687".into(),
|
actor_id: None,
|
||||||
bio: None,
|
bio: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
|
@ -298,7 +298,7 @@ mod tests {
|
||||||
deleted: None,
|
deleted: None,
|
||||||
updated: None,
|
updated: None,
|
||||||
nsfw: false,
|
nsfw: false,
|
||||||
actor_id: "changeme_928738972".into(),
|
actor_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
public_key: None,
|
public_key: None,
|
||||||
|
@ -326,7 +326,7 @@ mod tests {
|
||||||
embed_description: None,
|
embed_description: None,
|
||||||
embed_html: None,
|
embed_html: None,
|
||||||
thumbnail_url: None,
|
thumbnail_url: None,
|
||||||
ap_id: "http://fake.com".into(),
|
ap_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
published: None,
|
published: None,
|
||||||
};
|
};
|
||||||
|
@ -343,7 +343,7 @@ mod tests {
|
||||||
parent_id: None,
|
parent_id: None,
|
||||||
published: None,
|
published: None,
|
||||||
updated: None,
|
updated: None,
|
||||||
ap_id: "http://fake.com".into(),
|
ap_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ mod tests {
|
||||||
parent_id: None,
|
parent_id: None,
|
||||||
published: inserted_comment.published,
|
published: inserted_comment.published,
|
||||||
updated: None,
|
updated: None,
|
||||||
ap_id: "http://fake.com".into(),
|
ap_id: inserted_comment.ap_id.to_owned(),
|
||||||
local: true,
|
local: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ mod tests {
|
||||||
read: None,
|
read: None,
|
||||||
published: None,
|
published: None,
|
||||||
updated: None,
|
updated: None,
|
||||||
ap_id: "http://fake.com".into(),
|
ap_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -517,7 +517,7 @@ mod tests {
|
||||||
lang: "browser".into(),
|
lang: "browser".into(),
|
||||||
show_avatars: true,
|
show_avatars: true,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
actor_id: "changeme_92873982".into(),
|
actor_id: None,
|
||||||
bio: None,
|
bio: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
|
@ -537,7 +537,7 @@ mod tests {
|
||||||
deleted: None,
|
deleted: None,
|
||||||
updated: None,
|
updated: None,
|
||||||
nsfw: false,
|
nsfw: false,
|
||||||
actor_id: "changeme_7625376".into(),
|
actor_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
public_key: None,
|
public_key: None,
|
||||||
|
@ -565,7 +565,7 @@ mod tests {
|
||||||
embed_description: None,
|
embed_description: None,
|
||||||
embed_html: None,
|
embed_html: None,
|
||||||
thumbnail_url: None,
|
thumbnail_url: None,
|
||||||
ap_id: "http://fake.com".into(),
|
ap_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
published: None,
|
published: None,
|
||||||
};
|
};
|
||||||
|
@ -582,7 +582,7 @@ mod tests {
|
||||||
read: None,
|
read: None,
|
||||||
published: None,
|
published: None,
|
||||||
updated: None,
|
updated: None,
|
||||||
ap_id: "http://fake.com".into(),
|
ap_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -627,7 +627,7 @@ mod tests {
|
||||||
my_vote: None,
|
my_vote: None,
|
||||||
subscribed: None,
|
subscribed: None,
|
||||||
saved: None,
|
saved: None,
|
||||||
ap_id: "http://fake.com".to_string(),
|
ap_id: inserted_comment.ap_id.to_owned(),
|
||||||
local: true,
|
local: true,
|
||||||
community_actor_id: inserted_community.actor_id.to_owned(),
|
community_actor_id: inserted_community.actor_id.to_owned(),
|
||||||
community_local: true,
|
community_local: true,
|
||||||
|
@ -665,7 +665,7 @@ mod tests {
|
||||||
my_vote: Some(1),
|
my_vote: Some(1),
|
||||||
subscribed: Some(false),
|
subscribed: Some(false),
|
||||||
saved: Some(false),
|
saved: Some(false),
|
||||||
ap_id: "http://fake.com".to_string(),
|
ap_id: inserted_comment.ap_id.to_owned(),
|
||||||
local: true,
|
local: true,
|
||||||
community_actor_id: inserted_community.actor_id.to_owned(),
|
community_actor_id: inserted_community.actor_id.to_owned(),
|
||||||
community_local: true,
|
community_local: true,
|
||||||
|
|
|
@ -45,7 +45,7 @@ pub struct CommunityForm {
|
||||||
pub updated: Option<chrono::NaiveDateTime>,
|
pub updated: Option<chrono::NaiveDateTime>,
|
||||||
pub deleted: Option<bool>,
|
pub deleted: Option<bool>,
|
||||||
pub nsfw: bool,
|
pub nsfw: bool,
|
||||||
pub actor_id: String,
|
pub actor_id: Option<String>,
|
||||||
pub local: bool,
|
pub local: bool,
|
||||||
pub private_key: Option<String>,
|
pub private_key: Option<String>,
|
||||||
pub public_key: Option<String>,
|
pub public_key: Option<String>,
|
||||||
|
@ -330,7 +330,7 @@ mod tests {
|
||||||
lang: "browser".into(),
|
lang: "browser".into(),
|
||||||
show_avatars: true,
|
show_avatars: true,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
actor_id: "changeme_8266238".into(),
|
actor_id: None,
|
||||||
bio: None,
|
bio: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
|
@ -350,7 +350,7 @@ mod tests {
|
||||||
removed: None,
|
removed: None,
|
||||||
deleted: None,
|
deleted: None,
|
||||||
updated: None,
|
updated: None,
|
||||||
actor_id: "changeme_7625376".into(),
|
actor_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
public_key: None,
|
public_key: None,
|
||||||
|
|
|
@ -426,7 +426,7 @@ mod tests {
|
||||||
lang: "browser".into(),
|
lang: "browser".into(),
|
||||||
show_avatars: true,
|
show_avatars: true,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
actor_id: "changeme_829398".into(),
|
actor_id: None,
|
||||||
bio: None,
|
bio: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
|
@ -454,7 +454,7 @@ mod tests {
|
||||||
lang: "browser".into(),
|
lang: "browser".into(),
|
||||||
show_avatars: true,
|
show_avatars: true,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
actor_id: "changeme_82982738".into(),
|
actor_id: None,
|
||||||
bio: None,
|
bio: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
|
@ -474,7 +474,7 @@ mod tests {
|
||||||
deleted: None,
|
deleted: None,
|
||||||
updated: None,
|
updated: None,
|
||||||
nsfw: false,
|
nsfw: false,
|
||||||
actor_id: "changeme_283687".into(),
|
actor_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
public_key: None,
|
public_key: None,
|
||||||
|
@ -502,7 +502,7 @@ mod tests {
|
||||||
embed_description: None,
|
embed_description: None,
|
||||||
embed_html: None,
|
embed_html: None,
|
||||||
thumbnail_url: None,
|
thumbnail_url: None,
|
||||||
ap_id: "http://fake.com".into(),
|
ap_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
published: None,
|
published: None,
|
||||||
};
|
};
|
||||||
|
@ -519,7 +519,7 @@ mod tests {
|
||||||
parent_id: None,
|
parent_id: None,
|
||||||
published: None,
|
published: None,
|
||||||
updated: None,
|
updated: None,
|
||||||
ap_id: "http://fake.com".into(),
|
ap_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ mod tests {
|
||||||
lang: "browser".into(),
|
lang: "browser".into(),
|
||||||
show_avatars: true,
|
show_avatars: true,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
actor_id: "changeme_8292378".into(),
|
actor_id: None,
|
||||||
bio: None,
|
bio: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
|
|
|
@ -53,13 +53,13 @@ pub struct PostForm {
|
||||||
pub embed_description: Option<String>,
|
pub embed_description: Option<String>,
|
||||||
pub embed_html: Option<String>,
|
pub embed_html: Option<String>,
|
||||||
pub thumbnail_url: Option<String>,
|
pub thumbnail_url: Option<String>,
|
||||||
pub ap_id: String,
|
pub ap_id: Option<String>,
|
||||||
pub local: bool,
|
pub local: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PostForm {
|
impl PostForm {
|
||||||
pub fn get_ap_id(&self) -> Result<Url, ParseError> {
|
pub fn get_ap_id(&self) -> Result<Url, ParseError> {
|
||||||
Url::parse(&self.ap_id)
|
Url::parse(&self.ap_id.as_ref().unwrap_or(&"not_a_url".to_string()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ mod tests {
|
||||||
lang: "browser".into(),
|
lang: "browser".into(),
|
||||||
show_avatars: true,
|
show_avatars: true,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
actor_id: "changeme_8292683678".into(),
|
actor_id: None,
|
||||||
bio: None,
|
bio: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
|
@ -377,7 +377,7 @@ mod tests {
|
||||||
deleted: None,
|
deleted: None,
|
||||||
updated: None,
|
updated: None,
|
||||||
nsfw: false,
|
nsfw: false,
|
||||||
actor_id: "changeme_8223262378".into(),
|
actor_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
public_key: None,
|
public_key: None,
|
||||||
|
@ -405,7 +405,7 @@ mod tests {
|
||||||
embed_description: None,
|
embed_description: None,
|
||||||
embed_html: None,
|
embed_html: None,
|
||||||
thumbnail_url: None,
|
thumbnail_url: None,
|
||||||
ap_id: "http://fake.com".into(),
|
ap_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
published: None,
|
published: None,
|
||||||
};
|
};
|
||||||
|
@ -430,7 +430,7 @@ mod tests {
|
||||||
embed_description: None,
|
embed_description: None,
|
||||||
embed_html: None,
|
embed_html: None,
|
||||||
thumbnail_url: None,
|
thumbnail_url: None,
|
||||||
ap_id: "http://fake.com".into(),
|
ap_id: inserted_post.ap_id.to_owned(),
|
||||||
local: true,
|
local: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -423,7 +423,7 @@ mod tests {
|
||||||
lang: "browser".into(),
|
lang: "browser".into(),
|
||||||
show_avatars: true,
|
show_avatars: true,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
actor_id: "changeme_8282738268".into(),
|
actor_id: None,
|
||||||
bio: None,
|
bio: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
|
@ -443,7 +443,7 @@ mod tests {
|
||||||
deleted: None,
|
deleted: None,
|
||||||
updated: None,
|
updated: None,
|
||||||
nsfw: false,
|
nsfw: false,
|
||||||
actor_id: "changeme_2763".into(),
|
actor_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
public_key: None,
|
public_key: None,
|
||||||
|
@ -471,7 +471,7 @@ mod tests {
|
||||||
embed_description: None,
|
embed_description: None,
|
||||||
embed_html: None,
|
embed_html: None,
|
||||||
thumbnail_url: None,
|
thumbnail_url: None,
|
||||||
ap_id: "http://fake.com".into(),
|
ap_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
published: None,
|
published: None,
|
||||||
};
|
};
|
||||||
|
@ -555,7 +555,7 @@ mod tests {
|
||||||
embed_description: None,
|
embed_description: None,
|
||||||
embed_html: None,
|
embed_html: None,
|
||||||
thumbnail_url: None,
|
thumbnail_url: None,
|
||||||
ap_id: "http://fake.com".to_string(),
|
ap_id: inserted_post.ap_id.to_owned(),
|
||||||
local: true,
|
local: true,
|
||||||
creator_actor_id: inserted_user.actor_id.to_owned(),
|
creator_actor_id: inserted_user.actor_id.to_owned(),
|
||||||
creator_local: true,
|
creator_local: true,
|
||||||
|
@ -604,7 +604,7 @@ mod tests {
|
||||||
embed_description: None,
|
embed_description: None,
|
||||||
embed_html: None,
|
embed_html: None,
|
||||||
thumbnail_url: None,
|
thumbnail_url: None,
|
||||||
ap_id: "http://fake.com".to_string(),
|
ap_id: inserted_post.ap_id.to_owned(),
|
||||||
local: true,
|
local: true,
|
||||||
creator_actor_id: inserted_user.actor_id.to_owned(),
|
creator_actor_id: inserted_user.actor_id.to_owned(),
|
||||||
creator_local: true,
|
creator_local: true,
|
||||||
|
|
|
@ -27,7 +27,7 @@ pub struct PrivateMessageForm {
|
||||||
pub read: Option<bool>,
|
pub read: Option<bool>,
|
||||||
pub published: Option<chrono::NaiveDateTime>,
|
pub published: Option<chrono::NaiveDateTime>,
|
||||||
pub updated: Option<chrono::NaiveDateTime>,
|
pub updated: Option<chrono::NaiveDateTime>,
|
||||||
pub ap_id: String,
|
pub ap_id: Option<String>,
|
||||||
pub local: bool,
|
pub local: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ mod tests {
|
||||||
lang: "browser".into(),
|
lang: "browser".into(),
|
||||||
show_avatars: true,
|
show_avatars: true,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
actor_id: "changeme_6723878".into(),
|
actor_id: None,
|
||||||
bio: None,
|
bio: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
|
@ -181,7 +181,7 @@ mod tests {
|
||||||
lang: "browser".into(),
|
lang: "browser".into(),
|
||||||
show_avatars: true,
|
show_avatars: true,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
actor_id: "changeme_287263876".into(),
|
actor_id: None,
|
||||||
bio: None,
|
bio: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
|
@ -199,7 +199,7 @@ mod tests {
|
||||||
read: None,
|
read: None,
|
||||||
published: None,
|
published: None,
|
||||||
updated: None,
|
updated: None,
|
||||||
ap_id: "http://fake.com".into(),
|
ap_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -214,7 +214,7 @@ mod tests {
|
||||||
read: false,
|
read: false,
|
||||||
updated: None,
|
updated: None,
|
||||||
published: inserted_private_message.published,
|
published: inserted_private_message.published,
|
||||||
ap_id: "http://fake.com".into(),
|
ap_id: inserted_private_message.ap_id.to_owned(),
|
||||||
local: true,
|
local: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ pub struct UserForm {
|
||||||
pub show_avatars: bool,
|
pub show_avatars: bool,
|
||||||
pub send_notifications_to_email: bool,
|
pub send_notifications_to_email: bool,
|
||||||
pub matrix_user_id: Option<String>,
|
pub matrix_user_id: Option<String>,
|
||||||
pub actor_id: String,
|
pub actor_id: Option<String>,
|
||||||
pub bio: Option<String>,
|
pub bio: Option<String>,
|
||||||
pub local: bool,
|
pub local: bool,
|
||||||
pub private_key: Option<String>,
|
pub private_key: Option<String>,
|
||||||
|
@ -189,7 +189,7 @@ mod tests {
|
||||||
lang: "browser".into(),
|
lang: "browser".into(),
|
||||||
show_avatars: true,
|
show_avatars: true,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
actor_id: "changeme_9826382637".into(),
|
actor_id: None,
|
||||||
bio: None,
|
bio: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
|
|
|
@ -106,7 +106,7 @@ mod tests {
|
||||||
lang: "browser".into(),
|
lang: "browser".into(),
|
||||||
show_avatars: true,
|
show_avatars: true,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
actor_id: "changeme_628763".into(),
|
actor_id: None,
|
||||||
bio: None,
|
bio: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
|
@ -134,7 +134,7 @@ mod tests {
|
||||||
lang: "browser".into(),
|
lang: "browser".into(),
|
||||||
show_avatars: true,
|
show_avatars: true,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
actor_id: "changeme_927389278".into(),
|
actor_id: None,
|
||||||
bio: None,
|
bio: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
|
@ -154,7 +154,7 @@ mod tests {
|
||||||
deleted: None,
|
deleted: None,
|
||||||
updated: None,
|
updated: None,
|
||||||
nsfw: false,
|
nsfw: false,
|
||||||
actor_id: "changeme_876238".into(),
|
actor_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
public_key: None,
|
public_key: None,
|
||||||
|
@ -182,7 +182,7 @@ mod tests {
|
||||||
embed_description: None,
|
embed_description: None,
|
||||||
embed_html: None,
|
embed_html: None,
|
||||||
thumbnail_url: None,
|
thumbnail_url: None,
|
||||||
ap_id: "http://fake.com".into(),
|
ap_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
published: None,
|
published: None,
|
||||||
};
|
};
|
||||||
|
@ -199,7 +199,7 @@ mod tests {
|
||||||
parent_id: None,
|
parent_id: None,
|
||||||
published: None,
|
published: None,
|
||||||
updated: None,
|
updated: None,
|
||||||
ap_id: "http://fake.com".into(),
|
ap_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
21
server/migrations/2020-08-25-132005_add_unique_ap_ids/down.sql
vendored
Normal file
21
server/migrations/2020-08-25-132005_add_unique_ap_ids/down.sql
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
alter table private_message alter column ap_id set not null;
|
||||||
|
alter table private_message alter column ap_id set default 'http://fake.com';
|
||||||
|
|
||||||
|
alter table post alter column ap_id set not null;
|
||||||
|
alter table post alter column ap_id set default 'http://fake.com';
|
||||||
|
|
||||||
|
alter table comment alter column ap_id set not null;
|
||||||
|
alter table comment alter column ap_id set default 'http://fake.com';
|
||||||
|
|
||||||
|
update private_message
|
||||||
|
set ap_id = 'http://fake.com'
|
||||||
|
where ap_id like 'changeme_%';
|
||||||
|
|
||||||
|
update post
|
||||||
|
set ap_id = 'http://fake.com'
|
||||||
|
where ap_id like 'changeme_%';
|
||||||
|
|
||||||
|
update comment
|
||||||
|
set ap_id = 'http://fake.com'
|
||||||
|
where ap_id like 'changeme_%';
|
49
server/migrations/2020-08-25-132005_add_unique_ap_ids/up.sql
vendored
Normal file
49
server/migrations/2020-08-25-132005_add_unique_ap_ids/up.sql
vendored
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
-- Add unique ap_id for private_message, comment, and post
|
||||||
|
|
||||||
|
-- Need to delete the possible dupes for ones that don't start with the fake one
|
||||||
|
delete from private_message a using (
|
||||||
|
select min(id) as id, ap_id
|
||||||
|
from private_message
|
||||||
|
group by ap_id having count(*) > 1
|
||||||
|
) b
|
||||||
|
where a.ap_id = b.ap_id
|
||||||
|
and a.id <> b.id;
|
||||||
|
|
||||||
|
delete from post a using (
|
||||||
|
select min(id) as id, ap_id
|
||||||
|
from post
|
||||||
|
group by ap_id having count(*) > 1
|
||||||
|
) b
|
||||||
|
where a.ap_id = b.ap_id
|
||||||
|
and a.id <> b.id;
|
||||||
|
|
||||||
|
delete from comment a using (
|
||||||
|
select min(id) as id, ap_id
|
||||||
|
from comment
|
||||||
|
group by ap_id having count(*) > 1
|
||||||
|
) b
|
||||||
|
where a.ap_id = b.ap_id
|
||||||
|
and a.id <> b.id;
|
||||||
|
|
||||||
|
-- Replacing the current default on the columns, to the unique one
|
||||||
|
update private_message
|
||||||
|
set ap_id = generate_unique_changeme()
|
||||||
|
where ap_id = 'http://fake.com';
|
||||||
|
|
||||||
|
update post
|
||||||
|
set ap_id = generate_unique_changeme()
|
||||||
|
where ap_id = 'http://fake.com';
|
||||||
|
|
||||||
|
update comment
|
||||||
|
set ap_id = generate_unique_changeme()
|
||||||
|
where ap_id = 'http://fake.com';
|
||||||
|
|
||||||
|
-- Add the unique indexes
|
||||||
|
alter table private_message alter column ap_id set not null;
|
||||||
|
alter table private_message alter column ap_id set default generate_unique_changeme();
|
||||||
|
|
||||||
|
alter table post alter column ap_id set not null;
|
||||||
|
alter table post alter column ap_id set default generate_unique_changeme();
|
||||||
|
|
||||||
|
alter table comment alter column ap_id set not null;
|
||||||
|
alter table comment alter column ap_id set default generate_unique_changeme();
|
|
@ -146,7 +146,7 @@ impl Perform for CreateComment {
|
||||||
read: None,
|
read: None,
|
||||||
published: None,
|
published: None,
|
||||||
updated: None,
|
updated: None,
|
||||||
ap_id: "http://fake.com".into(),
|
ap_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -274,7 +274,7 @@ impl Perform for CreateCommunity {
|
||||||
deleted: None,
|
deleted: None,
|
||||||
nsfw: data.nsfw,
|
nsfw: data.nsfw,
|
||||||
updated: None,
|
updated: None,
|
||||||
actor_id,
|
actor_id: Some(actor_id),
|
||||||
local: true,
|
local: true,
|
||||||
private_key: Some(keypair.private_key),
|
private_key: Some(keypair.private_key),
|
||||||
public_key: Some(keypair.public_key),
|
public_key: Some(keypair.public_key),
|
||||||
|
@ -368,7 +368,7 @@ impl Perform for EditCommunity {
|
||||||
deleted: Some(read_community.deleted),
|
deleted: Some(read_community.deleted),
|
||||||
nsfw: data.nsfw,
|
nsfw: data.nsfw,
|
||||||
updated: Some(naive_now()),
|
updated: Some(naive_now()),
|
||||||
actor_id: read_community.actor_id,
|
actor_id: Some(read_community.actor_id),
|
||||||
local: read_community.local,
|
local: read_community.local,
|
||||||
private_key: read_community.private_key,
|
private_key: read_community.private_key,
|
||||||
public_key: read_community.public_key,
|
public_key: read_community.public_key,
|
||||||
|
|
|
@ -187,7 +187,7 @@ impl Perform for CreatePost {
|
||||||
embed_description: iframely_description,
|
embed_description: iframely_description,
|
||||||
embed_html: iframely_html,
|
embed_html: iframely_html,
|
||||||
thumbnail_url: pictrs_thumbnail,
|
thumbnail_url: pictrs_thumbnail,
|
||||||
ap_id: "http://fake.com".into(),
|
ap_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
published: None,
|
published: None,
|
||||||
};
|
};
|
||||||
|
@ -518,7 +518,7 @@ impl Perform for EditPost {
|
||||||
embed_description: iframely_description,
|
embed_description: iframely_description,
|
||||||
embed_html: iframely_html,
|
embed_html: iframely_html,
|
||||||
thumbnail_url: pictrs_thumbnail,
|
thumbnail_url: pictrs_thumbnail,
|
||||||
ap_id: orig_post.ap_id,
|
ap_id: Some(orig_post.ap_id),
|
||||||
local: orig_post.local,
|
local: orig_post.local,
|
||||||
published: None,
|
published: None,
|
||||||
};
|
};
|
||||||
|
|
|
@ -410,7 +410,7 @@ impl Perform for Register {
|
||||||
lang: "browser".into(),
|
lang: "browser".into(),
|
||||||
show_avatars: true,
|
show_avatars: true,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
actor_id: make_apub_endpoint(EndpointType::User, &data.username).to_string(),
|
actor_id: Some(make_apub_endpoint(EndpointType::User, &data.username).to_string()),
|
||||||
bio: None,
|
bio: None,
|
||||||
local: true,
|
local: true,
|
||||||
private_key: Some(user_keypair.private_key),
|
private_key: Some(user_keypair.private_key),
|
||||||
|
@ -441,37 +441,38 @@ impl Perform for Register {
|
||||||
let main_community_keypair = generate_actor_keypair()?;
|
let main_community_keypair = generate_actor_keypair()?;
|
||||||
|
|
||||||
// Create the main community if it doesn't exist
|
// Create the main community if it doesn't exist
|
||||||
let main_community = match blocking(context.pool(), move |conn| Community::read(conn, 2))
|
let main_community =
|
||||||
.await?
|
match blocking(context.pool(), move |conn| Community::read(conn, 2)).await? {
|
||||||
{
|
Ok(c) => c,
|
||||||
Ok(c) => c,
|
Err(_e) => {
|
||||||
Err(_e) => {
|
let default_community_name = "main";
|
||||||
let default_community_name = "main";
|
let community_form = CommunityForm {
|
||||||
let community_form = CommunityForm {
|
name: default_community_name.to_string(),
|
||||||
name: default_community_name.to_string(),
|
title: "The Default Community".to_string(),
|
||||||
title: "The Default Community".to_string(),
|
description: Some("The Default Community".to_string()),
|
||||||
description: Some("The Default Community".to_string()),
|
category_id: 1,
|
||||||
category_id: 1,
|
nsfw: false,
|
||||||
nsfw: false,
|
creator_id: inserted_user.id,
|
||||||
creator_id: inserted_user.id,
|
removed: None,
|
||||||
removed: None,
|
deleted: None,
|
||||||
deleted: None,
|
updated: None,
|
||||||
updated: None,
|
actor_id: Some(
|
||||||
actor_id: make_apub_endpoint(EndpointType::Community, default_community_name).to_string(),
|
make_apub_endpoint(EndpointType::Community, default_community_name).to_string(),
|
||||||
local: true,
|
),
|
||||||
private_key: Some(main_community_keypair.private_key),
|
local: true,
|
||||||
public_key: Some(main_community_keypair.public_key),
|
private_key: Some(main_community_keypair.private_key),
|
||||||
last_refreshed_at: None,
|
public_key: Some(main_community_keypair.public_key),
|
||||||
published: None,
|
last_refreshed_at: None,
|
||||||
icon: None,
|
published: None,
|
||||||
banner: None,
|
icon: None,
|
||||||
};
|
banner: None,
|
||||||
blocking(context.pool(), move |conn| {
|
};
|
||||||
Community::create(conn, &community_form)
|
blocking(context.pool(), move |conn| {
|
||||||
})
|
Community::create(conn, &community_form)
|
||||||
.await??
|
})
|
||||||
}
|
.await??
|
||||||
};
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Sign them up for main community no matter what
|
// Sign them up for main community no matter what
|
||||||
let community_follower_form = CommunityFollowerForm {
|
let community_follower_form = CommunityFollowerForm {
|
||||||
|
@ -643,7 +644,7 @@ impl Perform for SaveUserSettings {
|
||||||
lang: data.lang.to_owned(),
|
lang: data.lang.to_owned(),
|
||||||
show_avatars: data.show_avatars,
|
show_avatars: data.show_avatars,
|
||||||
send_notifications_to_email: data.send_notifications_to_email,
|
send_notifications_to_email: data.send_notifications_to_email,
|
||||||
actor_id: read_user.actor_id,
|
actor_id: Some(read_user.actor_id),
|
||||||
bio,
|
bio,
|
||||||
local: read_user.local,
|
local: read_user.local,
|
||||||
private_key: read_user.private_key,
|
private_key: read_user.private_key,
|
||||||
|
@ -1218,7 +1219,7 @@ impl Perform for CreatePrivateMessage {
|
||||||
deleted: None,
|
deleted: None,
|
||||||
read: None,
|
read: None,
|
||||||
updated: None,
|
updated: None,
|
||||||
ap_id: "http://fake.com".into(),
|
ap_id: None,
|
||||||
local: true,
|
local: true,
|
||||||
published: None,
|
published: None,
|
||||||
};
|
};
|
||||||
|
|
|
@ -192,7 +192,7 @@ impl FromApub for CommentForm {
|
||||||
published: note.published().map(|u| u.to_owned().naive_local()),
|
published: note.published().map(|u| u.to_owned().naive_local()),
|
||||||
updated: note.updated().map(|u| u.to_owned().naive_local()),
|
updated: note.updated().map(|u| u.to_owned().naive_local()),
|
||||||
deleted: None,
|
deleted: None,
|
||||||
ap_id: check_actor_domain(note, expected_domain)?,
|
ap_id: Some(check_actor_domain(note, expected_domain)?),
|
||||||
local: false,
|
local: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,7 +403,7 @@ impl FromApub for CommunityForm {
|
||||||
updated: group.inner.updated().map(|u| u.to_owned().naive_local()),
|
updated: group.inner.updated().map(|u| u.to_owned().naive_local()),
|
||||||
deleted: None,
|
deleted: None,
|
||||||
nsfw: group.ext_one.sensitive,
|
nsfw: group.ext_one.sensitive,
|
||||||
actor_id: check_actor_domain(group, expected_domain)?,
|
actor_id: Some(check_actor_domain(group, expected_domain)?),
|
||||||
local: false,
|
local: false,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
public_key: Some(group.ext_two.to_owned().public_key.public_key_pem),
|
public_key: Some(group.ext_two.to_owned().public_key.public_key_pem),
|
||||||
|
|
|
@ -334,7 +334,7 @@ async fn fetch_remote_community(
|
||||||
for o in outbox_items {
|
for o in outbox_items {
|
||||||
let page = PageExt::from_any_base(o)?.context(location_info!())?;
|
let page = PageExt::from_any_base(o)?.context(location_info!())?;
|
||||||
let post = PostForm::from_apub(&page, context, None).await?;
|
let post = PostForm::from_apub(&page, context, None).await?;
|
||||||
let post_ap_id = post.ap_id.clone();
|
let post_ap_id = post.ap_id.as_ref().context(location_info!())?.clone();
|
||||||
// Check whether the post already exists in the local db
|
// Check whether the post already exists in the local db
|
||||||
let existing = blocking(context.pool(), move |conn| {
|
let existing = blocking(context.pool(), move |conn| {
|
||||||
Post::read_from_apub_id(conn, &post_ap_id)
|
Post::read_from_apub_id(conn, &post_ap_id)
|
||||||
|
|
|
@ -78,7 +78,7 @@ async fn receive_delete_post(
|
||||||
embed_description: post.embed_description,
|
embed_description: post.embed_description,
|
||||||
embed_html: post.embed_html,
|
embed_html: post.embed_html,
|
||||||
thumbnail_url: post.thumbnail_url,
|
thumbnail_url: post.thumbnail_url,
|
||||||
ap_id: post.ap_id,
|
ap_id: Some(post.ap_id),
|
||||||
local: post.local,
|
local: post.local,
|
||||||
published: None,
|
published: None,
|
||||||
};
|
};
|
||||||
|
@ -131,7 +131,7 @@ async fn receive_delete_comment(
|
||||||
read: None,
|
read: None,
|
||||||
published: None,
|
published: None,
|
||||||
updated: Some(naive_now()),
|
updated: Some(naive_now()),
|
||||||
ap_id: comment.ap_id,
|
ap_id: Some(comment.ap_id),
|
||||||
local: comment.local,
|
local: comment.local,
|
||||||
};
|
};
|
||||||
let comment_id = comment.id;
|
let comment_id = comment.id;
|
||||||
|
@ -175,7 +175,8 @@ async fn receive_delete_community(
|
||||||
|
|
||||||
let community_actor_id = CommunityForm::from_apub(&group, context, Some(user.actor_id()?))
|
let community_actor_id = CommunityForm::from_apub(&group, context, Some(user.actor_id()?))
|
||||||
.await?
|
.await?
|
||||||
.actor_id;
|
.actor_id
|
||||||
|
.context(location_info!())?;
|
||||||
|
|
||||||
let community = blocking(context.pool(), move |conn| {
|
let community = blocking(context.pool(), move |conn| {
|
||||||
Community::read_from_actor_id(conn, &community_actor_id)
|
Community::read_from_actor_id(conn, &community_actor_id)
|
||||||
|
@ -193,7 +194,7 @@ async fn receive_delete_community(
|
||||||
updated: Some(naive_now()),
|
updated: Some(naive_now()),
|
||||||
deleted: Some(true),
|
deleted: Some(true),
|
||||||
nsfw: community.nsfw,
|
nsfw: community.nsfw,
|
||||||
actor_id: community.actor_id,
|
actor_id: Some(community.actor_id),
|
||||||
local: community.local,
|
local: community.local,
|
||||||
private_key: community.private_key,
|
private_key: community.private_key,
|
||||||
public_key: community.public_key,
|
public_key: community.public_key,
|
||||||
|
|
|
@ -85,7 +85,7 @@ async fn receive_remove_post(
|
||||||
embed_description: post.embed_description,
|
embed_description: post.embed_description,
|
||||||
embed_html: post.embed_html,
|
embed_html: post.embed_html,
|
||||||
thumbnail_url: post.thumbnail_url,
|
thumbnail_url: post.thumbnail_url,
|
||||||
ap_id: post.ap_id,
|
ap_id: Some(post.ap_id),
|
||||||
local: post.local,
|
local: post.local,
|
||||||
published: None,
|
published: None,
|
||||||
};
|
};
|
||||||
|
@ -138,7 +138,7 @@ async fn receive_remove_comment(
|
||||||
read: None,
|
read: None,
|
||||||
published: None,
|
published: None,
|
||||||
updated: Some(naive_now()),
|
updated: Some(naive_now()),
|
||||||
ap_id: comment.ap_id,
|
ap_id: Some(comment.ap_id),
|
||||||
local: comment.local,
|
local: comment.local,
|
||||||
};
|
};
|
||||||
let comment_id = comment.id;
|
let comment_id = comment.id;
|
||||||
|
@ -182,7 +182,8 @@ async fn receive_remove_community(
|
||||||
|
|
||||||
let community_actor_id = CommunityForm::from_apub(&group, context, Some(mod_.actor_id()?))
|
let community_actor_id = CommunityForm::from_apub(&group, context, Some(mod_.actor_id()?))
|
||||||
.await?
|
.await?
|
||||||
.actor_id;
|
.actor_id
|
||||||
|
.context(location_info!())?;
|
||||||
|
|
||||||
let community = blocking(context.pool(), move |conn| {
|
let community = blocking(context.pool(), move |conn| {
|
||||||
Community::read_from_actor_id(conn, &community_actor_id)
|
Community::read_from_actor_id(conn, &community_actor_id)
|
||||||
|
@ -200,7 +201,7 @@ async fn receive_remove_community(
|
||||||
updated: Some(naive_now()),
|
updated: Some(naive_now()),
|
||||||
deleted: None,
|
deleted: None,
|
||||||
nsfw: community.nsfw,
|
nsfw: community.nsfw,
|
||||||
actor_id: community.actor_id,
|
actor_id: Some(community.actor_id),
|
||||||
local: community.local,
|
local: community.local,
|
||||||
private_key: community.private_key,
|
private_key: community.private_key,
|
||||||
public_key: community.public_key,
|
public_key: community.public_key,
|
||||||
|
|
|
@ -175,7 +175,7 @@ async fn receive_undo_delete_comment(
|
||||||
read: None,
|
read: None,
|
||||||
published: None,
|
published: None,
|
||||||
updated: Some(naive_now()),
|
updated: Some(naive_now()),
|
||||||
ap_id: comment.ap_id,
|
ap_id: Some(comment.ap_id),
|
||||||
local: comment.local,
|
local: comment.local,
|
||||||
};
|
};
|
||||||
let comment_id = comment.id;
|
let comment_id = comment.id;
|
||||||
|
@ -234,7 +234,7 @@ async fn receive_undo_remove_comment(
|
||||||
read: None,
|
read: None,
|
||||||
published: None,
|
published: None,
|
||||||
updated: Some(naive_now()),
|
updated: Some(naive_now()),
|
||||||
ap_id: comment.ap_id,
|
ap_id: Some(comment.ap_id),
|
||||||
local: comment.local,
|
local: comment.local,
|
||||||
};
|
};
|
||||||
let comment_id = comment.id;
|
let comment_id = comment.id;
|
||||||
|
@ -299,7 +299,7 @@ async fn receive_undo_delete_post(
|
||||||
embed_description: post.embed_description,
|
embed_description: post.embed_description,
|
||||||
embed_html: post.embed_html,
|
embed_html: post.embed_html,
|
||||||
thumbnail_url: post.thumbnail_url,
|
thumbnail_url: post.thumbnail_url,
|
||||||
ap_id: post.ap_id,
|
ap_id: Some(post.ap_id),
|
||||||
local: post.local,
|
local: post.local,
|
||||||
published: None,
|
published: None,
|
||||||
};
|
};
|
||||||
|
@ -359,7 +359,7 @@ async fn receive_undo_remove_post(
|
||||||
embed_description: post.embed_description,
|
embed_description: post.embed_description,
|
||||||
embed_html: post.embed_html,
|
embed_html: post.embed_html,
|
||||||
thumbnail_url: post.thumbnail_url,
|
thumbnail_url: post.thumbnail_url,
|
||||||
ap_id: post.ap_id,
|
ap_id: Some(post.ap_id),
|
||||||
local: post.local,
|
local: post.local,
|
||||||
published: None,
|
published: None,
|
||||||
};
|
};
|
||||||
|
@ -399,7 +399,8 @@ async fn receive_undo_delete_community(
|
||||||
|
|
||||||
let community_actor_id = CommunityForm::from_apub(&group, context, Some(user.actor_id()?))
|
let community_actor_id = CommunityForm::from_apub(&group, context, Some(user.actor_id()?))
|
||||||
.await?
|
.await?
|
||||||
.actor_id;
|
.actor_id
|
||||||
|
.context(location_info!())?;
|
||||||
|
|
||||||
let community = blocking(context.pool(), move |conn| {
|
let community = blocking(context.pool(), move |conn| {
|
||||||
Community::read_from_actor_id(conn, &community_actor_id)
|
Community::read_from_actor_id(conn, &community_actor_id)
|
||||||
|
@ -417,7 +418,7 @@ async fn receive_undo_delete_community(
|
||||||
updated: Some(naive_now()),
|
updated: Some(naive_now()),
|
||||||
deleted: Some(false),
|
deleted: Some(false),
|
||||||
nsfw: community.nsfw,
|
nsfw: community.nsfw,
|
||||||
actor_id: community.actor_id,
|
actor_id: Some(community.actor_id),
|
||||||
local: community.local,
|
local: community.local,
|
||||||
private_key: community.private_key,
|
private_key: community.private_key,
|
||||||
public_key: community.public_key,
|
public_key: community.public_key,
|
||||||
|
@ -464,7 +465,8 @@ async fn receive_undo_remove_community(
|
||||||
|
|
||||||
let community_actor_id = CommunityForm::from_apub(&group, context, Some(mod_.actor_id()?))
|
let community_actor_id = CommunityForm::from_apub(&group, context, Some(mod_.actor_id()?))
|
||||||
.await?
|
.await?
|
||||||
.actor_id;
|
.actor_id
|
||||||
|
.context(location_info!())?;
|
||||||
|
|
||||||
let community = blocking(context.pool(), move |conn| {
|
let community = blocking(context.pool(), move |conn| {
|
||||||
Community::read_from_actor_id(conn, &community_actor_id)
|
Community::read_from_actor_id(conn, &community_actor_id)
|
||||||
|
@ -482,7 +484,7 @@ async fn receive_undo_remove_community(
|
||||||
updated: Some(naive_now()),
|
updated: Some(naive_now()),
|
||||||
deleted: None,
|
deleted: None,
|
||||||
nsfw: community.nsfw,
|
nsfw: community.nsfw,
|
||||||
actor_id: community.actor_id,
|
actor_id: Some(community.actor_id),
|
||||||
local: community.local,
|
local: community.local,
|
||||||
private_key: community.private_key,
|
private_key: community.private_key,
|
||||||
public_key: community.public_key,
|
public_key: community.public_key,
|
||||||
|
|
|
@ -175,7 +175,11 @@ async fn receive_update_private_message(
|
||||||
let domain = Some(update.id_unchecked().context(location_info!())?.to_owned());
|
let domain = Some(update.id_unchecked().context(location_info!())?.to_owned());
|
||||||
let private_message_form = PrivateMessageForm::from_apub(¬e, context, domain).await?;
|
let private_message_form = PrivateMessageForm::from_apub(¬e, context, domain).await?;
|
||||||
|
|
||||||
let private_message_ap_id = private_message_form.ap_id.clone();
|
let private_message_ap_id = private_message_form
|
||||||
|
.ap_id
|
||||||
|
.as_ref()
|
||||||
|
.context(location_info!())?
|
||||||
|
.clone();
|
||||||
let private_message = blocking(&context.pool(), move |conn| {
|
let private_message = blocking(&context.pool(), move |conn| {
|
||||||
PrivateMessage::read_from_apub_id(conn, &private_message_ap_id)
|
PrivateMessage::read_from_apub_id(conn, &private_message_ap_id)
|
||||||
})
|
})
|
||||||
|
@ -224,7 +228,7 @@ async fn receive_delete_private_message(
|
||||||
let domain = Some(delete.id_unchecked().context(location_info!())?.to_owned());
|
let domain = Some(delete.id_unchecked().context(location_info!())?.to_owned());
|
||||||
let private_message_form = PrivateMessageForm::from_apub(¬e, context, domain).await?;
|
let private_message_form = PrivateMessageForm::from_apub(¬e, context, domain).await?;
|
||||||
|
|
||||||
let private_message_ap_id = private_message_form.ap_id;
|
let private_message_ap_id = private_message_form.ap_id.context(location_info!())?;
|
||||||
let private_message = blocking(&context.pool(), move |conn| {
|
let private_message = blocking(&context.pool(), move |conn| {
|
||||||
PrivateMessage::read_from_apub_id(conn, &private_message_ap_id)
|
PrivateMessage::read_from_apub_id(conn, &private_message_ap_id)
|
||||||
})
|
})
|
||||||
|
@ -236,7 +240,7 @@ async fn receive_delete_private_message(
|
||||||
creator_id: private_message.creator_id,
|
creator_id: private_message.creator_id,
|
||||||
deleted: Some(true),
|
deleted: Some(true),
|
||||||
read: None,
|
read: None,
|
||||||
ap_id: private_message.ap_id,
|
ap_id: Some(private_message.ap_id),
|
||||||
local: private_message.local,
|
local: private_message.local,
|
||||||
published: None,
|
published: None,
|
||||||
updated: Some(naive_now()),
|
updated: Some(naive_now()),
|
||||||
|
@ -287,7 +291,11 @@ async fn receive_undo_delete_private_message(
|
||||||
let domain = Some(undo.id_unchecked().context(location_info!())?.to_owned());
|
let domain = Some(undo.id_unchecked().context(location_info!())?.to_owned());
|
||||||
let private_message = PrivateMessageForm::from_apub(¬e, context, domain).await?;
|
let private_message = PrivateMessageForm::from_apub(¬e, context, domain).await?;
|
||||||
|
|
||||||
let private_message_ap_id = private_message.ap_id.clone();
|
let private_message_ap_id = private_message
|
||||||
|
.ap_id
|
||||||
|
.as_ref()
|
||||||
|
.context(location_info!())?
|
||||||
|
.clone();
|
||||||
let private_message_id = blocking(&context.pool(), move |conn| {
|
let private_message_id = blocking(&context.pool(), move |conn| {
|
||||||
PrivateMessage::read_from_apub_id(conn, &private_message_ap_id).map(|pm| pm.id)
|
PrivateMessage::read_from_apub_id(conn, &private_message_ap_id).map(|pm| pm.id)
|
||||||
})
|
})
|
||||||
|
|
|
@ -289,7 +289,7 @@ impl FromApub for PostForm {
|
||||||
embed_description: embed.description,
|
embed_description: embed.description,
|
||||||
embed_html: embed.html,
|
embed_html: embed.html,
|
||||||
thumbnail_url,
|
thumbnail_url,
|
||||||
ap_id: check_actor_domain(page, expected_domain)?,
|
ap_id: Some(check_actor_domain(page, expected_domain)?),
|
||||||
local: false,
|
local: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ impl FromApub for PrivateMessageForm {
|
||||||
updated: note.updated().map(|u| u.to_owned().naive_local()),
|
updated: note.updated().map(|u| u.to_owned().naive_local()),
|
||||||
deleted: None,
|
deleted: None,
|
||||||
read: None,
|
read: None,
|
||||||
ap_id: check_actor_domain(note, expected_domain)?,
|
ap_id: Some(check_actor_domain(note, expected_domain)?),
|
||||||
local: false,
|
local: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,7 +269,7 @@ impl FromApub for UserForm {
|
||||||
show_avatars: false,
|
show_avatars: false,
|
||||||
send_notifications_to_email: false,
|
send_notifications_to_email: false,
|
||||||
matrix_user_id: None,
|
matrix_user_id: None,
|
||||||
actor_id: check_actor_domain(person, expected_domain)?,
|
actor_id: Some(check_actor_domain(person, expected_domain)?),
|
||||||
bio,
|
bio,
|
||||||
local: false,
|
local: false,
|
||||||
private_key: None,
|
private_key: None,
|
||||||
|
|
|
@ -67,7 +67,7 @@ fn user_updates_2020_04_02(conn: &PgConnection) -> Result<(), LemmyError> {
|
||||||
lang: cuser.lang.to_owned(),
|
lang: cuser.lang.to_owned(),
|
||||||
show_avatars: cuser.show_avatars,
|
show_avatars: cuser.show_avatars,
|
||||||
send_notifications_to_email: cuser.send_notifications_to_email,
|
send_notifications_to_email: cuser.send_notifications_to_email,
|
||||||
actor_id: make_apub_endpoint(EndpointType::User, &cuser.name).to_string(),
|
actor_id: Some(make_apub_endpoint(EndpointType::User, &cuser.name).to_string()),
|
||||||
bio: cuser.bio.to_owned(),
|
bio: cuser.bio.to_owned(),
|
||||||
local: cuser.local,
|
local: cuser.local,
|
||||||
private_key: Some(keypair.private_key),
|
private_key: Some(keypair.private_key),
|
||||||
|
@ -111,7 +111,7 @@ fn community_updates_2020_04_02(conn: &PgConnection) -> Result<(), LemmyError> {
|
||||||
deleted: None,
|
deleted: None,
|
||||||
nsfw: ccommunity.nsfw,
|
nsfw: ccommunity.nsfw,
|
||||||
updated: None,
|
updated: None,
|
||||||
actor_id: make_apub_endpoint(EndpointType::Community, &ccommunity.name).to_string(),
|
actor_id: Some(make_apub_endpoint(EndpointType::Community, &ccommunity.name).to_string()),
|
||||||
local: ccommunity.local,
|
local: ccommunity.local,
|
||||||
private_key: Some(keypair.private_key),
|
private_key: Some(keypair.private_key),
|
||||||
public_key: Some(keypair.public_key),
|
public_key: Some(keypair.public_key),
|
||||||
|
@ -138,7 +138,7 @@ fn post_updates_2020_04_03(conn: &PgConnection) -> Result<(), LemmyError> {
|
||||||
|
|
||||||
// Update the ap_id
|
// Update the ap_id
|
||||||
let incorrect_posts = post
|
let incorrect_posts = post
|
||||||
.filter(ap_id.eq("http://fake.com"))
|
.filter(ap_id.eq("changeme_%"))
|
||||||
.filter(local.eq(true))
|
.filter(local.eq(true))
|
||||||
.load::<Post>(conn)?;
|
.load::<Post>(conn)?;
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ fn comment_updates_2020_04_03(conn: &PgConnection) -> Result<(), LemmyError> {
|
||||||
|
|
||||||
// Update the ap_id
|
// Update the ap_id
|
||||||
let incorrect_comments = comment
|
let incorrect_comments = comment
|
||||||
.filter(ap_id.eq("http://fake.com"))
|
.filter(ap_id.eq("changeme_%"))
|
||||||
.filter(local.eq(true))
|
.filter(local.eq(true))
|
||||||
.load::<Comment>(conn)?;
|
.load::<Comment>(conn)?;
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ fn private_message_updates_2020_05_05(conn: &PgConnection) -> Result<(), LemmyEr
|
||||||
|
|
||||||
// Update the ap_id
|
// Update the ap_id
|
||||||
let incorrect_pms = private_message
|
let incorrect_pms = private_message
|
||||||
.filter(ap_id.eq("http://fake.com"))
|
.filter(ap_id.eq("changeme_%"))
|
||||||
.filter(local.eq(true))
|
.filter(local.eq(true))
|
||||||
.load::<PrivateMessage>(conn)?;
|
.load::<PrivateMessage>(conn)?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue