diff --git a/src/api_request_handler.rs b/src/api_request_handler.rs index b55f646..95c567a 100644 --- a/src/api_request_handler.rs +++ b/src/api_request_handler.rs @@ -253,7 +253,7 @@ impl APIHandler { } // Proceed with the main logic after passing all checks - self.notification_manager.save_user_device_info(pubkey, device_token).await?; + self.notification_manager.save_user_device_info_if_not_present(pubkey, device_token).await?; Ok(APIResponse { status: StatusCode::OK, body: json!({ "message": "User info saved successfully" }), diff --git a/src/notification_manager/notification_manager.rs b/src/notification_manager/notification_manager.rs index 11ffe56..ab3d01b 100644 --- a/src/notification_manager/notification_manager.rs +++ b/src/notification_manager/notification_manager.rs @@ -406,6 +406,17 @@ impl NotificationManager { } // MARK: - User device info and settings + + pub async fn save_user_device_info_if_not_present( + &self, + pubkey: nostr::PublicKey, + device_token: &str, + ) -> Result<(), Box> { + if self.is_pubkey_registered(&pubkey).await? { + return Ok(()); + } + self.save_user_device_info(pubkey, device_token).await + } pub async fn save_user_device_info( &self,