archive destoryed mucs when registering that bookmark has been removed
This commit is contained in:
		
							parent
							
								
									9d849f540f
								
							
						
					
					
						commit
						b9952f27fd
					
				| @ -13,6 +13,7 @@ import java.util.ArrayList; | |||||||
| import java.util.Collection; | import java.util.Collection; | ||||||
| import java.util.HashSet; | import java.util.HashSet; | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  | import java.util.Set; | ||||||
| import java.util.concurrent.CopyOnWriteArrayList; | import java.util.concurrent.CopyOnWriteArrayList; | ||||||
| import java.util.concurrent.CopyOnWriteArraySet; | import java.util.concurrent.CopyOnWriteArraySet; | ||||||
| 
 | 
 | ||||||
| @ -472,6 +473,17 @@ public class Account extends AbstractEntity { | |||||||
|         this.bookmarks = bookmarks; |         this.bookmarks = bookmarks; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public Set<Jid> getBookmarkedJids() { | ||||||
|  |         final Set<Jid> jids = new HashSet<>(); | ||||||
|  |         for(final Bookmark bookmark : this.bookmarks) { | ||||||
|  |             final Jid jid = bookmark.getJid(); | ||||||
|  |             if (jid != null) { | ||||||
|  |                 jids.add(jid.asBareJid()); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return jids; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public boolean hasBookmarkFor(final Jid conferenceJid) { |     public boolean hasBookmarkFor(final Jid conferenceJid) { | ||||||
|         return getBookmark(conferenceJid) != null; |         return getBookmark(conferenceJid) != null; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -1410,6 +1410,7 @@ public class XmppConnectionService extends Service { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     public void processBookmarks(Account account, Element storage, final boolean pep) { |     public void processBookmarks(Account account, Element storage, final boolean pep) { | ||||||
|  |         final Set<Jid> previousBookmarks = account.getBookmarkedJids(); | ||||||
|         final HashMap<Jid, Bookmark> bookmarks = new HashMap<>(); |         final HashMap<Jid, Bookmark> bookmarks = new HashMap<>(); | ||||||
|         final boolean synchronizeWithBookmarks = synchronizeWithBookmarks(); |         final boolean synchronizeWithBookmarks = synchronizeWithBookmarks(); | ||||||
|         if (storage != null) { |         if (storage != null) { | ||||||
| @ -1423,6 +1424,7 @@ public class XmppConnectionService extends Service { | |||||||
|                     if (bookmark.getJid() == null) { |                     if (bookmark.getJid() == null) { | ||||||
|                         continue; |                         continue; | ||||||
|                     } |                     } | ||||||
|  |                     previousBookmarks.remove(bookmark.getJid().asBareJid()); | ||||||
|                     Conversation conversation = find(bookmark); |                     Conversation conversation = find(bookmark); | ||||||
|                     if (conversation != null) { |                     if (conversation != null) { | ||||||
|                         if (conversation.getMode() != Conversation.MODE_MULTI) { |                         if (conversation.getMode() != Conversation.MODE_MULTI) { | ||||||
| @ -1439,6 +1441,16 @@ public class XmppConnectionService extends Service { | |||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|  |             if (pep && synchronizeWithBookmarks) { | ||||||
|  |                 Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": " + previousBookmarks.size() + " bookmarks have been removed"); | ||||||
|  |                 for (Jid jid : previousBookmarks) { | ||||||
|  |                     final Conversation conversation = find(account, jid); | ||||||
|  |                     if (conversation != null && conversation.getMucOptions().getError() == MucOptions.Error.DESTROYED) { | ||||||
|  |                         Log.d(Config.LOGTAG,account.getJid().asBareJid()+": archiving destroyed conference ("+conversation.getJid()+") after receiving pep"); | ||||||
|  |                         archiveConversation(conversation, false); | ||||||
|  |                     } | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|         } |         } | ||||||
|         account.setBookmarks(new CopyOnWriteArrayList<>(bookmarks.values())); |         account.setBookmarks(new CopyOnWriteArrayList<>(bookmarks.values())); | ||||||
|     } |     } | ||||||
| @ -1479,8 +1491,7 @@ public class XmppConnectionService extends Service { | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| 	private void pushNodeAndEnforcePublishOptions(final Account account, final String node, final Element element, final Bundle options, final boolean retry) { | 	private void pushNodeAndEnforcePublishOptions(final Account account, final String node, final Element element, final Bundle options, final boolean retry) { | ||||||
|         IqPacket packet = mIqGenerator.publishElement(node, element, options); |         final IqPacket packet = mIqGenerator.publishElement(node, element, options); | ||||||
|         Log.d(Config.LOGTAG,packet.toString()); |  | ||||||
|         sendIqPacket(account, packet, (a, response) -> { |         sendIqPacket(account, packet, (a, response) -> { | ||||||
|             if (response.getType() == IqPacket.TYPE.RESULT) { |             if (response.getType() == IqPacket.TYPE.RESULT) { | ||||||
|                 return; |                 return; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Daniel Gultsch
						Daniel Gultsch