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

Commit

Permalink
fixes for creating new groups
Browse files Browse the repository at this point in the history
- sets the subject/name properly
- ensures group is created even if no one is added, and no message sent
  • Loading branch information
iamironrabbit committed May 30, 2018
1 parent ef47946 commit b7bfc6c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
3 changes: 3 additions & 0 deletions app/src/main/java/org/awesomeapp/messenger/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,9 @@ protected String doInBackground(String... params) {
{
mRequestedChatId = session.getId();
session.markAsSeen(); // We created this, so mark as seen
session.sendTypingStatus(true);
session.setMuted(false);
session.setGroupChatSubject(subject);
publishProgress(mRequestedChatId);

} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ public void sendPacket(org.jivesoftware.smack.packet.Stanza packet) {
void postpone(final org.jivesoftware.smack.packet.Stanza packet) {
if (packet instanceof org.jivesoftware.smack.packet.Message) {
boolean groupChat = ((org.jivesoftware.smack.packet.Message) packet).getType().equals( org.jivesoftware.smack.packet.Message.Type.groupchat);
ChatSession session = findOrCreateSession(packet.getTo().toString(), groupChat);
ChatSession session = findOrCreateSession(packet.getTo().toString(), groupChat, false);
if (session != null)
session.onMessagePostponed(packet.getStanzaId());
}
Expand Down Expand Up @@ -2451,7 +2451,7 @@ private void handleMessage (org.jivesoftware.smack.packet.Message smackMessage,

}

ChatSession session = findOrCreateSession(smackMessage.getFrom().toString(), isGroupMessage);
ChatSession session = findOrCreateSession(smackMessage.getFrom().toString(), isGroupMessage, false);

if (session != null) //not subscribed so don't do anything
{
Expand Down Expand Up @@ -2670,7 +2670,7 @@ public void run() {
}
}

private ChatSession findOrCreateSession(String address, boolean groupChat) {
private ChatSession findOrCreateSession(String address, boolean groupChat, boolean isNew) {

try {

Expand Down Expand Up @@ -2708,7 +2708,7 @@ private ChatSession findOrCreateSession(String address, boolean groupChat) {
//create a session
if (session == null) {
ImEntity participant = findOrCreateParticipant(xAddr.getAddress(), true);
session = mSessionManager.createChatSession(participant, participant == null);
session = mSessionManager.createChatSession(participant, true);
if (session != null)
((ChatGroup) session.getParticipant()).setName(muc.getSubject());
}
Expand Down Expand Up @@ -3559,7 +3559,7 @@ protected void doAddContactToListAsync(Contact contact, ContactList list, boolea
}
}

ChatSession session = findOrCreateSession(contact.getAddress().toString(), false);
ChatSession session = findOrCreateSession(contact.getAddress().toString(), false, true);

if (session != null)
session.setSubscribed(autoSubscribedPresence);
Expand Down Expand Up @@ -3614,7 +3614,7 @@ public void declineSubscriptionRequest(Contact contact) {
e.printStackTrace();
}

ChatSession session = findOrCreateSession(contact.getAddress().getAddress(), false);
ChatSession session = findOrCreateSession(contact.getAddress().getAddress(), false, false);

if (session != null)
session.setSubscribed(false);
Expand Down Expand Up @@ -3669,7 +3669,7 @@ public void approveSubscriptionRequest(final Contact contact) {
mContactListManager.getSubscriptionRequestListener().onSubscriptionApproved(contact, mProviderId, mAccountId);
getSubscriptionRequestListener().onSubScriptionChanged(contact,mProviderId,mAccountId,subType,subStatus);

ChatSession session = findOrCreateSession(contact.getAddress().toString(), false);
ChatSession session = findOrCreateSession(contact.getAddress().toString(), false, true);

if (session != null)
session.setSubscribed(true);
Expand Down Expand Up @@ -4760,7 +4760,7 @@ private void handleSubscribeRequest (Jid jid) throws ImException, RemoteExceptio
mContactListManager.getSubscriptionRequestListener().onSubScriptionRequest(contact, mProviderId, mAccountId);
}

ChatSession session = findOrCreateSession(jid.toString(), false);
ChatSession session = findOrCreateSession(jid.toString(), false, true);


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public IChatSession createMultiUserChatSession(String roomAddress, String subjec
groupMan.createChatGroupAsync(roomAddress, subject, nickname);

ChatGroup chatGroup = groupMan.getChatGroup(address);
chatGroup.setName(subject);

if (chatGroup != null && mConnection.getState() == ImConnection.LOGGED_IN)
{
Expand Down

0 comments on commit b7bfc6c

Please sign in to comment.