Skip to content

Commit

Permalink
remove map in autoendpoint apns router with related comment to post D…
Browse files Browse the repository at this point in the history
…ynamo removal
  • Loading branch information
taddes committed Jul 2, 2024
1 parent 621ff01 commit 80c0594
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 28 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ slog-scope = "4.4"
slog-stdlog = "4.1"
slog-term = "2.6"
thiserror = "1.0"
tokio = "1.36"
tokio = "1.38"
tokio-compat-02 = "0.2"
tokio-core = "0.1"
tokio-io = "0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,8 @@ impl WebPushClient {
.or(self.current_timestamp);
trace!("🗄️ WebPushClient::do_check_storage {:?}", &timestamp);
// if we're to include topic messages, do those first.
// NOTE: DynamoDB would also wind up fetching the `current_timestamp` when pulling these,
// Bigtable can't fetch `current_timestamp` so we can't rely on `fetch_topic_messages()`
// returning a reasonable timestamp.
// NOTE: Bigtable can't fetch `current_timestamp`, so we can't rely on
// `fetch_topic_messages()` returning a reasonable timestamp.
let topic_resp = if self.flags.include_topic {
trace!("🗄️ WebPushClient::do_check_storage: fetch_topic_messages");
// Get the most recent max 11 messages.
Expand Down
4 changes: 2 additions & 2 deletions autoconnect/autoconnect-ws/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::sync::Arc;

use actix_ws::{CloseReason, Message};
use futures::{channel::mpsc, Stream, StreamExt};
use tokio::{select, time::timeout};
use tokio::time::timeout;

use autoconnect_common::protocol::{ServerMessage, ServerNotification};
use autoconnect_settings::AppState;
Expand Down Expand Up @@ -151,7 +151,7 @@ async fn identified_ws(

let mut ping_manager = PingManager::new(client.app_settings()).await;
let close_reason = loop {
select! {
tokio::select! {
maybe_result = msg_stream.next() => {
let Some(result) = maybe_result else {
trace!("identified_ws: msg_stream EOF");
Expand Down
23 changes: 1 addition & 22 deletions autoendpoint/src/routers/apns/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,21 +234,6 @@ impl ApnsRouter {
ApiError::from(ApnsError::ApnsUpstream(error))
}

/// Convert all of the floats in a JSON value into integers.
/// Deserializing to `APS` will fail if
/// it expects an integer and gets a float.
fn convert_value_float_to_int(value: &mut Value) {
if let Some(float) = value.as_f64() {
*value = Value::Number(serde_json::Number::from(float as i64));
}

if let Some(object) = value.as_object_mut() {
object
.values_mut()
.for_each(Self::convert_value_float_to_int);
}
}

/// if we have any clients defined, this connection is "active"
pub fn active(&self) -> bool {
!self.clients.is_empty()
Expand Down Expand Up @@ -432,13 +417,7 @@ impl Router for ApnsRouter {
.get("rel_channel")
.and_then(Value::as_str)
.ok_or(ApnsError::NoReleaseChannel)?;
// XXX: We don't really use anything that is a numeric here, aside from
// mutable contant, and even there we should just check for presense.
// Once we're off of DynamoDB, we might want to kill the map.
let aps_json = router_data.get("aps").cloned().map(|mut value| {
Self::convert_value_float_to_int(&mut value);
value
});
let aps_json = router_data.get("aps").cloned();
let mut message_data = build_message_data(notification)?;
message_data.insert("ver", notification.message_id.clone());

Expand Down

0 comments on commit 80c0594

Please sign in to comment.