@@ -77,7 +77,7 @@ impl BroadcastChannel {
7777 pub async fn send_event ( & self , notification : Notification , to_user : & Uuid ) {
7878 let lock = self . channel . read ( ) . await ;
7979 if let Some ( sender) = lock. get ( to_user) {
80- match sender. send ( notification) {
80+ match sender. send ( notification. clone ( ) ) {
8181 Ok ( sc) => {
8282 info ! ( "Successfully sent {:?} broadcast event." , sc) ;
8383 }
@@ -86,11 +86,11 @@ impl BroadcastChannel {
8686 }
8787 }
8888 } else {
89- if let Err ( error) = self . cache . add_notification_for_user ( to_user, & notification) . await {
90- error ! ( "Failed to cache notification: {}" , error) ;
91- } ;
92- self . send_undeliverable_notifications ( notification, vec ! [ to_user. clone( ) ] ) . await ;
89+ self . send_undeliverable_notifications ( notification. clone ( ) , vec ! [ to_user. clone( ) ] ) . await ;
9390 }
91+ if let Err ( error) = self . cache . add_notification_for_user ( to_user, & notification) . await {
92+ error ! ( "Failed to cache notification: {}" , error) ;
93+ } ;
9494 }
9595
9696 pub async fn send_event_to_all ( & self , user_ids : Vec < Uuid > , notification : Notification ) {
@@ -107,11 +107,11 @@ impl BroadcastChannel {
107107 }
108108 }
109109 } else {
110- if let Err ( error) = self . cache . add_notification_for_user ( & user_id, & notification) . await {
111- error ! ( "Failed to cache notification: {}" , error) ;
112- } ;
113110 not_deliverable. push ( user_id) ;
114111 }
112+ if let Err ( error) = self . cache . add_notification_for_user ( & user_id, & notification) . await {
113+ error ! ( "Failed to cache notification: {}" , error) ;
114+ } ;
115115 }
116116 if not_deliverable. len ( ) > 0 {
117117 self . send_undeliverable_notifications ( notification, not_deliverable) . await ;
@@ -134,6 +134,7 @@ impl BroadcastChannel {
134134 }
135135
136136 pub async fn unsubscribe ( & self , user_id : Uuid ) {
137+ debug ! ( "Unsubscribing user {:?} from broadcasting events." , user_id) ;
137138 let mut lock = self . channel . write ( ) . await ;
138139 if let Some ( sender) = lock. get ( & user_id) {
139140 if sender. receiver_count ( ) > 0 {
0 commit comments