@@ -95,7 +95,7 @@ public void onReceived() {
9595
9696 private void handleNotification () {
9797 Ejson receivedEjson = safeFromJson (mBundle .getString ("ejson" , "{}" ), Ejson .class );
98-
98+
9999 if (receivedEjson != null && receivedEjson .notificationType != null && receivedEjson .notificationType .equals ("message-id-only" )) {
100100 Log .d (TAG , "Detected message-id-only notification, will fetch full content from server" );
101101 loadNotificationAndProcess (receivedEjson );
@@ -202,8 +202,12 @@ private void showNotification(Bundle bundle, Ejson ejson, String notId) {
202202 boolean hasSender = ejson != null && ejson .sender != null ;
203203 String title = bundle .getString ("title" );
204204
205+ String displaySenderName = (ejson != null && ejson .senderName != null && !ejson .senderName .isEmpty ())
206+ ? ejson .senderName
207+ : (hasSender ? ejson .sender .username : title );
208+
205209 bundle .putLong ("time" , new Date ().getTime ());
206- bundle .putString ("username" , hasSender ? ejson . sender . username : title );
210+ bundle .putString ("username" , displaySenderName );
207211 bundle .putString ("senderId" , hasSender ? ejson .sender ._id : "1" );
208212
209213 String avatarUri = ejson != null ? ejson .getAvatarUri () : null ;
@@ -291,19 +295,6 @@ private Notification.Builder buildNotification(int notificationId) {
291295
292296 // Determine the correct title based on notification type
293297 String notificationTitle = title ;
294- if (ejson != null && ejson .type != null ) {
295- if ("p" .equals (ejson .type ) || "c" .equals (ejson .type )) {
296- // For groups/channels, use room name if available, otherwise fall back to title
297- notificationTitle = (ejson .name != null && !ejson .name .isEmpty ()) ? ejson .name : title ;
298- } else if ("d" .equals (ejson .type )) {
299- // For direct messages, use title (sender name from server)
300- notificationTitle = title ;
301- } else if ("l" .equals (ejson .type )) {
302- // For omnichannel, use sender name if available, otherwise fall back to title
303- notificationTitle = (ejson .sender != null && ejson .sender .name != null && !ejson .sender .name .isEmpty ())
304- ? ejson .sender .name : title ;
305- }
306- }
307298
308299 if (ENABLE_VERBOSE_LOGS ) {
309300 Log .d (TAG , "[buildNotification] notId=" + notId );
@@ -465,19 +456,6 @@ private void notificationStyle(Notification.Builder notification, int notId, Bun
465456 // Determine the correct conversation title based on notification type
466457 Ejson bundleEjson = safeFromJson (bundle .getString ("ejson" , "{}" ), Ejson .class );
467458 String conversationTitle = title ;
468- if (bundleEjson != null && bundleEjson .type != null ) {
469- if ("p" .equals (bundleEjson .type ) || "c" .equals (bundleEjson .type )) {
470- // For groups/channels, use room name if available, otherwise fall back to title
471- conversationTitle = (bundleEjson .name != null && !bundleEjson .name .isEmpty ()) ? bundleEjson .name : title ;
472- } else if ("d" .equals (bundleEjson .type )) {
473- // For direct messages, use title (sender name from server)
474- conversationTitle = title ;
475- } else if ("l" .equals (bundleEjson .type )) {
476- // For omnichannel, use sender name if available, otherwise fall back to title
477- conversationTitle = (bundleEjson .sender != null && bundleEjson .sender .name != null && !bundleEjson .sender .name .isEmpty ())
478- ? bundleEjson .sender .name : title ;
479- }
480- }
481459 messageStyle .setConversationTitle (conversationTitle );
482460
483461 if (bundles != null ) {
@@ -489,15 +467,17 @@ private void notificationStyle(Notification.Builder notification, int notId, Bun
489467 Ejson ejson = safeFromJson (data .getString ("ejson" , "{}" ), Ejson .class );
490468 String m = extractMessage (message , ejson );
491469
470+ String displaySenderName = (ejson != null && ejson .senderName != null && !ejson .senderName .isEmpty ())
471+ ? ejson .senderName
472+ : (ejson != null && ejson .sender != null ? ejson .sender .username : title );
473+
492474 if (Build .VERSION .SDK_INT < Build .VERSION_CODES .P ) {
493- String senderName = ejson != null ? ejson .senderName : "Unknown" ;
494- messageStyle .addMessage (m , timestamp , senderName );
475+ messageStyle .addMessage (m , timestamp , displaySenderName );
495476 } else {
496477 Bitmap avatar = getAvatar (avatarUri );
497- String senderName = ejson != null ? ejson .senderName : "Unknown" ;
498478 Person .Builder senderBuilder = new Person .Builder ()
499479 .setKey (senderId )
500- .setName (senderName );
480+ .setName (displaySenderName );
501481
502482 if (avatar != null ) {
503483 senderBuilder .setIcon (Icon .createWithBitmap (avatar ));
0 commit comments