feat: resend messages after authentication (#137)
* resend failed message * update settings
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
use std::cmp::Ordering;
|
||||
use std::hash::{Hash, Hasher};
|
||||
use std::time::Duration;
|
||||
|
||||
use anyhow::Error;
|
||||
use common::display::ReadableProfile;
|
||||
use common::event::EventUtils;
|
||||
use global::nostr_client;
|
||||
use global::constants::SEND_RETRY;
|
||||
use global::{css, nostr_client};
|
||||
use gpui::{App, AppContext, Context, EventEmitter, SharedString, Task};
|
||||
use itertools::Itertools;
|
||||
use nostr_sdk::prelude::*;
|
||||
@@ -472,7 +474,32 @@ impl Room {
|
||||
.await
|
||||
{
|
||||
Ok(output) => {
|
||||
reports.push(SendReport::output(receiver, output));
|
||||
if output
|
||||
.failed
|
||||
.iter()
|
||||
.any(|(_, msg)| msg.starts_with("auth-required:"))
|
||||
{
|
||||
let id = output.id();
|
||||
|
||||
// Wait for authenticated and resent event successfully
|
||||
for attempt in 0..=SEND_RETRY {
|
||||
// Check if event was successfully resent
|
||||
if let Some(output) =
|
||||
css().resent_ids.read().await.iter().find(|o| o.id() == id)
|
||||
{
|
||||
reports.push(SendReport::output(receiver, output.to_owned()));
|
||||
break;
|
||||
}
|
||||
|
||||
if attempt == SEND_RETRY {
|
||||
break;
|
||||
}
|
||||
|
||||
smol::Timer::after(Duration::from_secs(1)).await;
|
||||
}
|
||||
} else {
|
||||
reports.push(SendReport::output(receiver, output));
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
if let nostr_sdk::client::Error::PrivateMsgRelaysNotFound = e {
|
||||
|
||||
Reference in New Issue
Block a user