@@ -207,6 +207,82 @@ pub enum SignalEvent {
207207 Error ( String ) ,
208208}
209209
210+ impl SignalEvent {
211+ /// Format this event for debug logging with PII redacted.
212+ pub fn redacted_summary ( & self ) -> String {
213+ use crate :: debug_log:: { mask_phone, mask_body} ;
214+ match self {
215+ Self :: MessageReceived ( msg) => format ! (
216+ "MessageReceived(from={}, body={}, attachments={}, group={})" ,
217+ mask_phone( & msg. source) ,
218+ msg. body. as_deref( ) . map_or( "[none]" . to_string( ) , mask_body) ,
219+ msg. attachments. len( ) ,
220+ msg. group_id. is_some( ) ,
221+ ) ,
222+ Self :: ReceiptReceived { sender, receipt_type, timestamps } => format ! (
223+ "ReceiptReceived({receipt_type} from={}, count={})" ,
224+ mask_phone( sender) , timestamps. len( ) ,
225+ ) ,
226+ Self :: SendTimestamp { rpc_id, server_ts } => format ! (
227+ "SendTimestamp(rpc={rpc_id}, ts={server_ts})" ,
228+ ) ,
229+ Self :: SendFailed { rpc_id } => format ! ( "SendFailed(rpc={rpc_id})" ) ,
230+ Self :: TypingIndicator { sender, is_typing, .. } => format ! (
231+ "TypingIndicator(from={}, typing={is_typing})" ,
232+ mask_phone( sender) ,
233+ ) ,
234+ Self :: ReactionReceived { conv_id, emoji, sender, target_timestamp, is_remove, .. } => format ! (
235+ "ReactionReceived(conv={}, from={}, emoji={emoji}, target_ts={target_timestamp}, remove={is_remove})" ,
236+ mask_phone( conv_id) , mask_phone( sender) ,
237+ ) ,
238+ Self :: EditReceived { conv_id, target_timestamp, new_body, .. } => format ! (
239+ "EditReceived(conv={}, target_ts={target_timestamp}, body={})" ,
240+ mask_phone( conv_id) , mask_body( new_body) ,
241+ ) ,
242+ Self :: RemoteDeleteReceived { conv_id, target_timestamp, .. } => format ! (
243+ "RemoteDeleteReceived(conv={}, target_ts={target_timestamp})" ,
244+ mask_phone( conv_id) ,
245+ ) ,
246+ Self :: PinReceived { conv_id, target_timestamp, .. } => format ! (
247+ "PinReceived(conv={}, target_ts={target_timestamp})" ,
248+ mask_phone( conv_id) ,
249+ ) ,
250+ Self :: UnpinReceived { conv_id, target_timestamp, .. } => format ! (
251+ "UnpinReceived(conv={}, target_ts={target_timestamp})" ,
252+ mask_phone( conv_id) ,
253+ ) ,
254+ Self :: PollCreated { conv_id, timestamp, .. } => format ! (
255+ "PollCreated(conv={}, ts={timestamp})" ,
256+ mask_phone( conv_id) ,
257+ ) ,
258+ Self :: PollVoteReceived { conv_id, target_timestamp, voter, .. } => format ! (
259+ "PollVoteReceived(conv={}, target_ts={target_timestamp}, voter={})" ,
260+ mask_phone( conv_id) , mask_phone( voter) ,
261+ ) ,
262+ Self :: PollTerminated { conv_id, target_timestamp } => format ! (
263+ "PollTerminated(conv={}, target_ts={target_timestamp})" ,
264+ mask_phone( conv_id) ,
265+ ) ,
266+ Self :: SystemMessage { conv_id, body, .. } => format ! (
267+ "SystemMessage(conv={}, body={})" ,
268+ mask_phone( conv_id) , mask_body( body) ,
269+ ) ,
270+ Self :: ExpirationTimerChanged { conv_id, seconds, .. } => format ! (
271+ "ExpirationTimerChanged(conv={}, seconds={seconds})" ,
272+ mask_phone( conv_id) ,
273+ ) ,
274+ Self :: ReadSyncReceived { read_messages } => format ! (
275+ "ReadSyncReceived(count={})" ,
276+ read_messages. len( ) ,
277+ ) ,
278+ Self :: ContactList ( contacts) => format ! ( "ContactList(count={})" , contacts. len( ) ) ,
279+ Self :: GroupList ( groups) => format ! ( "GroupList(count={})" , groups. len( ) ) ,
280+ Self :: IdentityList ( ids) => format ! ( "IdentityList(count={})" , ids. len( ) ) ,
281+ Self :: Error ( e) => format ! ( "Error({e})" ) ,
282+ }
283+ }
284+ }
285+
210286/// A message from Signal
211287#[ derive( Debug , Clone ) ]
212288pub struct SignalMessage {
0 commit comments