Page MenuHomePhorge

D12178.1768428505.diff
No OneTemporary

Size
5 KB
Referenced Files
None
Subscribers
None

D12178.1768428505.diff

diff --git a/services/identity/src/ddb_utils.rs b/services/identity/src/ddb_utils.rs
--- a/services/identity/src/ddb_utils.rs
+++ b/services/identity/src/ddb_utils.rs
@@ -1,4 +1,4 @@
-use chrono::{DateTime, NaiveDateTime, Utc};
+use chrono::{DateTime, Utc};
use comm_lib::{
aws::{
ddb::types::{
@@ -160,17 +160,6 @@
transactions
}
-pub trait DateTimeExt {
- fn from_utc_timestamp_millis(timestamp: i64) -> Option<DateTime<Utc>>;
-}
-
-impl DateTimeExt for DateTime<Utc> {
- fn from_utc_timestamp_millis(timestamp: i64) -> Option<Self> {
- let naive = NaiveDateTime::from_timestamp_millis(timestamp)?;
- Some(Self::from_naive_utc_and_offset(naive, Utc))
- }
-}
-
pub struct DBIdentity {
pub identifier: Identifier,
pub farcaster_id: Option<String>,
diff --git a/services/identity/src/device_list.rs b/services/identity/src/device_list.rs
--- a/services/identity/src/device_list.rs
+++ b/services/identity/src/device_list.rs
@@ -5,7 +5,6 @@
use crate::{
constants::{error_types, DEVICE_LIST_TIMESTAMP_VALID_FOR},
database::{DeviceListRow, DeviceListUpdate},
- ddb_utils::DateTimeExt,
error::DeviceListError,
grpc_services::protos::auth::UpdateDeviceListRequest,
};
@@ -109,14 +108,14 @@
devices,
timestamp: raw_timestamp,
} = signed_list.as_raw()?;
- let timestamp = DateTime::<Utc>::from_utc_timestamp_millis(raw_timestamp)
- .ok_or_else(|| {
- error!(
- errorType = error_types::GRPC_SERVICES_LOG,
- "Failed to parse RawDeviceList timestamp!"
- );
- tonic::Status::invalid_argument("invalid timestamp")
- })?;
+ let timestamp =
+ DateTime::from_timestamp_millis(raw_timestamp).ok_or_else(|| {
+ error!(
+ errorType = error_types::GRPC_SERVICES_LOG,
+ "Failed to parse RawDeviceList timestamp!"
+ );
+ tonic::Status::invalid_argument("invalid timestamp")
+ })?;
Ok(DeviceListUpdate {
devices,
timestamp,
@@ -499,7 +498,7 @@
.expect("Failed to parse DeviceListUpdate from signed list");
let expected_timestamp =
- DateTime::<Utc>::from_utc_timestamp_millis(123456789).unwrap();
+ DateTime::from_timestamp_millis(123456789).unwrap();
assert_eq!(update.timestamp, expected_timestamp);
assert_eq!(
@@ -546,8 +545,7 @@
DeviceListRow {
user_id: "".to_string(),
device_ids: raw_list.devices,
- timestamp: DateTime::<Utc>::from_utc_timestamp_millis(raw_list.timestamp)
- .unwrap(),
+ timestamp: DateTime::from_timestamp_millis(raw_list.timestamp).unwrap(),
current_primary_signature: None,
last_primary_signature: None,
}
diff --git a/services/identity/src/grpc_services/authenticated.rs b/services/identity/src/grpc_services/authenticated.rs
--- a/services/identity/src/grpc_services/authenticated.rs
+++ b/services/identity/src/grpc_services/authenticated.rs
@@ -7,10 +7,9 @@
client_service::{handle_db_error, UpdateState, WorkflowInProgress},
constants::{error_types, request_metadata},
database::DatabaseClient,
- ddb_utils::DateTimeExt,
grpc_services::shared::get_value,
};
-use chrono::{DateTime, Utc};
+use chrono::DateTime;
use comm_opaque2::grpc::protocol_error_to_grpc_status;
use tonic::{Request, Response, Status};
use tracing::{debug, error, trace, warn};
@@ -486,7 +485,7 @@
let since = since_timestamp
.map(|timestamp| {
- DateTime::<Utc>::from_utc_timestamp_millis(timestamp)
+ DateTime::from_timestamp_millis(timestamp)
.ok_or_else(|| tonic::Status::invalid_argument("Invalid timestamp"))
})
.transpose()?;
diff --git a/shared/comm-lib/src/auth/service.rs b/shared/comm-lib/src/auth/service.rs
--- a/shared/comm-lib/src/auth/service.rs
+++ b/shared/comm-lib/src/auth/service.rs
@@ -1,5 +1,5 @@
use aws_sdk_secretsmanager::Client as SecretsManagerClient;
-use chrono::{DateTime, Duration, NaiveDateTime, Utc};
+use chrono::{DateTime, Duration, Utc};
use grpc_clients::identity::unauthenticated::client as identity_client;
use super::{AuthorizationCredential, ServicesAuthToken, UserIdentity};
@@ -131,8 +131,7 @@
let duration = result
.last_rotated_date()
.and_then(|date| date.to_millis().ok())
- .and_then(NaiveDateTime::from_timestamp_millis)
- .map(|naive| DateTime::<Utc>::from_naive_utc_and_offset(naive, Utc))
+ .and_then(DateTime::from_timestamp_millis)
.map(|last_rotated| Utc::now().signed_duration_since(last_rotated));
Ok(duration)
}
diff --git a/shared/comm-lib/src/database.rs b/shared/comm-lib/src/database.rs
--- a/shared/comm-lib/src/database.rs
+++ b/shared/comm-lib/src/database.rs
@@ -408,15 +408,13 @@
attribute_name.clone(),
attribute_value.clone(),
)?;
- let naive_datetime = chrono::NaiveDateTime::from_timestamp_millis(timestamp)
- .ok_or_else(|| {
- DBItemError::new(
- attribute_name,
- Value::AttributeValue(attribute_value),
- DBItemAttributeError::TimestampOutOfRange,
- )
- })?;
- Ok(DateTime::from_naive_utc_and_offset(naive_datetime, Utc))
+ chrono::DateTime::from_timestamp_millis(timestamp).ok_or_else(|| {
+ DBItemError::new(
+ attribute_name,
+ Value::AttributeValue(attribute_value),
+ DBItemAttributeError::TimestampOutOfRange,
+ )
+ })
}
pub fn parse_integer<T>(

File Metadata

Mime Type
text/plain
Expires
Wed, Jan 14, 10:08 PM (6 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5934247
Default Alt Text
D12178.1768428505.diff (5 KB)

Event Timeline