Skip to content

Commit d0b18bb

Browse files
authored
fix(notifications): resolve contact info from chat ID when group key is not E.164 (#902)
The backend changed group_key from an E.164 phone number to a base64-encoded chat ID. This caused applyContactChatStyle to produce an empty sender name and no contact photo, since the E.164 extraction (startsWith("+")) failed silently. Fall back to contactCoordinator.lookupContactByDmChatId to recover the sender's E.164 from the local contact mapping, restoring name resolution, photo loading, and formatted phone fallback. Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 86c65eb commit d0b18bb

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

apps/flipcash/shared/notifications/src/main/kotlin/com/flipcash/app/notifications/NotificationService.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import com.flipcash.app.core.util.Linkify
2727
import com.flipcash.shared.chat.ChatCoordinator
2828
import com.flipcash.app.tokens.TokenCoordinator
2929
import com.flipcash.services.controllers.PushController
30+
import com.flipcash.services.models.chat.ChatId
3031
import com.flipcash.services.models.NavigationTrigger
3132
import com.flipcash.services.models.NotificationCategory
3233
import com.flipcash.services.models.NotificationPayload
@@ -162,7 +163,7 @@ class NotificationService : FirebaseMessagingService(),
162163
}
163164

164165
val notificationId = if (chatId != null) {
165-
builder.applyContactChatStyle(chatId.hashCode(), groupKey, body)
166+
builder.applyContactChatStyle(chatId, groupKey, body)
166167
} else {
167168
builder.setContentTitle(title).setContentText(body)
168169
SecureRandom().nextInt(Int.MAX_VALUE)
@@ -184,11 +185,13 @@ class NotificationService : FirebaseMessagingService(),
184185
}
185186

186187
private suspend fun NotificationCompat.Builder.applyContactChatStyle(
187-
notificationId: Int,
188+
chatId: ChatId,
188189
groupKey: String?,
189190
body: String?,
190191
): Int {
192+
val notificationId = chatId.hashCode()
191193
val e164 = groupKey?.takeIf { it.startsWith("+") }
194+
?: contactCoordinator.lookupContactByDmChatId(chatId.toString())?.e164
192195
val contactPhoto = e164?.let { resolveContactPhoto(it) }
193196
val senderName = e164?.let { contactResolver.resolveName(it) } ?: ""
194197

0 commit comments

Comments
 (0)