Skip to content

Commit

Permalink
Add dummy recipients to MMS messages with no recipients
Browse files Browse the repository at this point in the history
Calling 'getOrCreateThreadId' with an empty set of addresses will cause it
to complain:

"getThreadId: NO receipients specified -- NOT creating thread" (sic)

and then throw an exception:

"java.lang.IllegalArgumentException: Unable to find or allocate a thread ID."

So if an MMS message has no associated recipient addresses, we add a dummy one.

Closes: #150
  • Loading branch information
tmo1 committed Jan 17, 2024
1 parent 5543b4e commit 1b43bd9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion app/src/main/java/com/github/tmo1/sms_ie/ImportExportMessages.kt
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,17 @@ suspend fun importMessages(
threadIdMap), then we need to get a new thread_id and record the mapping
between the old and new ones in threadIdMap
*/
if (!messageMetadata.containsKey("thread_id")) {
if (!messageMetadata.containsKey("thread_id")) {/* Calling getOrCreateThreadId with an empty set of addresses
will cause it to complain:
"getThreadId: NO receipients specified -- NOT creating thread" (sic)
and then throw an exception:
"java.lang.IllegalArgumentException: Unable to find or allocate a thread ID."
So if an MMS message has no associated recipient addresses, we add a dummy one here.
See: https://github.com/tmo1/sms-ie/issues/150
*/
if (addresses.isEmpty()) {
addresses.add(ContentValues())
}
val newThreadId = Telephony.Threads.getOrCreateThreadId(
appContext,
addresses.map { x -> x.getAsString(Telephony.Mms.Addr.ADDRESS) }
Expand Down

0 comments on commit 1b43bd9

Please sign in to comment.