If I have 20 users, each user have 100 archived messages.
How can I get the latest 20 archived messages of all 20 users in one query?
This query doesn't work that way...
<iq type='set' id='test1'>
<query xmlns='urn:xmpp:mam:0'>
<set xmlns='http://jabber.org/protocol/rsm'>
<max>20</max>
<before/>
</set>
</query>
</iq>
XMPP does not support this kind of Query.You may need to change source code and introduce custom request to achieve this behavior.
Related
How do I only allow contacts who are on my roster list to send me messages?
Is there any XEP responsible to do that? Or will I need to do this client-side?
Yes, OpenFire supports XEP-0016: Privacy Lists (see this question), which can be used to block stanzas according to various criteria.
You can't explicitly block stanzas for contacts not in your roster, but you can block by subscription status none, which can more or less accomplish the same goal. You could send something like this:
<iq from='romeo#example.net/orchard' type='set' id='msg3'>
<query xmlns='jabber:iq:privacy'>
<list name='message-sub-example'>
<item type='subscription'
value='none'
action='deny'
order='5'>
<message/>
</item>
</list>
</query>
</iq>
This creates a privacy list called message-sub-example, containing a rule to block any messages from contacts with subscription type none, including contacts not in the roster. For this list to take effect, you need to make it the active list:
<iq from='romeo#example.net/orchard' type='set' id='active1'>
<query xmlns='jabber:iq:privacy'>
<active name='message-sub-example'/>
</query>
</iq>
I'm using an XMPP server that implements XEP-0313 for retrieving conversation history. I would like to fetch only the last message of each conversation, so that I can build a list of your most recent conversations previewing the last message.
I've managed to fetch all messages of all conversations and based on that I could build the list, but it's a big waste of data and not an option. I'm not sure this is the right extension for accomplishing this, so if there is another extension I should be looking at, please guide me in the right direction.
One thing you can do easily is first retrieve the user's roster and then for each contact retrieve the latest message.
<iq from='juliet#example.com/balcony'
id='bv1bs71f'
type='get'>
<query xmlns='jabber:iq:roster'/>
</iq>
Result:
<iq id='bv1bs71f'
to='juliet#example.com/chamber'
type='result'>
<query xmlns='jabber:iq:roster' ver='ver7'>
<item jid='nurse#example.com'/>
<item jid='romeo#example.net'/>
</query>
</iq>
Retrieve the last message from or to nurse#example.com:
<iq type='set' id='juliet1'>
<query xmlns='urn:xmpp:mam:1'>
<x xmlns='jabber:x:data' type='submit'>
<field var='FORM_TYPE' type='hidden'>
<value>urn:xmpp:mam:1</value>
</field>
<field var='with'>
<value>nurse#example.com</value>
</field>
</x>
<set xmlns='http://jabber.org/protocol/rsm'>
<max>1</max>
<before/>
</set>
</query>
</iq>
Of course users can have conversations with people not on their roster, but in practice this is quite rare on XMPP.
I'm using Openfire as my xmpp server and am trying to retrieve archived messages after a particular time using XEP-0136. I have the monitoring service plugin installed and am able to receive a list of collections but it is not listening to the start and end parameters.
I've searched around and haven't seen others have the same issue...so either they've not tried it (unlikely) or I'm doing something wrong.
Here is my iq:
<iq xmlns="jabber:client" type="get">
<list xmlns="urn:xmpp:archive" start="2014-09-08T17:12:10Z" end="2014-09-08T17:12:56Z">
<set xmlns="http://jabber.org/protocol/rsm">
<max>100</max>
</set>
</list>
</iq>
The only thing that is different between my iq and what is in the XEP-0136 docs (http://xmpp.org/extensions/xep-0136.html#example-39) is that I don't specify a with. I'm trying to get all inbound and outbound messages from the currently logged in user from the start time.
Is there something I'm missing here? I'd really appreciate your help.
EDIT: I have confirmed that adding 'with' does not help.
Im using Jabber-Net API to make a GMail client. I've been having problems with the subscription process using my client as it always returning the "subscription=none" and "ask=none". When i subscribe a new user, it works fine but, subscribing/ unsubscribing users very frquently from roster makes the users stop to send subscription request with "to/ from/ both" or etc.
I have discovered that, "CONTACT" always receives a packet like this:
<iq type="set">
<query xmlns="jabber:iq:roster">
<item
jid="jabberuser#host"
subscription="none"
ask="none"/>
</query>
</iq>
Any prompt answer will be much appreciated..
Are you sending a presence subscription?
<presence type='subscribe' to='jabberuser#host'/>
get a list of all users and the status of XMPP multi-user-chat
I do so
<iq from='hag66#shakespeare.lit/pda'
id='kl2fax27'
to='coven#chat.shakespeare.lit'
type='get'>
<query xmlns='http://jabber.org/protocol/disco#items'/>
</iq>
getting a list but without status.
I need for all users on the statuses to know?
Please read XEP-0045, which describes the multi-user chat (MUC) protocol. You need to join the room:
<presence
from='hag66#shakespeare.lit/pda'
to='coven#chat.shakespeare.lit/thirdwitch'>
<x xmlns='http://jabber.org/protocol/muc'/>
</presence>
You'll then get a presence stanza from each occupant of the room with their current status:
<presence
from='coven#chat.shakespeare.lit/firstwitch'
to='hag66#shakespeare.lit/pda'>
<x xmlns='http://jabber.org/protocol/muc#user'>
<item affiliation='owner' role='moderator'/>
</x>
</presence>
<presence
from='coven#chat.shakespeare.lit/secondwitch'
to='hag66#shakespeare.lit/pda'>
<x xmlns='http://jabber.org/protocol/muc#user'>
<item affiliation='admin' role='moderator'/>
</x>
</presence>
And before you ask, no, there is no way to tell when you're "done" receiving these notifications, since users may come and go at any time. You are now subscribed to the presence changes of the occupants, and have to keep track of what is current on the receiving side.
Reading through the XMPP RFC, I see that statuses are conveyed by presence messages, and that you ask another entity to report its status now (rather than waiting for it to tell you in a broadcast) by sending a probe status request to which you'll get a directed response (§5.5 of the RFC gives some examples). It's up to you to interpret what they say back correctly, of course…