mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-25 13:39:24 +00:00
Ignore unreadable wallpapers.
This commit is contained in:
committed by
Michelle Tang
parent
a4bf92b6a8
commit
a7da663d4f
@@ -8,10 +8,14 @@ import org.thoughtcrime.securesms.database.RecipientTable.RegisteredState
|
||||
import org.thoughtcrime.securesms.database.SignalDatabase
|
||||
import org.thoughtcrime.securesms.database.model.GroupRecord
|
||||
import org.thoughtcrime.securesms.database.model.RecipientRecord
|
||||
import org.thoughtcrime.securesms.dependencies.AppDependencies
|
||||
import org.thoughtcrime.securesms.groups.GroupId
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore
|
||||
import org.thoughtcrime.securesms.mms.PartAuthority
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences
|
||||
import org.thoughtcrime.securesms.util.Util
|
||||
import org.thoughtcrime.securesms.wallpaper.ChatWallpaper
|
||||
import org.thoughtcrime.securesms.wallpaper.UriChatWallpaper
|
||||
import java.util.LinkedList
|
||||
import java.util.Optional
|
||||
|
||||
@@ -20,6 +24,7 @@ import java.util.Optional
|
||||
* It's also helpful for java-kotlin interop, since there's so many optional fields.
|
||||
*/
|
||||
object RecipientCreator {
|
||||
|
||||
@JvmOverloads
|
||||
@JvmStatic
|
||||
fun forId(recipientId: RecipientId, resolved: Boolean = false): Recipient {
|
||||
@@ -180,7 +185,7 @@ object RecipientCreator {
|
||||
capabilities = record.capabilities,
|
||||
storageId = record.storageId,
|
||||
mentionSetting = record.mentionSetting,
|
||||
wallpaperValue = record.wallpaper,
|
||||
wallpaperValue = record.wallpaper?.validate(),
|
||||
chatColorsValue = record.chatColors,
|
||||
avatarColor = avatarColor ?: record.avatarColor,
|
||||
about = record.about,
|
||||
@@ -239,4 +244,18 @@ object RecipientCreator {
|
||||
|
||||
return forCallLink(null, record, AvatarColor.UNKNOWN)
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private fun ChatWallpaper.validate(): ChatWallpaper? {
|
||||
if (this !is UriChatWallpaper) {
|
||||
return this
|
||||
}
|
||||
|
||||
return try {
|
||||
PartAuthority.getAttachmentStream(AppDependencies.application, this.uri).close()
|
||||
this
|
||||
} catch (_: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user