Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
88
Issues
88
List
Boards
Labels
Service Desk
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
cb831788
Commit
cb831788
authored
Jan 30, 2018
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add the complete='true' attribute only when appropriate
parent
17f2cb5c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
12 deletions
+38
-12
CHANGELOG.rst
CHANGELOG.rst
+5
-0
src/xmpp/biboumi_component.cpp
src/xmpp/biboumi_component.cpp
+19
-6
tests/end_to_end/__main__.py
tests/end_to_end/__main__.py
+14
-6
No files found.
CHANGELOG.rst
View file @
cb831788
Version 8.0
===========
- Add a complete='true' in MAM’s iq result when appropriate
Version 7.2 - 2018-01-24
========================
...
...
src/xmpp/biboumi_component.cpp
View file @
cb831788
...
...
@@ -721,13 +721,25 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza)
if
(
max
)
limit
=
std
::
atoi
(
max
->
get_inner
().
data
());
}
// If the archive is really big, and the client didn’t specify any
// limit, we avoid flooding it: we set an arbitrary max limit.
if
(
limit
==
-
1
&&
start
.
empty
()
&&
end
.
empty
())
// Do send more than 100 messages, even if the client asked for more,
// or if it didn’t specify any limit.
// 101 is just a trick to know if there are more available messages.
// If our query returns 101 message, we know it’s incomplete, but we
// still send only 100
if
((
limit
==
-
1
&&
start
.
empty
()
&&
end
.
empty
())
||
limit
>
100
)
limit
=
101
;
log_debug
(
"limit: "
,
limit
);
auto
lines
=
Database
::
get_muc_logs
(
from
.
bare
(),
iid
.
get_local
(),
iid
.
get_server
(),
limit
,
start
,
end
);
bool
complete
=
true
;
if
(
lines
.
size
()
>
100
)
{
limit
=
100
;
log_debug
(
"incomplete"
);
complete
=
false
;
log_debug
(
"size of lines before erase: "
,
lines
.
size
());
lines
.
erase
(
lines
.
begin
(),
std
::
prev
(
lines
.
end
(),
100
));
log_debug
(
"size of lines after erase: "
,
lines
.
size
());
}
const
auto
lines
=
Database
::
get_muc_logs
(
from
.
bare
(),
iid
.
get_local
(),
iid
.
get_server
(),
limit
,
start
,
end
);
for
(
const
Database
::
MucLogLine
&
line
:
lines
)
{
if
(
!
line
.
col
<
Database
::
Nick
>
().
empty
())
...
...
@@ -738,7 +750,8 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza)
{
XmlNode
&
fin
=
*
(
fin_ptr
.
get
());
fin
[
"xmlns"
]
=
MAM_NS
;
fin
[
"complete"
]
=
"true"
;
if
(
complete
)
fin
[
"complete"
]
=
"true"
;
XmlSubNode
set
(
fin
,
"set"
);
set
[
"xmlns"
]
=
RSM_NS
;
if
(
!
lines
.
empty
())
...
...
tests/end_to_end/__main__.py
View file @
cb831788
...
...
@@ -1861,7 +1861,8 @@ if __name__ == '__main__':
partial
(
expect_stanza
,
(
"/iq[@type='result'][@id='id1'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"
,
"/iq/mam:fin/rms:set/rsm:last"
,
"/iq/mam:fin/rsm:set/rsm:first"
)),
"/iq/mam:fin/rsm:set/rsm:first"
,
"/iq/mam:fin[@complete='true']"
)),
# Retrieve an empty archive by specifying an early “end” date
partial
(
send_stanza
,
"""<iq to='#foo%{irc_server_one}' from='{jid_one}/{resource_one}' type='set' id='id2'>
...
...
@@ -1873,7 +1874,8 @@ if __name__ == '__main__':
</query></iq>"""
),
partial
(
expect_stanza
,
"/iq[@type='result'][@id='id2'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"
),
(
"/iq[@type='result'][@id='id2'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"
,
"/iq/mam:fin[@complete='true']/rsm:set"
,)),
# Retrieve an empty archive by specifying a late “start” date
# (note that this test will break in ~1000 years)
...
...
@@ -1886,7 +1888,8 @@ if __name__ == '__main__':
</query></iq>"""
),
partial
(
expect_stanza
,
"/iq[@type='result'][@id='id3'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"
),
(
"/iq[@type='result'][@id='id3'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"
,
"/iq/mam:fin[@complete='true']/rsm:set"
)),
# 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>"
),
...
...
@@ -1897,7 +1900,8 @@ if __name__ == '__main__':
),
partial
(
expect_stanza
,
"/iq[@type='result'][@id='id4'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"
),
(
"/iq[@type='result'][@id='id4'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"
,
"/iq/mam:fin[@complete='true']/rsm:set"
)),
]),
Scenario
(
"mam_with_timestamps"
,
...
...
@@ -1957,7 +1961,8 @@ if __name__ == '__main__':
),
partial
(
expect_stanza
,
"/iq[@type='result'][@id='id8'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"
),
(
"/iq[@type='result'][@id='id8'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"
,
"/iq/mam:fin[@complete='true']/rsm:set"
)),
]),
...
...
@@ -2151,8 +2156,11 @@ if __name__ == '__main__':
(
"/message/mam:result[@queryid='qid1']/forward:forwarded/delay:delay"
,
"/message/mam:result[@queryid='qid1']/forward:forwarded/client:message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/client:body[text()='149']"
)
),
# And it should not be marked as complete
partial
(
expect_stanza
,
"/iq[@type='result'][@id='id1'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"
),
(
"/iq[@type='result'][@id='id1'][@from='#foo%{irc_server_one}'][@to='{jid_one}/{resource_one}']"
,
"!/iq//mam:fin[@complete='true']"
,
"/iq//mam:fin"
)),
]),
Scenario
(
"channel_history_on_fixed_server"
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment