mirror of
https://github.com/modrinth/code.git
synced 2026-08-30 19:46:33 +00:00
* Begin external projects moderator database frontend * add copy link button * begin project page permissions settings * MEL database backend routes * include filename in external files * wip: when uploading a version file, fetch its overrides as a list * wip: override license checks * improve FileHost ref counting * file host read capability * scan files when inserting version file * add dependency sha1 field * clean up version files * wip: attributions * update s3 file host * attribution scanning basic works * works * insert attribution info after resolving * add routes * remove dep sha1 stuff * prepr * wip: override file sources * add files_missing_attributions to versions * return extended version info + attributed at/by * hook up frontend to backend (mostly) * expose version date published * withholding version visibility * frontend work * prepr * use api-client for img upload * moar frontend * prepr * Add schema to attribution resolution and Flame project results * sqlx prepare * changes * remove feature flag, fix optional proof images * fix schema * fmt * fix deletion and file fetch * prepare * fix admonition * update frontend stuff to new schema * prepr * attribution on dependencies * fixes * sqlx prepare * fixes * routes * fix routes * Version grandfathering * prepare * wip: bulk routes * pushing what i've got rn * include link in NoPermission * change hash insert to bulk route * query flame even if entry in MEL * delete file with weird name * Prioritise putting override files in existing groups even with ExternalLicense * fix how hex bytes are handled in route * feat: coolbot moderation changes (#6215) * Update moderator checklist * move permissions stage order * Updated nagContext.versions to v3, added nag for permissions * Update permissions.vue default messages * prepr --------- Co-authored-by: coolbot100s <76798835+coolbot100s@users.noreply.github.com> * QA * prepr * should group by project * return attribution resolution correctly * updated by moderator info * Track what moderator reviewed an attribution moderation status * default deser FMA field * new version page * clean up fetching + add a couple missing features * qa items * prepr * provide moderation package stuff with DI * format? * don't redact moderated_at * move supplementary resources * Reorganize moderation messages. * Quick replies for external content permissions. * prepare * QA * allow exempting projects * Ignore Flame projects which 404 * fix ci * fix cross project attribution stuff * Fix permission error * change what files get cscanned * add more logging * QA Jun 22 * fix * idempotency * Expose route for rescanning * update blog link --------- Co-authored-by: aecsocket <aecsocket@tutanota.com> Co-authored-by: coolbot100s <76798835+coolbot100s@users.noreply.github.com> Co-authored-by: aecsocket <43144841+aecsocket@users.noreply.github.com>
77 lines
2.2 KiB
Rust
77 lines
2.2 KiB
Rust
use std::sync::Arc;
|
|
|
|
use actix_web::web;
|
|
|
|
use crate::env::ENV;
|
|
use crate::file_hosting::FileHost;
|
|
use crate::queue::email::EmailQueue;
|
|
use crate::util::anrok;
|
|
use crate::util::gotenberg::GotenbergClient;
|
|
use crate::{LabrinthConfig, file_hosting};
|
|
use crate::{clickhouse, env};
|
|
|
|
pub mod api_common;
|
|
pub mod api_v2;
|
|
pub mod api_v3;
|
|
pub mod asserts;
|
|
pub mod database;
|
|
pub mod db;
|
|
pub mod dummy_data;
|
|
pub mod environment;
|
|
pub mod pats;
|
|
pub mod permissions;
|
|
pub mod scopes;
|
|
pub mod search;
|
|
|
|
// Testing equivalent to 'setup' function, producing a LabrinthConfig
|
|
// If making a test, you should probably use environment::TestEnvironment::build() (which calls this)
|
|
pub async fn setup(db: &database::TemporaryDatabase) -> LabrinthConfig {
|
|
println!("Setting up labrinth config");
|
|
env::init().expect("failed to initialize environment variables");
|
|
|
|
let _ = rustls::crypto::aws_lc_rs::default_provider().install_default();
|
|
|
|
let pool = db.pool.clone();
|
|
let ro_pool = db.ro_pool.clone();
|
|
let redis_pool = db.redis_pool.clone();
|
|
let search_backend = db.search_backend.clone();
|
|
let file_host: Arc<dyn FileHost> = Arc::new(file_hosting::MockHost::new());
|
|
let file_host = web::Data::<dyn FileHost>::from(file_host);
|
|
let mut clickhouse = clickhouse::init_client().await.unwrap();
|
|
|
|
let stripe_client = stripe::Client::new(ENV.STRIPE_API_KEY.clone());
|
|
|
|
let anrok_client = anrok::Client::from_env().unwrap();
|
|
let email_queue =
|
|
EmailQueue::init(pool.clone(), redis_pool.clone()).unwrap();
|
|
let gotenberg_client = GotenbergClient::from_env(redis_pool.clone())
|
|
.expect("Failed to create Gotenberg client");
|
|
let kafka_client = actix_web::web::Data::new(
|
|
crate::util::kafka::KafkaClientState::new()
|
|
.expect("Kafka connection failed"),
|
|
);
|
|
|
|
crate::app_setup(
|
|
pool.clone(),
|
|
ro_pool.clone(),
|
|
redis_pool.clone(),
|
|
search_backend.into(),
|
|
&mut clickhouse,
|
|
file_host.clone(),
|
|
stripe_client,
|
|
anrok_client,
|
|
email_queue,
|
|
gotenberg_client,
|
|
kafka_client,
|
|
false,
|
|
)
|
|
}
|
|
|
|
pub fn get_json_val_str(val: impl serde::Serialize) -> String {
|
|
serde_json::to_value(val)
|
|
.unwrap()
|
|
.as_str()
|
|
.unwrap()
|
|
.to_string()
|
|
}
|