mirror of
https://github.com/LemmyNet/lemmy
synced 2024-11-24 13:33:05 +00:00
Remove individual user/community inboxes (#5124)
* Remove endpoints for individual community/user inboxes fixes #4147 fixes #3928 * Remove shared_inbox_url columns * fmt
This commit is contained in:
parent
920ffe1803
commit
f05afead02
24 changed files with 100 additions and 148 deletions
|
@ -50,7 +50,10 @@ use lemmy_utils::{
|
|||
email::{send_email, translations::Lang},
|
||||
error::{LemmyError, LemmyErrorExt, LemmyErrorType, LemmyResult},
|
||||
rate_limit::{ActionType, BucketConfig},
|
||||
settings::structs::{PictrsImageMode, Settings},
|
||||
settings::{
|
||||
structs::{PictrsImageMode, Settings},
|
||||
SETTINGS,
|
||||
},
|
||||
utils::{
|
||||
markdown::{image_links::markdown_rewrite_image_links, markdown_check_for_blocked_urls},
|
||||
slurs::{build_slur_regex, remove_slurs},
|
||||
|
@ -973,12 +976,8 @@ pub fn generate_followers_url(actor_id: &DbUrl) -> Result<DbUrl, ParseError> {
|
|||
Ok(Url::parse(&format!("{actor_id}/followers"))?.into())
|
||||
}
|
||||
|
||||
pub fn generate_inbox_url(actor_id: &DbUrl) -> Result<DbUrl, ParseError> {
|
||||
Ok(Url::parse(&format!("{actor_id}/inbox"))?.into())
|
||||
}
|
||||
|
||||
pub fn generate_shared_inbox_url(settings: &Settings) -> LemmyResult<DbUrl> {
|
||||
let url = format!("{}/inbox", settings.get_protocol_and_hostname());
|
||||
pub fn generate_inbox_url() -> LemmyResult<DbUrl> {
|
||||
let url = format!("{}/inbox", SETTINGS.get_protocol_and_hostname());
|
||||
Ok(Url::parse(&url)?.into())
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ use lemmy_api_common::{
|
|||
generate_followers_url,
|
||||
generate_inbox_url,
|
||||
generate_local_apub_endpoint,
|
||||
generate_shared_inbox_url,
|
||||
get_url_blocklist,
|
||||
is_admin,
|
||||
local_site_to_slur_regex,
|
||||
|
@ -96,8 +95,7 @@ pub async fn create_community(
|
|||
actor_id: Some(community_actor_id.clone()),
|
||||
private_key: Some(keypair.private_key),
|
||||
followers_url: Some(generate_followers_url(&community_actor_id)?),
|
||||
inbox_url: Some(generate_inbox_url(&community_actor_id)?),
|
||||
shared_inbox_url: Some(generate_shared_inbox_url(context.settings())?),
|
||||
inbox_url: Some(generate_inbox_url()?),
|
||||
posting_restricted_to_mods: data.posting_restricted_to_mods,
|
||||
visibility: data.visibility,
|
||||
..CommunityInsertForm::new(
|
||||
|
|
|
@ -6,7 +6,7 @@ use lemmy_api_common::{
|
|||
context::LemmyContext,
|
||||
site::{CreateSite, SiteResponse},
|
||||
utils::{
|
||||
generate_shared_inbox_url,
|
||||
generate_inbox_url,
|
||||
get_url_blocklist,
|
||||
is_admin,
|
||||
local_site_rate_limit_to_rate_limit_config,
|
||||
|
@ -55,7 +55,7 @@ pub async fn create_site(
|
|||
validate_create_payload(&local_site, &data)?;
|
||||
|
||||
let actor_id: DbUrl = Url::parse(&context.settings().get_protocol_and_hostname())?.into();
|
||||
let inbox_url = Some(generate_shared_inbox_url(context.settings())?);
|
||||
let inbox_url = Some(generate_inbox_url()?);
|
||||
let keypair = generate_actor_keypair()?;
|
||||
|
||||
let slur_regex = local_site_to_slur_regex(&local_site);
|
||||
|
|
|
@ -11,7 +11,6 @@ use lemmy_api_common::{
|
|||
check_user_valid,
|
||||
generate_inbox_url,
|
||||
generate_local_apub_endpoint,
|
||||
generate_shared_inbox_url,
|
||||
honeypot_check,
|
||||
local_site_to_slur_regex,
|
||||
password_length_check,
|
||||
|
@ -418,8 +417,7 @@ async fn create_person(
|
|||
// Register the new person
|
||||
let person_form = PersonInsertForm {
|
||||
actor_id: Some(actor_id.clone()),
|
||||
inbox_url: Some(generate_inbox_url(&actor_id)?),
|
||||
shared_inbox_url: Some(generate_shared_inbox_url(context.settings())?),
|
||||
inbox_url: Some(generate_inbox_url()?),
|
||||
private_key: Some(actor_keypair.private_key),
|
||||
..PersonInsertForm::new(username.clone(), actor_keypair.public_key, instance_id)
|
||||
};
|
||||
|
|
|
@ -106,8 +106,14 @@ impl ActivityHandler for UpdateCommunity {
|
|||
icon: Some(self.object.icon.map(|i| i.url.into())),
|
||||
banner: Some(self.object.image.map(|i| i.url.into())),
|
||||
followers_url: self.object.followers.map(Into::into),
|
||||
inbox_url: Some(self.object.inbox.into()),
|
||||
shared_inbox_url: Some(self.object.endpoints.map(|e| e.shared_inbox.into())),
|
||||
inbox_url: Some(
|
||||
self
|
||||
.object
|
||||
.endpoints
|
||||
.map(|e| e.shared_inbox)
|
||||
.unwrap_or(self.object.inbox)
|
||||
.into(),
|
||||
),
|
||||
moderators_url: self.object.attributed_to.map(Into::into),
|
||||
posting_restricted_to_mods: self.object.posting_restricted_to_mods,
|
||||
featured_url: self.object.featured.map(Into::into),
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
use crate::{
|
||||
activity_lists::GroupInboxActivities,
|
||||
collections::{
|
||||
community_featured::ApubCommunityFeatured,
|
||||
community_follower::ApubCommunityFollower,
|
||||
|
@ -7,15 +6,13 @@ use crate::{
|
|||
community_outbox::ApubCommunityOutbox,
|
||||
},
|
||||
http::{check_community_public, create_apub_response, create_apub_tombstone_response},
|
||||
objects::{community::ApubCommunity, person::ApubPerson},
|
||||
objects::community::ApubCommunity,
|
||||
};
|
||||
use activitypub_federation::{
|
||||
actix_web::inbox::receive_activity,
|
||||
config::Data,
|
||||
protocol::context::WithContext,
|
||||
traits::{Collection, Object},
|
||||
};
|
||||
use actix_web::{web, web::Bytes, HttpRequest, HttpResponse};
|
||||
use actix_web::{web, HttpResponse};
|
||||
use lemmy_api_common::context::LemmyContext;
|
||||
use lemmy_db_schema::{source::community::Community, traits::ApubActor};
|
||||
use lemmy_utils::{error::LemmyResult, LemmyErrorType};
|
||||
|
@ -47,19 +44,6 @@ pub(crate) async fn get_apub_community_http(
|
|||
create_apub_response(&apub)
|
||||
}
|
||||
|
||||
/// Handler for all incoming receive to community inboxes.
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn community_inbox(
|
||||
request: HttpRequest,
|
||||
body: Bytes,
|
||||
data: Data<LemmyContext>,
|
||||
) -> LemmyResult<HttpResponse> {
|
||||
receive_activity::<WithContext<GroupInboxActivities>, ApubPerson, LemmyContext>(
|
||||
request, body, &data,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
/// Returns an empty followers collection, only populating the size (for privacy).
|
||||
pub(crate) async fn get_apub_community_followers(
|
||||
info: web::Path<CommunityQuery>,
|
||||
|
|
|
@ -1,17 +1,10 @@
|
|||
use crate::{
|
||||
activity_lists::PersonInboxActivities,
|
||||
fetcher::user_or_community::UserOrCommunity,
|
||||
http::{create_apub_response, create_apub_tombstone_response},
|
||||
objects::person::ApubPerson,
|
||||
protocol::collections::empty_outbox::EmptyOutbox,
|
||||
};
|
||||
use activitypub_federation::{
|
||||
actix_web::inbox::receive_activity,
|
||||
config::Data,
|
||||
protocol::context::WithContext,
|
||||
traits::Object,
|
||||
};
|
||||
use actix_web::{web, web::Bytes, HttpRequest, HttpResponse};
|
||||
use activitypub_federation::{config::Data, traits::Object};
|
||||
use actix_web::{web, HttpResponse};
|
||||
use lemmy_api_common::{context::LemmyContext, utils::generate_outbox_url};
|
||||
use lemmy_db_schema::{source::person::Person, traits::ApubActor};
|
||||
use lemmy_utils::{error::LemmyResult, LemmyErrorType};
|
||||
|
@ -44,18 +37,6 @@ pub(crate) async fn get_apub_person_http(
|
|||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn person_inbox(
|
||||
request: HttpRequest,
|
||||
body: Bytes,
|
||||
data: Data<LemmyContext>,
|
||||
) -> LemmyResult<HttpResponse> {
|
||||
receive_activity::<WithContext<PersonInboxActivities>, UserOrCommunity, LemmyContext>(
|
||||
request, body, &data,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub(crate) async fn get_apub_person_outbox(
|
||||
info: web::Path<PersonQuery>,
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use crate::http::{
|
||||
comment::get_apub_comment,
|
||||
community::{
|
||||
community_inbox,
|
||||
get_apub_community_featured,
|
||||
get_apub_community_followers,
|
||||
get_apub_community_http,
|
||||
|
@ -9,7 +8,7 @@ use crate::http::{
|
|||
get_apub_community_outbox,
|
||||
},
|
||||
get_activity,
|
||||
person::{get_apub_person_http, get_apub_person_outbox, person_inbox},
|
||||
person::{get_apub_person_http, get_apub_person_outbox},
|
||||
post::get_apub_post,
|
||||
shared_inbox,
|
||||
site::{get_apub_site_http, get_apub_site_outbox},
|
||||
|
@ -56,8 +55,6 @@ pub fn config(cfg: &mut web::ServiceConfig) {
|
|||
cfg.service(
|
||||
web::scope("")
|
||||
.guard(InboxRequestGuard)
|
||||
.route("/c/{community_name}/inbox", web::post().to(community_inbox))
|
||||
.route("/u/{user_name}/inbox", web::post().to(person_inbox))
|
||||
.route("/inbox", web::post().to(shared_inbox)),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::{
|
|||
local_site_data_cached,
|
||||
objects::{instance::fetch_instance_actor_for_object, read_from_string_or_source_opt},
|
||||
protocol::{
|
||||
objects::{group::Group, Endpoints, LanguageTag},
|
||||
objects::{group::Group, LanguageTag},
|
||||
ImageObject,
|
||||
Source,
|
||||
},
|
||||
|
@ -116,9 +116,7 @@ impl Object for ApubCommunity {
|
|||
inbox: self.inbox_url.clone().into(),
|
||||
outbox: generate_outbox_url(&self.actor_id)?.into(),
|
||||
followers: self.followers_url.clone().map(Into::into),
|
||||
endpoints: self.shared_inbox_url.clone().map(|s| Endpoints {
|
||||
shared_inbox: s.into(),
|
||||
}),
|
||||
endpoints: None,
|
||||
public_key: self.public_key(),
|
||||
language,
|
||||
published: Some(self.published),
|
||||
|
@ -165,8 +163,13 @@ impl Object for ApubCommunity {
|
|||
banner,
|
||||
description,
|
||||
followers_url: group.followers.clone().map(Into::into),
|
||||
inbox_url: Some(group.inbox.into()),
|
||||
shared_inbox_url: group.endpoints.map(|e| e.shared_inbox.into()),
|
||||
inbox_url: Some(
|
||||
group
|
||||
.endpoints
|
||||
.map(|e| e.shared_inbox)
|
||||
.unwrap_or(group.inbox)
|
||||
.into(),
|
||||
),
|
||||
moderators_url: group.attributed_to.clone().map(Into::into),
|
||||
posting_restricted_to_mods: group.posting_restricted_to_mods,
|
||||
featured_url: group.featured.clone().map(Into::into),
|
||||
|
@ -225,7 +228,7 @@ impl Actor for ApubCommunity {
|
|||
}
|
||||
|
||||
fn shared_inbox(&self) -> Option<Url> {
|
||||
self.shared_inbox_url.clone().map(Into::into)
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,10 +6,7 @@ use crate::{
|
|||
local_site_data_cached,
|
||||
objects::{instance::fetch_instance_actor_for_object, read_from_string_or_source_opt},
|
||||
protocol::{
|
||||
objects::{
|
||||
person::{Person, UserTypes},
|
||||
Endpoints,
|
||||
},
|
||||
objects::person::{Person, UserTypes},
|
||||
ImageObject,
|
||||
Source,
|
||||
},
|
||||
|
@ -118,9 +115,7 @@ impl Object for ApubPerson {
|
|||
matrix_user_id: self.matrix_user_id.clone(),
|
||||
published: Some(self.published),
|
||||
outbox: generate_outbox_url(&self.actor_id)?.into(),
|
||||
endpoints: self.shared_inbox_url.clone().map(|s| Endpoints {
|
||||
shared_inbox: s.into(),
|
||||
}),
|
||||
endpoints: None,
|
||||
public_key: self.public_key(),
|
||||
updated: self.updated,
|
||||
inbox: self.inbox_url.clone().into(),
|
||||
|
@ -182,8 +177,13 @@ impl Object for ApubPerson {
|
|||
private_key: None,
|
||||
public_key: person.public_key.public_key_pem,
|
||||
last_refreshed_at: Some(naive_now()),
|
||||
inbox_url: Some(person.inbox.into()),
|
||||
shared_inbox_url: person.endpoints.map(|e| e.shared_inbox.into()),
|
||||
inbox_url: Some(
|
||||
person
|
||||
.endpoints
|
||||
.map(|e| e.shared_inbox)
|
||||
.unwrap_or(person.inbox)
|
||||
.into(),
|
||||
),
|
||||
matrix_user_id: person.matrix_user_id,
|
||||
instance_id,
|
||||
};
|
||||
|
@ -211,7 +211,7 @@ impl Actor for ApubPerson {
|
|||
}
|
||||
|
||||
fn shared_inbox(&self) -> Option<Url> {
|
||||
self.shared_inbox_url.clone().map(Into::into)
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -523,7 +523,6 @@ mod tests {
|
|||
banner: None,
|
||||
followers_url: inserted_community.followers_url.clone(),
|
||||
inbox_url: inserted_community.inbox_url.clone(),
|
||||
shared_inbox_url: None,
|
||||
moderators_url: None,
|
||||
featured_url: None,
|
||||
hidden: false,
|
||||
|
|
|
@ -279,7 +279,6 @@ mod tests {
|
|||
public_key: "pubkey".to_owned(),
|
||||
last_refreshed_at: inserted_person.published,
|
||||
inbox_url: inserted_person.inbox_url.clone(),
|
||||
shared_inbox_url: None,
|
||||
matrix_user_id: None,
|
||||
ban_expires: None,
|
||||
instance_id: inserted_instance.id,
|
||||
|
|
|
@ -188,8 +188,6 @@ diesel::table! {
|
|||
followers_url -> Nullable<Varchar>,
|
||||
#[max_length = 255]
|
||||
inbox_url -> Varchar,
|
||||
#[max_length = 255]
|
||||
shared_inbox_url -> Nullable<Varchar>,
|
||||
hidden -> Bool,
|
||||
posting_restricted_to_mods -> Bool,
|
||||
instance_id -> Int4,
|
||||
|
@ -686,8 +684,6 @@ diesel::table! {
|
|||
deleted -> Bool,
|
||||
#[max_length = 255]
|
||||
inbox_url -> Varchar,
|
||||
#[max_length = 255]
|
||||
shared_inbox_url -> Nullable<Varchar>,
|
||||
matrix_user_id -> Nullable<Text>,
|
||||
bot_account -> Bool,
|
||||
ban_expires -> Nullable<Timestamptz>,
|
||||
|
|
|
@ -54,8 +54,6 @@ pub struct Community {
|
|||
#[cfg_attr(feature = "full", ts(skip))]
|
||||
#[serde(skip, default = "placeholder_apub_url")]
|
||||
pub inbox_url: DbUrl,
|
||||
#[serde(skip)]
|
||||
pub shared_inbox_url: Option<DbUrl>,
|
||||
/// Whether the community is hidden.
|
||||
pub hidden: bool,
|
||||
/// Whether posting is restricted to mods only.
|
||||
|
@ -107,8 +105,6 @@ pub struct CommunityInsertForm {
|
|||
#[new(default)]
|
||||
pub inbox_url: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub shared_inbox_url: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub moderators_url: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub featured_url: Option<DbUrl>,
|
||||
|
@ -140,7 +136,6 @@ pub struct CommunityUpdateForm {
|
|||
pub banner: Option<Option<DbUrl>>,
|
||||
pub followers_url: Option<DbUrl>,
|
||||
pub inbox_url: Option<DbUrl>,
|
||||
pub shared_inbox_url: Option<Option<DbUrl>>,
|
||||
pub moderators_url: Option<DbUrl>,
|
||||
pub featured_url: Option<DbUrl>,
|
||||
pub hidden: Option<bool>,
|
||||
|
|
|
@ -48,8 +48,6 @@ pub struct Person {
|
|||
#[cfg_attr(feature = "full", ts(skip))]
|
||||
#[serde(skip, default = "placeholder_apub_url")]
|
||||
pub inbox_url: DbUrl,
|
||||
#[serde(skip)]
|
||||
pub shared_inbox_url: Option<DbUrl>,
|
||||
/// A matrix id, usually given an @person:matrix.org
|
||||
pub matrix_user_id: Option<String>,
|
||||
/// Whether the person is a bot account.
|
||||
|
@ -93,8 +91,6 @@ pub struct PersonInsertForm {
|
|||
#[new(default)]
|
||||
pub inbox_url: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub shared_inbox_url: Option<DbUrl>,
|
||||
#[new(default)]
|
||||
pub matrix_user_id: Option<String>,
|
||||
#[new(default)]
|
||||
pub bot_account: Option<bool>,
|
||||
|
@ -119,7 +115,6 @@ pub struct PersonUpdateForm {
|
|||
pub banner: Option<Option<DbUrl>>,
|
||||
pub deleted: Option<bool>,
|
||||
pub inbox_url: Option<DbUrl>,
|
||||
pub shared_inbox_url: Option<Option<DbUrl>>,
|
||||
pub matrix_user_id: Option<Option<String>>,
|
||||
pub bot_account: Option<bool>,
|
||||
pub ban_expires: Option<Option<DateTime<Utc>>>,
|
||||
|
|
|
@ -402,7 +402,6 @@ mod tests {
|
|||
last_refreshed_at: inserted_community.last_refreshed_at,
|
||||
followers_url: inserted_community.followers_url,
|
||||
inbox_url: inserted_community.inbox_url,
|
||||
shared_inbox_url: inserted_community.shared_inbox_url,
|
||||
moderators_url: inserted_community.moderators_url,
|
||||
featured_url: inserted_community.featured_url,
|
||||
instance_id: inserted_instance.id,
|
||||
|
@ -423,7 +422,6 @@ mod tests {
|
|||
banner: None,
|
||||
updated: None,
|
||||
inbox_url: inserted_jessica.inbox_url.clone(),
|
||||
shared_inbox_url: None,
|
||||
matrix_user_id: None,
|
||||
ban_expires: None,
|
||||
instance_id: inserted_instance.id,
|
||||
|
@ -446,7 +444,6 @@ mod tests {
|
|||
banner: None,
|
||||
updated: None,
|
||||
inbox_url: inserted_timmy.inbox_url.clone(),
|
||||
shared_inbox_url: None,
|
||||
matrix_user_id: None,
|
||||
ban_expires: None,
|
||||
instance_id: inserted_instance.id,
|
||||
|
@ -488,7 +485,6 @@ mod tests {
|
|||
banner: None,
|
||||
updated: None,
|
||||
inbox_url: inserted_sara.inbox_url.clone(),
|
||||
shared_inbox_url: None,
|
||||
matrix_user_id: None,
|
||||
ban_expires: None,
|
||||
instance_id: inserted_instance.id,
|
||||
|
@ -550,7 +546,6 @@ mod tests {
|
|||
private_key: inserted_timmy.private_key.clone(),
|
||||
public_key: inserted_timmy.public_key.clone(),
|
||||
last_refreshed_at: inserted_timmy.last_refreshed_at,
|
||||
shared_inbox_url: None,
|
||||
matrix_user_id: None,
|
||||
ban_expires: None,
|
||||
instance_id: inserted_instance.id,
|
||||
|
|
|
@ -1049,7 +1049,6 @@ mod tests {
|
|||
banner: None,
|
||||
updated: None,
|
||||
inbox_url: data.timmy_local_user_view.person.inbox_url.clone(),
|
||||
shared_inbox_url: None,
|
||||
matrix_user_id: None,
|
||||
ban_expires: None,
|
||||
instance_id: data.inserted_instance.id,
|
||||
|
@ -1105,7 +1104,6 @@ mod tests {
|
|||
last_refreshed_at: data.inserted_community.last_refreshed_at,
|
||||
followers_url: data.inserted_community.followers_url.clone(),
|
||||
inbox_url: data.inserted_community.inbox_url.clone(),
|
||||
shared_inbox_url: data.inserted_community.shared_inbox_url.clone(),
|
||||
moderators_url: data.inserted_community.moderators_url.clone(),
|
||||
featured_url: data.inserted_community.featured_url.clone(),
|
||||
visibility: CommunityVisibility::Public,
|
||||
|
|
|
@ -1812,7 +1812,6 @@ mod tests {
|
|||
banner: None,
|
||||
updated: None,
|
||||
inbox_url: inserted_person.inbox_url.clone(),
|
||||
shared_inbox_url: None,
|
||||
matrix_user_id: None,
|
||||
ban_expires: None,
|
||||
instance_id: data.inserted_instance.id,
|
||||
|
@ -1847,7 +1846,6 @@ mod tests {
|
|||
last_refreshed_at: inserted_community.last_refreshed_at,
|
||||
followers_url: inserted_community.followers_url.clone(),
|
||||
inbox_url: inserted_community.inbox_url.clone(),
|
||||
shared_inbox_url: inserted_community.shared_inbox_url.clone(),
|
||||
moderators_url: inserted_community.moderators_url.clone(),
|
||||
featured_url: inserted_community.featured_url.clone(),
|
||||
visibility: CommunityVisibility::Public,
|
||||
|
|
|
@ -258,7 +258,6 @@ mod tests {
|
|||
banner: None,
|
||||
updated: None,
|
||||
inbox_url: inserted_sara_person.inbox_url.clone(),
|
||||
shared_inbox_url: None,
|
||||
matrix_user_id: None,
|
||||
instance_id: inserted_instance.id,
|
||||
private_key: inserted_sara_person.private_key,
|
||||
|
@ -328,7 +327,6 @@ mod tests {
|
|||
banner: None,
|
||||
updated: None,
|
||||
inbox_url: inserted_timmy_person.inbox_url.clone(),
|
||||
shared_inbox_url: None,
|
||||
matrix_user_id: None,
|
||||
instance_id: inserted_instance.id,
|
||||
private_key: inserted_timmy_person.private_key,
|
||||
|
|
|
@ -10,7 +10,7 @@ use diesel_async::RunQueryDsl;
|
|||
use lemmy_db_schema::{
|
||||
newtypes::{CommunityId, DbUrl, InstanceId, PersonId},
|
||||
schema::{community, community_follower, person},
|
||||
utils::{functions::coalesce, get_conn, DbPool},
|
||||
utils::{get_conn, DbPool},
|
||||
};
|
||||
|
||||
impl CommunityFollowerView {
|
||||
|
@ -37,10 +37,7 @@ impl CommunityFollowerView {
|
|||
// local-person+remote-community or remote-person+local-community
|
||||
.filter(not(person::local))
|
||||
.filter(community_follower::published.gt(published_since.naive_utc()))
|
||||
.select((
|
||||
community::id,
|
||||
coalesce(person::shared_inbox_url, person::inbox_url),
|
||||
))
|
||||
.select((community::id, person::inbox_url))
|
||||
.distinct() // only need each community_id, inbox combination once
|
||||
.load::<(CommunityId, DbUrl)>(conn)
|
||||
.await
|
||||
|
@ -54,7 +51,7 @@ impl CommunityFollowerView {
|
|||
.filter(community_follower::community_id.eq(community_id))
|
||||
.filter(not(person::local))
|
||||
.inner_join(person::table)
|
||||
.select(coalesce(person::shared_inbox_url, person::inbox_url))
|
||||
.select(person::inbox_url)
|
||||
.distinct()
|
||||
.load::<DbUrl>(conn)
|
||||
.await?;
|
||||
|
|
|
@ -449,7 +449,7 @@ mod test {
|
|||
protocol::context::WithContext,
|
||||
};
|
||||
use actix_web::{dev::ServerHandle, web, App, HttpResponse, HttpServer};
|
||||
use lemmy_api_common::utils::{generate_inbox_url, generate_shared_inbox_url};
|
||||
use lemmy_api_common::utils::generate_inbox_url;
|
||||
use lemmy_db_schema::{
|
||||
newtypes::DbUrl,
|
||||
source::{
|
||||
|
@ -491,8 +491,7 @@ mod test {
|
|||
let person_form = PersonInsertForm {
|
||||
actor_id: Some(actor_id.clone()),
|
||||
private_key: (Some(actor_keypair.private_key)),
|
||||
inbox_url: Some(generate_inbox_url(&actor_id)?),
|
||||
shared_inbox_url: Some(generate_shared_inbox_url(context.settings())?),
|
||||
inbox_url: Some(generate_inbox_url()?),
|
||||
..PersonInsertForm::new("alice".to_string(), actor_keypair.public_key, instance.id)
|
||||
};
|
||||
let person = Person::create(&mut context.pool(), &person_form).await?;
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
ALTER TABLE person
|
||||
ADD COLUMN shared_inbox_url varchar(255);
|
||||
|
||||
ALTER TABLE community
|
||||
ADD COLUMN shared_inbox_url varchar(255);
|
||||
|
33
migrations/2024-10-18-074533_no-individual-inboxes/up.sql
Normal file
33
migrations/2024-10-18-074533_no-individual-inboxes/up.sql
Normal file
|
@ -0,0 +1,33 @@
|
|||
-- replace value of inbox_url with shared_inbox_url and the drop shared inbox
|
||||
UPDATE
|
||||
person
|
||||
SET
|
||||
inbox_url = subquery.inbox_url
|
||||
FROM (
|
||||
SELECT
|
||||
id,
|
||||
coalesce(shared_inbox_url, inbox_url) AS inbox_url
|
||||
FROM
|
||||
person) AS subquery
|
||||
WHERE
|
||||
person.id = subquery.id;
|
||||
|
||||
ALTER TABLE person
|
||||
DROP COLUMN shared_inbox_url;
|
||||
|
||||
UPDATE
|
||||
community
|
||||
SET
|
||||
inbox_url = subquery.inbox_url
|
||||
FROM (
|
||||
SELECT
|
||||
id,
|
||||
coalesce(shared_inbox_url, inbox_url) AS inbox_url
|
||||
FROM
|
||||
community) AS subquery
|
||||
WHERE
|
||||
community.id = subquery.id;
|
||||
|
||||
ALTER TABLE community
|
||||
DROP COLUMN shared_inbox_url;
|
||||
|
|
@ -10,13 +10,7 @@ use diesel::{
|
|||
use diesel_async::RunQueryDsl;
|
||||
use lemmy_api_common::{
|
||||
lemmy_db_views::structs::SiteView,
|
||||
utils::{
|
||||
generate_followers_url,
|
||||
generate_inbox_url,
|
||||
generate_local_apub_endpoint,
|
||||
generate_shared_inbox_url,
|
||||
EndpointType,
|
||||
},
|
||||
utils::{generate_followers_url, generate_inbox_url, generate_local_apub_endpoint, EndpointType},
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
source::{
|
||||
|
@ -49,8 +43,8 @@ pub async fn run_advanced_migrations(
|
|||
comment_updates_2020_04_03(pool, protocol_and_hostname).await?;
|
||||
private_message_updates_2020_05_05(pool, protocol_and_hostname).await?;
|
||||
post_thumbnail_url_updates_2020_07_27(pool, protocol_and_hostname).await?;
|
||||
apub_columns_2021_02_02(pool, settings).await?;
|
||||
instance_actor_2022_01_28(pool, protocol_and_hostname, settings).await?;
|
||||
apub_columns_2021_02_02(pool).await?;
|
||||
instance_actor_2022_01_28(pool, protocol_and_hostname).await?;
|
||||
regenerate_public_keys_2022_07_05(pool).await?;
|
||||
initialize_local_site_2022_10_10(pool, settings).await?;
|
||||
|
||||
|
@ -282,36 +276,27 @@ async fn post_thumbnail_url_updates_2020_07_27(
|
|||
|
||||
/// We are setting inbox and follower URLs for local and remote actors alike, because for now
|
||||
/// all federated instances are also Lemmy and use the same URL scheme.
|
||||
async fn apub_columns_2021_02_02(pool: &mut DbPool<'_>, settings: &Settings) -> LemmyResult<()> {
|
||||
async fn apub_columns_2021_02_02(pool: &mut DbPool<'_>) -> LemmyResult<()> {
|
||||
let conn = &mut get_conn(pool).await?;
|
||||
info!("Running apub_columns_2021_02_02");
|
||||
{
|
||||
use lemmy_db_schema::schema::person::dsl::{inbox_url, person, shared_inbox_url};
|
||||
use lemmy_db_schema::schema::person::dsl::{inbox_url, person};
|
||||
let persons = person
|
||||
.filter(inbox_url.like("http://changeme%"))
|
||||
.load::<Person>(conn)
|
||||
.await?;
|
||||
|
||||
for p in &persons {
|
||||
let inbox_url_ = generate_inbox_url(&p.actor_id)?;
|
||||
let shared_inbox_url_ = generate_shared_inbox_url(settings)?;
|
||||
let inbox_url_ = generate_inbox_url()?;
|
||||
diesel::update(person.find(p.id))
|
||||
.set((
|
||||
inbox_url.eq(inbox_url_),
|
||||
shared_inbox_url.eq(shared_inbox_url_),
|
||||
))
|
||||
.set((inbox_url.eq(inbox_url_),))
|
||||
.get_result::<Person>(conn)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
use lemmy_db_schema::schema::community::dsl::{
|
||||
community,
|
||||
followers_url,
|
||||
inbox_url,
|
||||
shared_inbox_url,
|
||||
};
|
||||
use lemmy_db_schema::schema::community::dsl::{community, followers_url, inbox_url};
|
||||
let communities = community
|
||||
.filter(inbox_url.like("http://changeme%"))
|
||||
.load::<Community>(conn)
|
||||
|
@ -319,14 +304,9 @@ async fn apub_columns_2021_02_02(pool: &mut DbPool<'_>, settings: &Settings) ->
|
|||
|
||||
for c in &communities {
|
||||
let followers_url_ = generate_followers_url(&c.actor_id)?;
|
||||
let inbox_url_ = generate_inbox_url(&c.actor_id)?;
|
||||
let shared_inbox_url_ = generate_shared_inbox_url(settings)?;
|
||||
let inbox_url_ = generate_inbox_url()?;
|
||||
diesel::update(community.find(c.id))
|
||||
.set((
|
||||
followers_url.eq(followers_url_),
|
||||
inbox_url.eq(inbox_url_),
|
||||
shared_inbox_url.eq(shared_inbox_url_),
|
||||
))
|
||||
.set((followers_url.eq(followers_url_), inbox_url.eq(inbox_url_)))
|
||||
.get_result::<Community>(conn)
|
||||
.await?;
|
||||
}
|
||||
|
@ -342,7 +322,6 @@ async fn apub_columns_2021_02_02(pool: &mut DbPool<'_>, settings: &Settings) ->
|
|||
async fn instance_actor_2022_01_28(
|
||||
pool: &mut DbPool<'_>,
|
||||
protocol_and_hostname: &str,
|
||||
settings: &Settings,
|
||||
) -> LemmyResult<()> {
|
||||
info!("Running instance_actor_2021_09_29");
|
||||
if let Ok(site_view) = SiteView::read_local(pool).await {
|
||||
|
@ -356,7 +335,7 @@ async fn instance_actor_2022_01_28(
|
|||
let site_form = SiteUpdateForm {
|
||||
actor_id: Some(actor_id.clone().into()),
|
||||
last_refreshed_at: Some(naive_now()),
|
||||
inbox_url: Some(generate_shared_inbox_url(settings)?),
|
||||
inbox_url: Some(generate_inbox_url()?),
|
||||
private_key: Some(Some(key_pair.private_key)),
|
||||
public_key: Some(key_pair.public_key),
|
||||
..Default::default()
|
||||
|
@ -457,8 +436,7 @@ async fn initialize_local_site_2022_10_10(
|
|||
// Register the user if there's a site setup
|
||||
let person_form = PersonInsertForm {
|
||||
actor_id: Some(person_actor_id.clone()),
|
||||
inbox_url: Some(generate_inbox_url(&person_actor_id)?),
|
||||
shared_inbox_url: Some(generate_shared_inbox_url(settings)?),
|
||||
inbox_url: Some(generate_inbox_url()?),
|
||||
private_key: Some(person_keypair.private_key),
|
||||
..PersonInsertForm::new(
|
||||
setup.admin_username.clone(),
|
||||
|
@ -488,7 +466,7 @@ async fn initialize_local_site_2022_10_10(
|
|||
let site_form = SiteInsertForm {
|
||||
actor_id: Some(site_actor_id.clone().into()),
|
||||
last_refreshed_at: Some(naive_now()),
|
||||
inbox_url: Some(generate_shared_inbox_url(settings)?),
|
||||
inbox_url: Some(generate_inbox_url()?),
|
||||
private_key: Some(site_key_pair.private_key),
|
||||
public_key: Some(site_key_pair.public_key),
|
||||
|
||||
|
|
Loading…
Reference in a new issue