@@ -26,6 +26,7 @@ pub use self::options::Options;
26
26
pub use self :: signer:: NostrSigner ;
27
27
use self :: zapper:: { ZapDetails , ZapEntity } ;
28
28
use crate :: error:: Result ;
29
+ use crate :: pool:: result:: { SendEventOutput , SendOutput } ;
29
30
use crate :: relay:: options:: { NegentropyOptions , SubscribeAutoCloseOptions } ;
30
31
use crate :: relay:: { RelayBlacklist , RelayOptions } ;
31
32
use crate :: { HandleNotification , NostrDatabase , Relay } ;
@@ -390,37 +391,44 @@ impl Client {
390
391
. collect ( ) )
391
392
}
392
393
393
- pub async fn send_msg ( & self , msg : Arc < ClientMessage > ) -> Result < ( ) > {
394
- Ok ( self . inner . send_msg ( msg. as_ref ( ) . deref ( ) . clone ( ) ) . await ?)
394
+ pub async fn send_msg ( & self , msg : Arc < ClientMessage > ) -> Result < SendOutput > {
395
+ Ok ( self
396
+ . inner
397
+ . send_msg ( msg. as_ref ( ) . deref ( ) . clone ( ) )
398
+ . await ?
399
+ . into ( ) )
395
400
}
396
401
397
- pub async fn send_msg_to ( & self , urls : Vec < String > , msg : Arc < ClientMessage > ) -> Result < ( ) > {
402
+ pub async fn send_msg_to (
403
+ & self ,
404
+ urls : Vec < String > ,
405
+ msg : Arc < ClientMessage > ,
406
+ ) -> Result < SendOutput > {
398
407
Ok ( self
399
408
. inner
400
409
. send_msg_to ( urls, msg. as_ref ( ) . deref ( ) . clone ( ) )
401
- . await ?)
410
+ . await ?
411
+ . into ( ) )
402
412
}
403
413
404
- pub async fn send_event ( & self , event : Arc < Event > ) -> Result < Arc < EventId > > {
405
- Ok ( Arc :: new (
406
- self . inner
407
- . send_event ( event. as_ref ( ) . deref ( ) . clone ( ) )
408
- . await ?
409
- . into ( ) ,
410
- ) )
414
+ pub async fn send_event ( & self , event : Arc < Event > ) -> Result < SendEventOutput > {
415
+ Ok ( self
416
+ . inner
417
+ . send_event ( event. as_ref ( ) . deref ( ) . clone ( ) )
418
+ . await ?
419
+ . into ( ) )
411
420
}
412
421
413
422
pub async fn send_event_to (
414
423
& self ,
415
424
urls : Vec < String > ,
416
425
event : Arc < Event > ,
417
- ) -> Result < Arc < EventId > > {
418
- Ok ( Arc :: new (
419
- self . inner
420
- . send_event_to ( urls, event. as_ref ( ) . deref ( ) . clone ( ) )
421
- . await ?
422
- . into ( ) ,
423
- ) )
426
+ ) -> Result < SendEventOutput > {
427
+ Ok ( self
428
+ . inner
429
+ . send_event_to ( urls, event. as_ref ( ) . deref ( ) . clone ( ) )
430
+ . await ?
431
+ . into ( ) )
424
432
}
425
433
426
434
/// Signs the `EventBuilder` into an `Event` using the `NostrSigner`
@@ -436,13 +444,12 @@ impl Client {
436
444
/// Take an [`EventBuilder`], sign it by using the [`NostrSigner`] and broadcast to all relays.
437
445
///
438
446
/// Rise an error if the [`NostrSigner`] is not set.
439
- pub async fn send_event_builder ( & self , builder : Arc < EventBuilder > ) -> Result < Arc < EventId > > {
440
- Ok ( Arc :: new (
441
- self . inner
442
- . send_event_builder ( builder. as_ref ( ) . deref ( ) . clone ( ) )
443
- . await ?
444
- . into ( ) ,
445
- ) )
447
+ pub async fn send_event_builder ( & self , builder : Arc < EventBuilder > ) -> Result < SendEventOutput > {
448
+ Ok ( self
449
+ . inner
450
+ . send_event_builder ( builder. as_ref ( ) . deref ( ) . clone ( ) )
451
+ . await ?
452
+ . into ( ) )
446
453
}
447
454
448
455
/// Take an [`EventBuilder`], sign it by using the [`NostrSigner`] and broadcast to specific relays.
@@ -452,22 +459,20 @@ impl Client {
452
459
& self ,
453
460
urls : Vec < String > ,
454
461
builder : Arc < EventBuilder > ,
455
- ) -> Result < Arc < EventId > > {
456
- Ok ( Arc :: new (
457
- self . inner
458
- . send_event_builder_to ( urls, builder. as_ref ( ) . deref ( ) . clone ( ) )
459
- . await ?
460
- . into ( ) ,
461
- ) )
462
+ ) -> Result < SendEventOutput > {
463
+ Ok ( self
464
+ . inner
465
+ . send_event_builder_to ( urls, builder. as_ref ( ) . deref ( ) . clone ( ) )
466
+ . await ?
467
+ . into ( ) )
462
468
}
463
469
464
- pub async fn set_metadata ( & self , metadata : Arc < Metadata > ) -> Result < Arc < EventId > > {
465
- Ok ( Arc :: new (
466
- self . inner
467
- . set_metadata ( metadata. as_ref ( ) . deref ( ) )
468
- . await ?
469
- . into ( ) ,
470
- ) )
470
+ pub async fn set_metadata ( & self , metadata : Arc < Metadata > ) -> Result < SendEventOutput > {
471
+ Ok ( self
472
+ . inner
473
+ . set_metadata ( metadata. as_ref ( ) . deref ( ) )
474
+ . await ?
475
+ . into ( ) )
471
476
}
472
477
473
478
/// Encrypted direct msg
@@ -480,14 +485,13 @@ impl Client {
480
485
receiver : & PublicKey ,
481
486
msg : String ,
482
487
reply : Option < Arc < EventId > > ,
483
- ) -> Result < Arc < EventId > > {
488
+ ) -> Result < SendEventOutput > {
484
489
#[ allow( deprecated) ]
485
- Ok ( Arc :: new (
486
- self . inner
487
- . send_direct_msg ( * * receiver, msg, reply. map ( |r| * * r) )
488
- . await ?
489
- . into ( ) ,
490
- ) )
490
+ Ok ( self
491
+ . inner
492
+ . send_direct_msg ( * * receiver, msg, reply. map ( |r| * * r) )
493
+ . await ?
494
+ . into ( ) )
491
495
}
492
496
493
497
/// Send private direct message
@@ -499,55 +503,50 @@ impl Client {
499
503
receiver : & PublicKey ,
500
504
message : String ,
501
505
reply_to : Option < Arc < EventId > > ,
502
- ) -> Result < ( ) > {
506
+ ) -> Result < SendEventOutput > {
503
507
Ok ( self
504
508
. inner
505
509
. send_private_msg ( * * receiver, message, reply_to. map ( |t| * * t) )
506
- . await ?)
510
+ . await ?
511
+ . into ( ) )
507
512
}
508
513
509
514
/// Repost
510
515
pub async fn repost (
511
516
& self ,
512
517
event : Arc < Event > ,
513
518
relay_url : Option < String > ,
514
- ) -> Result < Arc < EventId > > {
515
- Ok ( Arc :: new (
516
- self . inner
517
- . repost ( event. as_ref ( ) . deref ( ) , relay_url. map ( UncheckedUrl :: from) )
518
- . await ?
519
- . into ( ) ,
520
- ) )
519
+ ) -> Result < SendEventOutput > {
520
+ Ok ( self
521
+ . inner
522
+ . repost ( event. as_ref ( ) . deref ( ) , relay_url. map ( UncheckedUrl :: from) )
523
+ . await ?
524
+ . into ( ) )
521
525
}
522
526
523
527
/// Like event
524
528
///
525
529
/// <https://github.com/nostr-protocol/nips/blob/master/25.md>
526
- pub async fn like ( & self , event : Arc < Event > ) -> Result < Arc < EventId > > {
527
- Ok ( Arc :: new (
528
- self . inner . like ( event. as_ref ( ) . deref ( ) ) . await ?. into ( ) ,
529
- ) )
530
+ pub async fn like ( & self , event : Arc < Event > ) -> Result < SendEventOutput > {
531
+ Ok ( self . inner . like ( event. as_ref ( ) . deref ( ) ) . await ?. into ( ) )
530
532
}
531
533
532
534
/// Disike event
533
535
///
534
536
/// <https://github.com/nostr-protocol/nips/blob/master/25.md>
535
- pub async fn dislike ( & self , event : Arc < Event > ) -> Result < Arc < EventId > > {
536
- Ok ( Arc :: new (
537
- self . inner . dislike ( event. as_ref ( ) . deref ( ) ) . await ?. into ( ) ,
538
- ) )
537
+ pub async fn dislike ( & self , event : Arc < Event > ) -> Result < SendEventOutput > {
538
+ Ok ( self . inner . dislike ( event. as_ref ( ) . deref ( ) ) . await ?. into ( ) )
539
539
}
540
540
541
541
/// React to an [`Event`]
542
542
///
543
543
/// <https://github.com/nostr-protocol/nips/blob/master/25.md>
544
- pub async fn reaction ( & self , event : Arc < Event > , reaction : String ) -> Result < Arc < EventId > > {
545
- Ok ( Arc :: new (
546
- self . inner
547
- . reaction ( event. as_ref ( ) . deref ( ) , reaction)
548
- . await ?
549
- . into ( ) ,
550
- ) )
544
+ pub async fn reaction ( & self , event : Arc < Event > , reaction : String ) -> Result < SendEventOutput > {
545
+ Ok ( self
546
+ . inner
547
+ . reaction ( event. as_ref ( ) . deref ( ) , reaction)
548
+ . await ?
549
+ . into ( ) )
551
550
}
552
551
553
552
/// Send a Zap!
@@ -571,28 +570,28 @@ impl Client {
571
570
receiver : & PublicKey ,
572
571
rumor : Arc < EventBuilder > ,
573
572
expiration : Option < Arc < Timestamp > > ,
574
- ) -> Result < ( ) > {
573
+ ) -> Result < SendEventOutput > {
575
574
Ok ( self
576
575
. inner
577
576
. gift_wrap (
578
577
* * receiver,
579
578
rumor. as_ref ( ) . deref ( ) . clone ( ) ,
580
579
expiration. map ( |t| * * t) ,
581
580
)
582
- . await ?)
581
+ . await ?
582
+ . into ( ) )
583
583
}
584
584
585
585
pub async fn file_metadata (
586
586
& self ,
587
587
description : String ,
588
588
metadata : Arc < FileMetadata > ,
589
- ) -> Result < Arc < EventId > > {
590
- Ok ( Arc :: new (
591
- self . inner
592
- . file_metadata ( description, metadata. as_ref ( ) . deref ( ) . clone ( ) )
593
- . await ?
594
- . into ( ) ,
595
- ) )
589
+ ) -> Result < SendEventOutput > {
590
+ Ok ( self
591
+ . inner
592
+ . file_metadata ( description, metadata. as_ref ( ) . deref ( ) . clone ( ) )
593
+ . await ?
594
+ . into ( ) )
596
595
}
597
596
598
597
pub async fn reconcile ( & self , filter : Arc < Filter > , opts : Arc < NegentropyOptions > ) -> Result < ( ) > {
0 commit comments