如何获取已发送消息的MAM消息ID?

时间:2018-03-13 15:33:16

标签: xmpp

我正在使用eJabberd服务器(启用MAM)和客户端库Strophe.js。客户端应用程序将固定数量的邮件存储在本地存储中。

我从服务器收到的所有消息都包含元素<stanza-id/><message xmlns="jabber:client" to="aaa@example.net/8667085700924567016834" from="aaa@example.net"> <result xmlns="urn:xmpp:mam:2" id="1520510373346685"> <forwarded xmlns="urn:xmpp:forward:0"> <message xmlns="jabber:client" xml:lang="en" to="bbb@example.net" from="aaa@example.net/60965696931000870402419" type="chat"> <archived xmlns="urn:xmpp:mam:tmp" by="aaa@example.net" id="1520510373346685"/> <stanza-id xmlns="urn:xmpp:sid:0" by="aaa@example.net" id="1520510373346685"/> <body>asdf</body> </message> <delay xmlns="urn:xmpp:delay" from="example.net" stamp="2018-03-08T11:59:33.346685Z"/> </forwarded> </result> </message> ,它们提供服务器端生成的ID:

params = {
    "before": "1520510373346685",
    "max": 10,
    onMessage: <some handler>,
    onComplete: <some handler>,
}
this.connection.mam.query(Strophe.getBareJidFromJid(this.myJid), params);

我使用这些ID在每次MAM呼叫上获取固定数量的消息(使用RSM分页 - before / after / max属性)。例如:

1520510373346685

这会在带有节标识const lesserGeopoint = new functions.firebase.firestore.GeoPoint(box.swCorner.latitude, box.swCorner.longitude); const greaterGeopoint = new functions.firebase.firestore.GeoPoint(box.neCorner.latitude, box.neCorner.longitude); 的消息之前收到10条消息。

但是,我发送的邮件本身没有此ID,直到我发送并从MAM检索。

我没有找到任何关于从服务器获取当前发送的消息ID的示例,并且Strophe在从客户端发送消息并由服务器接收消息后不提供任何回调。

所以,问题是 - 有没有办法为当前发送的消息获取服务器生成的消息ID(节/ id /已存档)?

也许我自己的方法是错的 - 我应该生成自己的ID并将其添加到客户端的每条消息中吗?

1 个答案:

答案 0 :(得分:1)

除了查询存档之外,目前还没有指定任何机制。 XMPP社区中未来要解决此问题的一个突出想法是将发送碳反映回原始发件人,其中包括带有归档分配的ID的节id元素。

相关问题