Skip to content

Commit

Permalink
Merge pull request #1430 from bemusementpark/fix-null-display-name
Browse files Browse the repository at this point in the history
Fix NPE on null display name
  • Loading branch information
bemusementpark authored Mar 13, 2024
2 parents 3dee7ec + 3cba05e commit 36edca8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ open class Storage(
}

override fun getUserProfile(): Profile {
val displayName = TextSecurePreferences.getProfileName(context)!!
val displayName = TextSecurePreferences.getProfileName(context)
val profileKey = ProfileKeyUtil.getProfileKey(context)
val profilePictureUrl = TextSecurePreferences.getProfilePictureURL(context)
return Profile(displayName, profileKey, profilePictureUrl)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import com.google.protobuf.ByteString
import org.session.libsignal.utilities.Log
import org.session.libsignal.protos.SignalServiceProtos

class Profile() {
var displayName: String? = null
var profileKey: ByteArray? = null
class Profile(
var displayName: String? = null,
var profileKey: ByteArray? = null,
var profilePictureURL: String? = null
) {

companion object {
const val TAG = "Profile"
Expand All @@ -25,12 +26,6 @@ class Profile() {
}
}

constructor(displayName: String, profileKey: ByteArray? = null, profilePictureURL: String? = null) : this() {
this.displayName = displayName
this.profileKey = profileKey
this.profilePictureURL = profilePictureURL
}

fun toProto(): SignalServiceProtos.DataMessage? {
val displayName = displayName
if (displayName == null) {
Expand Down

0 comments on commit 36edca8

Please sign in to comment.