Properly look up participants in MMS group conversations

Application was always picking first participant when tapping on avatars
in conversations. It was also using first participant for MMS notifications.

This stores sender's phone number in the database, so it can be used to look
up correct participant in the list of participants. If matching on number fails,
matching on name is attempted. If both of these fail, it falls back to previous
behavior, which is just picking the first participant.

This may also be connected to #32, but I am not sure, since this should just
be related to behavior when tapping on avatars. Mixing up avatars in the
conversation should be a different issue.

This closes #433, closes #500, closes #384
This commit is contained in:
Ensar Sarajčić 2023-07-07 10:48:35 +02:00
parent b0da7bad31
commit daf11dc6fd
7 changed files with 44 additions and 8 deletions

View file

@ -116,7 +116,8 @@ fun Context.getMessages(
SimpleContact(0, 0, participantPhoto.name, photoUri, arrayListOf(phoneNumber), ArrayList(), ArrayList())
}
val isMMS = false
val message = Message(id, body, type, status, ArrayList(participants), date, read, thread, isMMS, null, senderName, photoUri, subscriptionId)
val message =
Message(id, body, type, status, ArrayList(participants), date, read, thread, isMMS, null, senderNumber, senderName, photoUri, subscriptionId)
messages.add(message)
}
@ -189,17 +190,19 @@ fun Context.getMMS(threadId: Long? = null, getImageResolutions: Boolean = false,
val isMMS = true
val attachment = getMmsAttachment(mmsId, getImageResolutions)
val body = attachment.text
var senderNumber = ""
var senderName = ""
var senderPhotoUri = ""
if (type != Mms.MESSAGE_BOX_SENT && type != Mms.MESSAGE_BOX_FAILED) {
val number = getMMSSender(mmsId)
val namePhoto = getNameAndPhotoFromPhoneNumber(number)
senderNumber = getMMSSender(mmsId)
val namePhoto = getNameAndPhotoFromPhoneNumber(senderNumber)
senderName = namePhoto.name
senderPhotoUri = namePhoto.photoUri ?: ""
}
val message = Message(mmsId, body, type, status, participants, date, read, threadId, isMMS, attachment, senderName, senderPhotoUri, subscriptionId)
val message =
Message(mmsId, body, type, status, participants, date, read, threadId, isMMS, attachment, senderNumber, senderName, senderPhotoUri, subscriptionId)
messages.add(message)
participants.forEach {