mirror of
https://github.com/nostrlabs-io/notepush.git
synced 2025-06-18 20:57:12 +00:00
Do not override user info row on registration endpoint if it already exists
This commit fixes an issue where notification settings would be lost after restarting Damus, causing unwanted notifications Signed-off-by: Daniel D’Aquino <daniel@daquino.me> Closes: https://github.com/damus-io/damus/issues/2417
This commit is contained in:
@ -253,7 +253,7 @@ impl APIHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Proceed with the main logic after passing all checks
|
// 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 {
|
Ok(APIResponse {
|
||||||
status: StatusCode::OK,
|
status: StatusCode::OK,
|
||||||
body: json!({ "message": "User info saved successfully" }),
|
body: json!({ "message": "User info saved successfully" }),
|
||||||
|
@ -406,6 +406,17 @@ impl NotificationManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - User device info and settings
|
// 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<dyn std::error::Error>> {
|
||||||
|
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(
|
pub async fn save_user_device_info(
|
||||||
&self,
|
&self,
|
||||||
|
Reference in New Issue
Block a user