server: add postgres based newsreader search and disable tantivy

This commit is contained in:
2024-12-17 09:31:51 -08:00
parent e36f4f97f9
commit 13eaf33b1a
9 changed files with 86 additions and 32 deletions

View File

@@ -17,12 +17,13 @@ use rocket::{
Response, State,
};
use rocket_cors::{AllowedHeaders, AllowedOrigins};
#[cfg(feature = "tantivy")]
use server::tantivy::TantivyConnection;
use server::{
config::Config,
error::ServerError,
graphql::{Attachment, GraphqlSchema, Mutation, QueryRoot},
nm::{attachment_bytes, cid_attachment_bytes},
tantivy::TantivyConnection,
};
use sqlx::postgres::PgPool;
@@ -216,15 +217,18 @@ async fn main() -> Result<(), Box<dyn Error>> {
}
let pool = PgPool::connect(&config.newsreader_database_url).await?;
sqlx::migrate!("./migrations").run(&pool).await?;
#[cfg(feature = "tantivy")]
let tantivy_conn = TantivyConnection::new(&config.newsreader_tantivy_db_path)?;
let schema = Schema::build(QueryRoot, Mutation, EmptySubscription)
.data(Notmuch::default())
.data(config)
.data(pool.clone())
.data(tantivy_conn)
.extension(async_graphql::extensions::Logger)
.finish();
.data(pool.clone());
#[cfg(feature = "tantivy")]
let schema = schema.data(tantivy_conn);
let schema = schema.extension(async_graphql::extensions::Logger).finish();
let rkt = rkt.manage(schema).manage(pool).manage(Notmuch::default());
//.manage(Notmuch::with_config("../notmuch/testdata/notmuch.config"))