~singpolyma/biboumi

3a8203c366d46ec2937a601868f5e2ed591c923e — louiz’ 5 years ago 4fde4d7
Handle the RSM "max" value in the MAM requests

fix #3255
2 files changed, 21 insertions(+), 1 deletions(-)

M src/xmpp/biboumi_component.cpp
M tests/end_to_end/__main__.py
M src/xmpp/biboumi_component.cpp => src/xmpp/biboumi_component.cpp +9 -1
@@ 619,7 619,15 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza)
                  }
              }
          }
        const auto lines = Database::get_muc_logs(from.bare(), iid.get_local(), iid.get_server(), -1, start, end);
        const XmlNode* set = query->get_child("set", RSM_NS);
        int limit = -1;
        if (set)
          {
            const XmlNode* max = set->get_child("max", RSM_NS);
            if (max)
              limit = std::atoi(max->get_inner().data());
          }
        const auto lines = Database::get_muc_logs(from.bare(), iid.get_local(), iid.get_server(), limit, start, end);
        for (const db::MucLogLine& line: lines)
        {
          if (!line.nick.value().empty())

M tests/end_to_end/__main__.py => tests/end_to_end/__main__.py +12 -0
@@ 1626,6 1626,18 @@ if __name__ == '__main__':

                    partial(expect_stanza,
                            "/iq[@type='result'][@id='id3'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"),

                    # Retrieve a limited archive
                    partial(send_stanza, "<iq to='#foo%{irc_server_one}' from='{jid_one}/{resource_one}' type='set' id='id4'><query xmlns='urn:xmpp:mam:2' queryid='qid4'><set xmlns='http://jabber.org/protocol/rsm'><max>1</max></set></query></iq>"),

                    partial(expect_stanza,
                            ("/message/mam:result[@queryid='qid4']/forward:forwarded/delay:delay",
                             "/message/mam:result[@queryid='qid4']/forward:forwarded/client:message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/client:body[text()='coucou 2']")
                            ),

                    partial(expect_stanza,
                            "/iq[@type='result'][@id='id4'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"),

                ]),
        Scenario("mam_on_fixed_server",
                 [