Skip to content

Commit

Permalink
fix: changes
Browse files Browse the repository at this point in the history
Signed-off-by: IAmTomahawkx <[email protected]>
  • Loading branch information
IAmTomahawkx committed Nov 27, 2024
1 parent 7b73fc3 commit 63c7494
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 18 deletions.
4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,5 @@ members = [
]

[patch.crates-io]
# mobc-redis = { git = "https://github.com/insertish/mobc", rev = "8b880bb59f2ba80b4c7bc40c649c113d8857a186" }
redis22 = { package = "redis", version = "0.22.3", git = "https://github.com/revoltchat/redis-rs", rev = "1a41faf356fd21aebba71cea7eb7eb2653e5f0ef" }
redis23 = { package = "redis", version = "0.23.1", git = "https://github.com/revoltchat/redis-rs", rev = "f8ca28ab85da59d2ccde526b4d2fb390eff5a5f9" }
#authifier = { package = "authifier", version = "1.0.9", path = "../authifier/crates/authifier" }
#rocket_authifier = { package = "rocket_authifier", version = "1.0.9", path = "../authifier/crates/rocket_authifier" }
#rocket_empty = { package = "rocket_empty", version = "0.1.2", git = "https://github.com/IAmTomahawkx/rocket_empty", rev = "4be43b75ef740324a0cd7a1d9866e53ae1dc586e" }
4 changes: 2 additions & 2 deletions crates/core/database/src/tasks/ack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ pub async fn handle_ack_event(
match &event {
#[allow(clippy::disallowed_methods)] // event is sent by higher level function
AckEvent::AckMessage { id } => {
let _u = user.as_ref().unwrap();
let user: &str = _u.as_str();
let user = user.as_ref().unwrap();
let user: &str = user.as_str();

let unread = db.fetch_unread(user, channel).await?;
let updated = db.acknowledge_message(channel, user, id).await?;
Expand Down
Empty file.
15 changes: 3 additions & 12 deletions crates/daemons/pushd/src/consumers/inbound/ack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,9 @@ impl AsyncConsumer for AckConsumer {
let content = String::from_utf8(content).unwrap();
let payload: AckPayload = serde_json::from_str(content.as_str()).unwrap();

log::debug!("Received Ack event");

// Step 1: fetch unreads and don't continue if there's no unreads
#[allow(clippy::disallowed_methods)]
let unreads = self.db.fetch_unread_mentions(&payload.user_id).await;
println!("unreads: {:?}", unreads);

if let Ok(u) = &unreads {
if u.is_empty() {
Expand Down Expand Up @@ -101,16 +98,12 @@ impl AsyncConsumer for AckConsumer {
return;
}

println!("sessions: {:?}", apple_sessions);

// Step 3: calculate the actual mention count, since we have to send it out
let mut mention_count = 0;
for u in &unreads.unwrap() {
mention_count += u.mentions.as_ref().unwrap().len()
}

println!("mention count: {}", mention_count);

// Step 4: loop through each apple session and send the badge update
for session in apple_sessions {
let service_payload = PayloadToService {
Expand All @@ -129,19 +122,17 @@ impl AsyncConsumer for AckConsumer {
)
.finish();

println!(
log::debug!(
"Publishing ack to apn session {}",
session.subscription.as_ref().unwrap().auth
);

publish_message(self, p.into(), args).await;
} else {
println!("Failed to serialize ack badge update payload!");
println!("{:?}", raw_service_payload.unwrap_err())
log::warn!("Failed to serialize ack badge update payload!");
revolt_config::capture_error(&raw_service_payload.unwrap_err());
}
}

println!("Done!");
}
}
}

0 comments on commit 63c7494

Please sign in to comment.