Skip to content

Commit

Permalink
update deps and fix checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacherr committed Oct 20, 2024
1 parent 4b5bcc6 commit e85f1e1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 25 deletions.
2 changes: 1 addition & 1 deletion assyst-core/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ async fn main() {
});

info!("Caching web download API URLs");
let web_download_urls = get_web_download_api_urls(&a.reqwest_client).await.unwrap();
let web_download_urls = get_web_download_api_urls(&a.reqwest_client).await.unwrap_or(vec![]);
info!("Got {} URLs to cache", web_download_urls.len());
debug!(?web_download_urls);
a.rest_cache_handler.set_web_download_urls(web_download_urls);
Expand Down
37 changes: 13 additions & 24 deletions assyst-core/src/task/tasks/refresh_entitlements.rs
Original file line number Diff line number Diff line change
@@ -1,38 +1,26 @@
use assyst_common::err;
use assyst_common::macros::handle_log;
use assyst_database::model::active_guild_premium_entitlement::ActiveGuildPremiumEntitlement;
use tracing::info;
use twilight_model::id::marker::EntitlementMarker;
use twilight_model::id::Id;

use crate::assyst::ThreadSafeAssyst;

pub async fn refresh_entitlements(assyst: ThreadSafeAssyst) {
let clone = assyst.entitlements.lock().unwrap().clone();
let mut entitlements = clone.iter().collect::<Vec<_>>();
entitlements.sort_by(|x, y| y.1.entitlement_id.cmp(&x.1.entitlement_id));
let latest = entitlements.first();
let additional = match latest {
Some(l) => {
match assyst
.http_client
.entitlements(assyst.application_id)
.after(Id::<EntitlementMarker>::new(l.1.entitlement_id as u64))
.await
{
Ok(x) => match x.model().await {
Ok(e) => e,
Err(e) => {
err!("Failed to get potential new entitlements: {e:?}");
vec![]
},
},
Err(e) => {
err!("Failed to get potential new entitlements: {e:?}");
vec![]
},
}
let additional = match assyst.http_client.entitlements(assyst.application_id).await {
Ok(x) => match x.model().await {
Ok(e) => e,
Err(e) => {
err!("Failed to get potential new entitlements: {e:?}");
vec![]
},
},
Err(e) => {
err!("Failed to get potential new entitlements: {e:?}");
vec![]
},
None => vec![],
};

for a in additional {
Expand All @@ -51,6 +39,7 @@ pub async fn refresh_entitlements(assyst: ThreadSafeAssyst) {
active.entitlement_id
);
};
handle_log(format!("New entitlement! Guild: {}", active.guild_id));
assyst.entitlements.lock().unwrap().insert(active.guild_id, active);
}
}
Expand Down

0 comments on commit e85f1e1

Please sign in to comment.