Skip to content

Commit

Permalink
FIX CHECK PROPERLY
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacherr committed Oct 21, 2024
1 parent 255d895 commit 0126d9f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions assyst-core/src/task/tasks/refresh_entitlements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ pub async fn refresh_entitlements(assyst: ThreadSafeAssyst) {
},
};

println!("{:?}", additional.iter().map(|x| x.id).collect::<Vec<_>>());

for a in additional {
for a in additional.clone() {
if !assyst.entitlements.lock().unwrap().contains_key(&(a.id.get() as i64)) {
let active = match ActiveGuildPremiumEntitlement::try_from(a) {
Ok(a) => a,
Expand Down Expand Up @@ -56,7 +54,10 @@ pub async fn refresh_entitlements(assyst: ThreadSafeAssyst) {

// remove entitlements from the db that are not in the rest response
for entitlement in db_entitlements.values() {
if !entitlements.contains_key(&entitlement.entitlement_id) {
if !additional
.iter()
.any(|x| x.id.get() as i64 == entitlement.entitlement_id)
{
assyst.entitlements.lock().unwrap().remove(&entitlement.entitlement_id);
info!(
"Removed expired entitlement {} (guild {})",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use twilight_model::util::Timestamp;

use crate::{is_unique_violation, DatabaseHandler};

#[derive(sqlx::FromRow, Clone)]
#[derive(sqlx::FromRow, Clone, Debug)]
pub struct ActiveGuildPremiumEntitlement {
pub entitlement_id: i64,
pub guild_id: i64,
Expand Down

0 comments on commit 0126d9f

Please sign in to comment.