Compare commits

...

2 Commits

Author SHA1 Message Date
Nutomic
7c1a37d584
In apub post receive, check posting restricted to mods (ref #2702) (#2704)
Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
2023-02-05 12:31:09 -05:00
Nutomic
2891856b48
Fix docker federation setup (#2706) 2023-02-05 12:30:10 -05:00
11 changed files with 33 additions and 56 deletions

View File

@ -147,7 +147,6 @@ export async function setupLogins() {
// Registration applications are now enabled by default, need to disable them
let editSiteForm: EditSite = {
registration_mode: RegistrationMode.Open,
federation_debug: true,
rate_limit_message: 999,
rate_limit_post: 999,
rate_limit_register: 999,

View File

@ -45,15 +45,11 @@ async fn local_instance(context: &LemmyContext) -> &'static LocalInstance {
.as_ref()
.map(|l| l.federation_worker_count)
.unwrap_or(64) as u64;
let federation_debug = local_site
.as_ref()
.map(|l| l.federation_debug)
.unwrap_or(true);
let settings = InstanceSettings::builder()
.http_fetch_retry_limit(FEDERATION_HTTP_FETCH_LIMIT)
.worker_count(worker_count)
.debug(federation_debug)
.debug(cfg!(debug_assertions))
.http_signature_compat(true)
.url_verifier(Box::new(VerifyUrlData(context.clone())))
.build()

View File

@ -26,7 +26,7 @@ use chrono::NaiveDateTime;
use lemmy_api_common::{
context::LemmyContext,
request::fetch_site_data,
utils::local_site_opt_to_slur_regex,
utils::{is_mod_or_admin, local_site_opt_to_slur_regex},
};
use lemmy_db_schema::{
self,
@ -173,6 +173,9 @@ impl ApubObject for ApubPost {
.dereference(context, local_instance(context).await, request_counter)
.await?;
let community = page.community(context, request_counter).await?;
if community.posting_restricted_to_mods {
is_mod_or_admin(context.pool(), creator.id, community.id).await?;
}
let mut name = page
.name
.clone()

View File

@ -154,11 +154,11 @@ pub const MIGRATIONS: EmbeddedMigrations = embed_migrations!();
pub fn run_migrations(db_url: &str) {
// Needs to be a sync connection
let mut conn =
PgConnection::establish(db_url).unwrap_or_else(|_| panic!("Error connecting to {db_url}"));
PgConnection::establish(db_url).unwrap_or_else(|e| panic!("Error connecting to {db_url}: {e}"));
info!("Running Database migrations (This may take a long time)...");
let _ = &mut conn
.run_pending_migrations(MIGRATIONS)
.unwrap_or_else(|_| panic!("Couldn't run DB Migrations"));
.unwrap_or_else(|e| panic!("Couldn't run DB Migrations: {e}"));
info!("Database migrations complete.");
}

View File

@ -30,9 +30,9 @@ services:
lemmy-alpha-ui:
image: dessalines/lemmy-ui:0.17.1
environment:
- LEMMY_INTERNAL_HOST=lemmy-alpha:8541
- LEMMY_EXTERNAL_HOST=localhost:8541
- LEMMY_HTTPS=false
- LEMMY_UI_LEMMY_INTERNAL_HOST=lemmy-alpha:8541
- LEMMY_UI_LEMMY_EXTERNAL_HOST=localhost:8541
- LEMMY_UI_HTTPS=false
depends_on:
- lemmy-alpha
lemmy-alpha:
@ -52,15 +52,16 @@ services:
- POSTGRES_USER=lemmy
- POSTGRES_PASSWORD=password
- POSTGRES_DB=lemmy
restart: always
volumes:
- ./volumes/postgres_alpha:/var/lib/postgresql/data
lemmy-beta-ui:
image: dessalines/lemmy-ui:0.17.1
environment:
- LEMMY_INTERNAL_HOST=lemmy-beta:8551
- LEMMY_EXTERNAL_HOST=localhost:8551
- LEMMY_HTTPS=false
- LEMMY_UI_LEMMY_INTERNAL_HOST=lemmy-beta:8551
- LEMMY_UI_LEMMY_EXTERNAL_HOST=localhost:8551
- LEMMY_UI_HTTPS=false
depends_on:
- lemmy-beta
lemmy-beta:
@ -80,15 +81,16 @@ services:
- POSTGRES_USER=lemmy
- POSTGRES_PASSWORD=password
- POSTGRES_DB=lemmy
restart: always
volumes:
- ./volumes/postgres_beta:/var/lib/postgresql/data
lemmy-gamma-ui:
image: dessalines/lemmy-ui:0.17.1
environment:
- LEMMY_INTERNAL_HOST=lemmy-gamma:8561
- LEMMY_EXTERNAL_HOST=localhost:8561
- LEMMY_HTTPS=false
- LEMMY_UI_LEMMY_INTERNAL_HOST=lemmy-gamma:8561
- LEMMY_UI_LEMMY_EXTERNAL_HOST=localhost:8561
- LEMMY_UI_HTTPS=false
depends_on:
- lemmy-gamma
lemmy-gamma:
@ -108,6 +110,7 @@ services:
- POSTGRES_USER=lemmy
- POSTGRES_PASSWORD=password
- POSTGRES_DB=lemmy
restart: always
volumes:
- ./volumes/postgres_gamma:/var/lib/postgresql/data
@ -115,9 +118,9 @@ services:
lemmy-delta-ui:
image: dessalines/lemmy-ui:0.17.1
environment:
- LEMMY_INTERNAL_HOST=lemmy-delta:8571
- LEMMY_EXTERNAL_HOST=localhost:8571
- LEMMY_HTTPS=false
- LEMMY_UI_LEMMY_INTERNAL_HOST=lemmy-delta:8571
- LEMMY_UI_LEMMY_EXTERNAL_HOST=localhost:8571
- LEMMY_UI_HTTPS=false
depends_on:
- lemmy-delta
lemmy-delta:
@ -137,6 +140,7 @@ services:
- POSTGRES_USER=lemmy
- POSTGRES_PASSWORD=password
- POSTGRES_DB=lemmy
restart: always
volumes:
- ./volumes/postgres_delta:/var/lib/postgresql/data
@ -144,9 +148,9 @@ services:
lemmy-epsilon-ui:
image: dessalines/lemmy-ui:0.17.1
environment:
- LEMMY_INTERNAL_HOST=lemmy-epsilon:8581
- LEMMY_EXTERNAL_HOST=localhost:8581
- LEMMY_HTTPS=false
- LEMMY_UI_LEMMY_INTERNAL_HOST=lemmy-epsilon:8581
- LEMMY_UI_LEMMY_EXTERNAL_HOST=localhost:8581
- LEMMY_UI_HTTPS=false
depends_on:
- lemmy-epsilon
lemmy-epsilon:
@ -166,5 +170,6 @@ services:
- POSTGRES_USER=lemmy
- POSTGRES_PASSWORD=password
- POSTGRES_DB=lemmy
restart: always
volumes:
- ./volumes/postgres_epsilon:/var/lib/postgresql/data

View File

@ -7,13 +7,7 @@
admin_password: lemmylemmy
site_name: lemmy-alpha
}
# These are ignored, use LEMMY_DATABASE_URL
database: {
database: lemmy_alpha
user: lemmy
password: password
host: localhost
port: 5432
pool_size: 5
host: postgres_alpha
}
}

View File

@ -8,11 +8,6 @@
site_name: lemmy-beta
}
database: {
database: lemmy_beta
user: lemmy
password: password
host: localhost
port: 5432
pool_size: 5
host: postgres_beta
}
}

View File

@ -8,11 +8,6 @@
site_name: lemmy-delta
}
database: {
database: lemmy_delta
user: lemmy
password: password
host: localhost
port: 5432
pool_size: 5
host: postgres_delta
}
}

View File

@ -8,11 +8,6 @@
site_name: lemmy-epsilon
}
database: {
database: lemmy_epsilon
user: lemmy
password: password
host: localhost
port: 5432
pool_size: 5
host: postgres_epsilon
}
}

View File

@ -8,11 +8,6 @@
site_name: lemmy-gamma
}
database: {
database: lemmy_gamma
user: lemmy
password: password
host: localhost
port: 5432
pool_size: 5
host: postgres_gamma
}
}

View File

@ -3,7 +3,7 @@ set -e
sudo docker-compose down
sudo docker build ../../ --file ../dev/volume_mount.dockerfile -t lemmy-federation:latest
sudo docker build ../../ --file ../dev/Dockerfile -t lemmy-federation:latest
for Item in alpha beta gamma delta epsilon ; do
sudo mkdir -p volumes/pictrs_$Item