.limitResultsToJid(userOne) .afterUid(lastMessageArchiveUid) .build();
@Test public void checkWithJidFilter() throws Exception { Jid jid = JidTestUtil.BARE_JID_1; MamQueryArgs mamQueryArgs = MamQueryArgs.builder().limitResultsToJid(jid).build(); DataForm dataForm = mamQueryArgs.getDataForm(); List<String> fields = new ArrayList<>(); fields.add("with"); List<CharSequence> values = new ArrayList<>(); values.add(jid); assertEquals(getMamXMemberWith(fields, values), dataForm.toXML(null).toString()); }
@SmackIntegrationTest public void mamDecryptionTest() throws XMPPException.XMPPErrorException, SmackException.NotLoggedInException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException, CryptoFailedException, UndecidedOmemoIdentityException { // Make sure, Bobs server stores messages in the archive MamManager bobsMamManager = MamManager.getInstanceFor(bob.getConnection()); bobsMamManager.enableMamForAllMessages(); bobsMamManager.setDefaultBehavior(MamPrefsIQ.DefaultBehavior.always); // Prevent bob from automatically decrypting MAM messages. bob.stopStanzaAndPEPListeners(); String body = "This message will be stored in MAM!"; OmemoMessage.Sent encrypted = alice.encrypt(bob.getOwnJid(), body); alice.getConnection().sendStanza(encrypted.asMessage(bob.getOwnJid())); MamManager.MamQuery query = bobsMamManager.queryArchive(MamManager.MamQueryArgs.builder().limitResultsToJid(alice.getOwnJid()).build()); assertEquals(1, query.getMessageCount()); List<MessageOrOmemoMessage> decryptedMamQuery = bob.decryptMamQueryResult(query); assertEquals(1, decryptedMamQuery.size()); assertEquals(body, decryptedMamQuery.get(decryptedMamQuery.size() - 1).getOmemoMessage().getBody()); } }
.limitResultsSince(start) .limitResultsBefore(end) .limitResultsToJid(withJid) .withAdditionalFormFields(additionalFields) .build();
public MamQuery queryMostRecentPage(Jid jid, int max) throws NoResponseException, XMPPErrorException, NotConnectedException, NotLoggedInException, InterruptedException { MamQueryArgs mamQueryArgs = MamQueryArgs.builder() // Produces an empty <before/> element for XEP-0059 § 2.5 .queryLastPage() .limitResultsToJid(jid) .setResultPageSize(max) .build(); return queryArchive(mamQueryArgs); }
.limitResultsToJid(userOne) .queryLastPage() .build();
public MamQuery queryMostRecentPage(Jid jid, int max) throws NoResponseException, XMPPErrorException, NotConnectedException, NotLoggedInException, InterruptedException { MamQueryArgs mamQueryArgs = MamQueryArgs.builder() // Produces an empty <before/> element for XEP-0059 § 2.5 .queryLastPage() .limitResultsToJid(jid) .setResultPageSize(max) .build(); return queryArchive(mamQueryArgs); }