Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
fix NPE with receiving group chat messages
Browse files Browse the repository at this point in the history
  • Loading branch information
iamironrabbit committed May 31, 2018
1 parent 6ac10c4 commit 92e7393
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1136,11 +1136,12 @@ public boolean onIncomingMessage(ChatSession ses, final org.awesomeapp.messenger
String username = msg.getFrom().getAddress();
String bareUsername = msg.getFrom().getBareAddress();
String nickname = getNickName(username);
Contact contact = null;

try {
contact = mConnection.getContactListManager().getContactByAddress(bareUsername);
nickname = contact.getName();
Contact contact = mConnection.getContactListManager().getContactByAddress(bareUsername);
if (contact != null)
nickname = contact.getName();

} catch (Exception e) {
return false;
}
Expand Down Expand Up @@ -1233,13 +1234,17 @@ else if (displayType.equals("image"))
if (!isMuted()) {
ChatGroup group = (ChatGroup) ses.getParticipant();
try {
contact = mConnection.getContactListManager().getContactByAddress(nickname);
nickname = contact.getName();
Contact contact = mConnection.getContactListManager().getContactByAddress(nickname);
if (contact != null) {
nickname = contact.getName();

if (!TextUtils.isEmpty(nickname))
nickname = nickname.split("@")[0];
}

} catch (Exception e) {
}

nickname = nickname.split("@")[0];

mStatusBarNotifier.notifyGroupChat(mConnection.getProviderId(), mConnection.getAccountId(),
getId(), group.getAddress().getBareAddress(), group.getName(), nickname, body, false);
}
Expand Down

0 comments on commit 92e7393

Please sign in to comment.