You've already forked AstralRinth
forked from didirus/AstralRinth
Support for using a master key (#83)
* Support for using a master key * Expand scope of PR, add wrapper struct, add files to intitial versions/mods * Change changelog path, run formatter * Split file changes into different PR * Formatting, rename main variable Co-authored-by: Aeledfyr <aeledfyr@gmail.com>
This commit is contained in:
@@ -52,6 +52,12 @@ impl actix_web::ResponseError for SearchError {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct SearchConfig {
|
||||
pub address: String,
|
||||
pub key: String,
|
||||
}
|
||||
|
||||
/// A mod document used for uploading mods to meilisearch's indices.
|
||||
/// This contains some extra data that is not returned by search results.
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
@@ -133,9 +139,11 @@ impl Document for ResultSearchMod {
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn search_for_mod(info: &SearchRequest) -> Result<SearchResults, SearchError> {
|
||||
let address = &*dotenv::var("MEILISEARCH_ADDR")?;
|
||||
let client = Client::new(address, "");
|
||||
pub async fn search_for_mod(
|
||||
info: &SearchRequest,
|
||||
config: &SearchConfig,
|
||||
) -> Result<SearchResults, SearchError> {
|
||||
let client = Client::new(&*config.key, &*config.address);
|
||||
|
||||
let filters: Cow<_> = match (info.filters.as_deref(), info.version.as_deref()) {
|
||||
(Some(f), Some(v)) => format!("({}) AND ({})", f, v).into(),
|
||||
|
||||
Reference in New Issue
Block a user