I have been trying to get the archived messages from MAM and using the inbuilt functions of smack api,
try {
if (lastMessageMamId == null) {
mamQueryResult = getArchivedMessages(mamManager,chat.getUser().getJid().toString(), PAGE_SIZE);
// mamQueryResult = mamManager.queryArchive(50);
} else {
mamQueryResult = mamManager.pageAfter(chat.getUser().getJid(), lastMessageMamId, PAGE_SIZE);
}
}
and it always returns count 0 as result for forwarded messages for initializing the mamManager using
org.jivesoftware.smackx.mam.MamManager mamManager
= org.jivesoftware.smackx.mam.MamManager.getInstanceFor(connection);
i also created a method to obtain the archived messages by creating the custom packet with start and end , i think it is also created internally by some another method that accepts the start and end date (queryArchive(…))
public org.jivesoftware.smackx.mam.MamManager.MamQueryResult getArchivedMessages(org.jivesoftware.smackx.mam.MamManager mamManager, String jid, int maxResults) {
//MamManager mamManager = MamManager.getInstanceFor(connection);
try {
DataForm form = new DataForm(DataForm.Type.submit);
FormField field = new FormField(FormField.FORM_TYPE);
field.setType(FormField.Type.hidden);
field.addValue(MamElements.NAMESPACE);
form.addField(field);
//FormField formField = new FormField("with");
Calendar calendar = Calendar.getInstance();
calendar.get(Calendar.DAY_OF_MONTH-1);
FormField formField = new FormField("start");
formField.addValue("2010-06-07T00:00:00Z");
form.addField(formField);
FormField formField2 = new FormField("end");
formField2.addValue("2019-04-08T18:10:02.907Z");
form.addField(formField2);
RSMSet rsmSet = new RSMSet(maxResults);
return mamManager.page(form,rsmSet);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
but it also return the same count 0, but i have seen the archive table on server, it has messages in it, but i am not sure what is the thing that i am missing
i have also tried querying the mam using
mamQueryResult = mamManager.queryArchive(50);
but same problem
<iq id="H6q9q-60" type="set">
<query xmlns="urn:xmpp:mam:1" queryid="825e94c6-bd82-421e-b362-90072b421606">
<x xmlns="jabber:x:data" type="submit">
<field var="FORM_TYPE" type="hidden">
<value>urn:xmpp:mam:1</value>
</field>
<field var="start">
<value>2010-06-07T00:00:00Z</value>
</field>
<field var="end">
<value>2019-04-08T18:10:02.907Z</value>
</field>
</x>
<set xmlns="http://jabber.org/protocol/rsm">
<max>50</max>
</set>
</query>
</iq>
this is the IQ packet that gets generated and the server guy tells me that, this will not work as it does not have to, and from in IQ.
and i seriously dont think that is the problem, i just want my messages, all of my messages, weather they are one to one, or group messages, for this case i am interested in getting in the group messages only, as i my use case does not have one-to-one chat. What am i missing or doing wrong in it?