Skip to content

Commit

Permalink
on first sync get events since last check
Browse files Browse the repository at this point in the history
  • Loading branch information
johncantrell97 committed Apr 23, 2024
1 parent 6a4a7ec commit 7815ce0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
5 changes: 3 additions & 2 deletions mutiny-core/src/nostr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,9 @@ impl<S: MutinyStorage, P: PrimalApi, C: NostrClient> NostrManager<S, P, C> {
let time_stamp = match self.storage.get_nwc_sync_time()? {
None => {
let now = Timestamp::now();
self.storage.set_nwc_sync_time(now.as_u64())?;
now
let since_last_check = Timestamp::from(now.as_u64() - 20);
self.storage.set_nwc_sync_time(since_last_check.as_u64())?;
since_last_check
}
Some(time) => Timestamp::from(time + 1), // add one so we get only new events
};
Expand Down
18 changes: 9 additions & 9 deletions mutiny-core/src/nostr/nwc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,9 +421,7 @@ impl NostrWalletConnect {
let mut needs_save = false;
let mut needs_delete = false;
let mut result = None;
if event.kind == Kind::WalletConnectRequest
&& event.pubkey == client_pubkey
{
if event.kind == Kind::WalletConnectRequest && event.pubkey == client_pubkey {
let server_key = self.server_key.secret_key()?;

let decrypted = decrypt(server_key, &client_pubkey, &event.content)?;
Expand All @@ -447,12 +445,14 @@ impl NostrWalletConnect {

// only respond to commands sent to active profiles
if !self.profile.active() {
return self.get_skipped_error_event(
&event,
req.method,
ErrorCode::Other,
"Nostr profile inactive".to_string(),
).map(Some);
return self
.get_skipped_error_event(
&event,
req.method,
ErrorCode::Other,
"Nostr profile inactive".to_string(),
)
.map(Some);
}

// only respond to commands that are allowed by the profile
Expand Down

0 comments on commit 7815ce0

Please sign in to comment.