mod_mam: Advertise extended MAM 0.7.x behind a feature flag

In order to ease testing until the extended feautres are all
implemented.

Also TODOs for all the sub-features.
This commit is contained in:
Kim Alvefur 2020-11-30 21:00:45 +01:00
parent f4208459a7
commit b96341a58f
3 changed files with 92 additions and 2 deletions

View file

@ -568,7 +568,8 @@
<implements>
<xmpp:SupportedXep>
<xmpp:xep rdf:resource="https://xmpp.org/extensions/xep-0313.html"/>
<xmpp:version>0.6.3</xmpp:version>
<xmpp:version>0.7.2</xmpp:version>
<xmpp:status>partial</xmpp:status>
<xmpp:since>0.10.0</xmpp:since>
<xmpp:note>mod_mam, mod_muc_mam</xmpp:note>
</xmpp:SupportedXep>

View file

@ -1,7 +1,7 @@
-- Prosody IM
-- Copyright (C) 2008-2017 Matthew Wild
-- Copyright (C) 2008-2017 Waqas Hussain
-- Copyright (C) 2011-2017 Kim Alvefur
-- Copyright (C) 2011-2020 Kim Alvefur
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
@ -10,6 +10,7 @@
--
local xmlns_mam = "urn:xmpp:mam:2";
local xmlns_mam_ext = "urn:xmpp:mam:2#extended";
local xmlns_delay = "urn:xmpp:delay";
local xmlns_forward = "urn:xmpp:forward:0";
local xmlns_st_id = "urn:xmpp:sid:0";
@ -512,8 +513,18 @@ module:hook("pre-message/full", c2s_message_handler, 0);
module:hook("message/bare", message_handler, 0);
module:hook("message/full", message_handler, 0);
local advertise_extended = module:get_option_boolean("mam_advertise_extend", false);
-- TODO before-id, after-id
-- TODO ids
-- TODO page flipping
-- TODO archive metadata query
-- TODO delete feature flag option
module:hook("account-disco-info", function(event)
(event.reply or event.stanza):tag("feature", {var=xmlns_mam}):up();
if advertise_extended then
(event.reply or event.stanza):tag("feature", {var=xmlns_mam_ext}):up();
end
(event.reply or event.stanza):tag("feature", {var=xmlns_st_id}):up();
end);

View file

@ -0,0 +1,78 @@
# MAM 0.7.x Extended features
[Client] Romeo
jid: extmamtester@localhost
password: password
---------
Romeo connects
# Enable MAM so we can save some messages
Romeo sends:
<iq type="set" id="enablemam">
<prefs xmlns="urn:xmpp:mam:2" default="always">
<always/>
<never/>
</prefs>
</iq>
Romeo receives:
<iq type="result" id="enablemam">
<prefs xmlns="urn:xmpp:mam:2" default="always">
<always/>
<never/>
</prefs>
</iq>
# Some messages to look for later
Romeo sends:
<message to="someone@localhost" type="chat" id="chat01">
<body>Hello</body>
</message>
Romeo sends:
<message to="someone@localhost" type="chat" id="chat02">
<body>U there?</body>
</message>
Romeo sends:
<iq type="set" id="mamquery1">
<query xmlns="urn:xmpp:mam:2" queryid="q1"/>
</iq>
Romeo receives:
<message to="${Romeo's full JID}">
<result xmlns="urn:xmpp:mam:2" queryid="q1" id="{scansion:any}">
<forwarded xmlns="urn:xmpp:forward:0">
<delay stamp="2008-08-22T21:09:04Z" xmlns="urn:xmpp:delay"/>
<message to="someone@localhost" xmlns="jabber:client" type="chat" xml:lang="en" id="chat01" from="${Romeo's full JID}">
<body>Hello</body>
</message>
</forwarded>
</result>
</message>
Romeo receives:
<message to="${Romeo's full JID}">
<result xmlns="urn:xmpp:mam:2" queryid="q1" id="{scansion:any}">
<forwarded xmlns="urn:xmpp:forward:0">
<delay stamp="2008-08-22T21:09:04Z" xmlns="urn:xmpp:delay"/>
<message to="someone@localhost" xmlns="jabber:client" type="chat" xml:lang="en" id="chat02" from="${Romeo's full JID}">
<body>U there?</body>
</message>
</forwarded>
</result>
</message>
# FIXME unstable tag order from util.rsm
Romeo receives:
<iq type="result" id="mamquery1" to="${Romeo's full JID}">
<fin xmlns="urn:xmpp:mam:2" complete="true" queryid="q1">
<set xmlns="http://jabber.org/protocol/rsm" scansion:strict="false">
<count>2</count>
<first></first>
<last></last>
</set>
</fin>
</iq>