@@ -375,7 +375,10 @@ func (s *transactionServer) Swap(streamer transactionpb.Transaction_SwapServer)
375
375
376
376
log .Debug ("submitted transaction" )
377
377
378
- s .bestEffortNotifyUserOfSwapInProgress (ctx , owner )
378
+ err = s .bestEffortNotifyUserOfSwapInProgress (ctx , owner )
379
+ if err != nil {
380
+ log .WithError (err ).Warn ("failure notifying user of swap in progress" )
381
+ }
379
382
380
383
if ! initiateReq .WaitForBlockchainStatus {
381
384
err = streamer .Send (& transactionpb.SwapResponse {
@@ -488,13 +491,13 @@ func (s *transactionServer) validateSwap(
488
491
return nil
489
492
}
490
493
491
- func (s * transactionServer ) bestEffortNotifyUserOfSwapInProgress (ctx context.Context , owner * common.Account ) {
494
+ func (s * transactionServer ) bestEffortNotifyUserOfSwapInProgress (ctx context.Context , owner * common.Account ) error {
492
495
// Avoid spamming users chat messages due to retries of the Swap RPC within
493
496
// small periods of time. Implementation isn't perfect, but we'll be updating
494
497
// notifications later anyways.
495
498
lastNotificationTs , ok := swapNotificationTimeByOwner [owner .PublicKey ().ToBase58 ()]
496
499
if ok && time .Since (lastNotificationTs ) < time .Minute {
497
- return
500
+ return nil
498
501
}
499
502
swapNotificationTimeByOwner [owner .PublicKey ().ToBase58 ()] = time .Now ()
500
503
@@ -509,28 +512,28 @@ func (s *transactionServer) bestEffortNotifyUserOfSwapInProgress(ctx context.Con
509
512
var protoChatMessage chatpb.ChatMessage
510
513
err := proto .Unmarshal (chatMessageRecords [0 ].Data , & protoChatMessage )
511
514
if err != nil {
512
- return
515
+ return errors . Wrap ( err , "error unmarshalling proto chat message" )
513
516
}
514
517
515
518
switch typed := protoChatMessage .Content [0 ].Type .(type ) {
516
519
case * chatpb.Content_Localized :
517
520
if typed .Localized .KeyOrText != localization .ChatMessageUsdcDeposited {
518
- return
521
+ return nil
519
522
}
520
523
}
521
524
case chat .ErrMessageNotFound :
522
525
default :
523
- return
526
+ return errors . Wrap ( err , "error fetching chat messages" )
524
527
}
525
528
526
529
chatMessage , err := chat_util .NewUsdcBeingConvertedMessage ()
527
530
if err != nil {
528
- return
531
+ return errors . Wrap ( err , "error creating chat message" )
529
532
}
530
533
531
534
canPush , err := chat_util .SendKinPurchasesMessage (ctx , s .data , owner , chatMessage )
532
535
if err != nil {
533
- return
536
+ return errors . Wrap ( err , "error sending chat message" )
534
537
}
535
538
536
539
if canPush {
@@ -543,6 +546,8 @@ func (s *transactionServer) bestEffortNotifyUserOfSwapInProgress(ctx context.Con
543
546
chatMessage ,
544
547
)
545
548
}
549
+
550
+ return nil
546
551
}
547
552
548
553
func (s * transactionServer ) mustLoadSwapSubsidizer (ctx context.Context ) {
0 commit comments