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
99389eef
Commit
99389eef
authored
Feb 10, 2018
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always return the oldest matching messages from MAM, even if no date is set
parent
e0d1a0b4
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
11 deletions
+40
-11
src/bridge/bridge.cpp
src/bridge/bridge.cpp
+1
-1
src/database/database.cpp
src/database/database.cpp
+24
-1
src/database/database.hpp
src/database/database.hpp
+9
-0
src/xmpp/biboumi_component.cpp
src/xmpp/biboumi_component.cpp
+1
-1
tests/end_to_end/__main__.py
tests/end_to_end/__main__.py
+5
-8
No files found.
src/bridge/bridge.cpp
View file @
99389eef
...
@@ -1020,7 +1020,7 @@ void Bridge::send_room_history(const std::string& hostname, std::string chan_nam
...
@@ -1020,7 +1020,7 @@ void Bridge::send_room_history(const std::string& hostname, std::string chan_nam
auto
limit
=
coptions
.
col
<
Database
::
MaxHistoryLength
>
();
auto
limit
=
coptions
.
col
<
Database
::
MaxHistoryLength
>
();
if
(
history_limit
.
stanzas
>=
0
&&
history_limit
.
stanzas
<
limit
)
if
(
history_limit
.
stanzas
>=
0
&&
history_limit
.
stanzas
<
limit
)
limit
=
history_limit
.
stanzas
;
limit
=
history_limit
.
stanzas
;
const
auto
lines
=
Database
::
get_muc_logs
(
this
->
user_jid
,
chan_name
,
hostname
,
limit
,
history_limit
.
since
);
const
auto
lines
=
Database
::
get_muc_
most_recent_
logs
(
this
->
user_jid
,
chan_name
,
hostname
,
limit
,
history_limit
.
since
);
chan_name
.
append
(
utils
::
empty_if_fixed_server
(
"%"
+
hostname
));
chan_name
.
append
(
utils
::
empty_if_fixed_server
(
"%"
+
hostname
));
for
(
const
auto
&
line
:
lines
)
for
(
const
auto
&
line
:
lines
)
{
{
...
...
src/database/database.cpp
View file @
99389eef
...
@@ -185,13 +185,36 @@ std::vector<Database::MucLogLine> Database::get_muc_logs(const std::string& owne
...
@@ -185,13 +185,36 @@ std::vector<Database::MucLogLine> Database::get_muc_logs(const std::string& owne
request
<<
" and "
<<
Database
::
Date
{}
<<
"<="
<<
end_time
;
request
<<
" and "
<<
Database
::
Date
{}
<<
"<="
<<
end_time
;
}
}
if
(
limit
>=
0
)
request
.
limit
()
<<
limit
;
auto
result
=
request
.
execute
(
*
Database
::
db
);
return
{
result
.
cbegin
(),
result
.
cend
()};
}
std
::
vector
<
Database
::
MucLogLine
>
Database
::
get_muc_most_recent_logs
(
const
std
::
string
&
owner
,
const
std
::
string
&
chan_name
,
const
std
::
string
&
server
,
int
limit
,
const
std
::
string
&
start
)
{
auto
request
=
Database
::
muc_log_lines
.
select
();
request
.
where
()
<<
Database
::
Owner
{}
<<
"="
<<
owner
<<
\
" and "
<<
Database
::
IrcChanName
{}
<<
"="
<<
chan_name
<<
\
" and "
<<
Database
::
IrcServerName
{}
<<
"="
<<
server
;
if
(
!
start
.
empty
())
{
const
auto
start_time
=
utils
::
parse_datetime
(
start
);
if
(
start_time
!=
-
1
)
request
<<
" and "
<<
Database
::
Date
{}
<<
">="
<<
start_time
;
}
request
.
order_by
()
<<
Id
{}
<<
" DESC "
;
request
.
order_by
()
<<
Id
{}
<<
" DESC "
;
if
(
limit
>=
0
)
if
(
limit
>=
0
)
request
.
limit
()
<<
limit
;
request
.
limit
()
<<
limit
;
auto
result
=
request
.
execute
(
*
Database
::
db
);
auto
result
=
request
.
execute
(
*
Database
::
db
);
return
{
result
.
crbegin
(),
result
.
crend
()};
return
{
result
.
crbegin
(),
result
.
crend
()};
}
}
...
...
src/database/database.hpp
View file @
99389eef
...
@@ -118,8 +118,17 @@ class Database
...
@@ -118,8 +118,17 @@ class Database
static
IrcChannelOptions
get_irc_channel_options_with_server_and_global_default
(
const
std
::
string
&
owner
,
static
IrcChannelOptions
get_irc_channel_options_with_server_and_global_default
(
const
std
::
string
&
owner
,
const
std
::
string
&
server
,
const
std
::
string
&
server
,
const
std
::
string
&
channel
);
const
std
::
string
&
channel
);
/**
* Get all the lines between (optional) start and end dates, with a (optional) limit.
*/
static
std
::
vector
<
MucLogLine
>
get_muc_logs
(
const
std
::
string
&
owner
,
const
std
::
string
&
chan_name
,
const
std
::
string
&
server
,
static
std
::
vector
<
MucLogLine
>
get_muc_logs
(
const
std
::
string
&
owner
,
const
std
::
string
&
chan_name
,
const
std
::
string
&
server
,
int
limit
=-
1
,
const
std
::
string
&
start
=
""
,
const
std
::
string
&
end
=
""
);
int
limit
=-
1
,
const
std
::
string
&
start
=
""
,
const
std
::
string
&
end
=
""
);
/**
* Get the most recent messages from the archive, with optional limit and start date
*/
static
std
::
vector
<
MucLogLine
>
get_muc_most_recent_logs
(
const
std
::
string
&
owner
,
const
std
::
string
&
chan_name
,
const
std
::
string
&
server
,
int
limit
=-
1
,
const
std
::
string
&
start
=
""
);
static
std
::
string
store_muc_message
(
const
std
::
string
&
owner
,
const
std
::
string
&
chan_name
,
const
std
::
string
&
server_name
,
static
std
::
string
store_muc_message
(
const
std
::
string
&
owner
,
const
std
::
string
&
chan_name
,
const
std
::
string
&
server_name
,
time_point
date
,
const
std
::
string
&
body
,
const
std
::
string
&
nick
);
time_point
date
,
const
std
::
string
&
body
,
const
std
::
string
&
nick
);
...
...
src/xmpp/biboumi_component.cpp
View file @
99389eef
...
@@ -721,7 +721,7 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza)
...
@@ -721,7 +721,7 @@ bool BiboumiComponent::handle_mam_request(const Stanza& stanza)
if
(
max
)
if
(
max
)
limit
=
std
::
atoi
(
max
->
get_inner
().
data
());
limit
=
std
::
atoi
(
max
->
get_inner
().
data
());
}
}
// Do send more than 100 messages, even if the client asked for more,
// Do
not
send more than 100 messages, even if the client asked for more,
// or if it didn’t specify any limit.
// or if it didn’t specify any limit.
// 101 is just a trick to know if there are more available messages.
// 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
// If our query returns 101 message, we know it’s incomplete, but we
...
...
tests/end_to_end/__main__.py
View file @
99389eef
...
@@ -1896,7 +1896,7 @@ if __name__ == '__main__':
...
@@ -1896,7 +1896,7 @@ if __name__ == '__main__':
partial
(
expect_stanza
,
partial
(
expect_stanza
,
(
"/message/mam:result[@queryid='qid4']/forward:forwarded/delay:delay"
,
(
"/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
']"
)
"/message/mam:result[@queryid='qid4']/forward:forwarded/client:message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/client:body[text()='coucou']"
)
),
),
partial
(
expect_stanza
,
partial
(
expect_stanza
,
...
@@ -2139,10 +2139,10 @@ if __name__ == '__main__':
...
@@ -2139,10 +2139,10 @@ if __name__ == '__main__':
# Retrieve the archive, without any restriction
# Retrieve the archive, without any restriction
partial
(
send_stanza
,
"<iq to='#foo%{irc_server_one}' from='{jid_one}/{resource_one}' type='set' id='id1'><query xmlns='urn:xmpp:mam:2' queryid='qid1' /></iq>"
),
partial
(
send_stanza
,
"<iq to='#foo%{irc_server_one}' from='{jid_one}/{resource_one}' type='set' id='id1'><query xmlns='urn:xmpp:mam:2' queryid='qid1' /></iq>"
),
# Since we should only receive the last 100 messages from the archive,
# Since we should only receive the last 100 messages from the archive,
# it should start with message "
50
"
# it should start with message "
1
"
partial
(
expect_stanza
,
partial
(
expect_stanza
,
(
"/message/mam:result[@queryid='qid1']/forward:forwarded/delay:delay"
,
(
"/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()='
50
']"
)
"/message/mam:result[@queryid='qid1']/forward:forwarded/client:message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/client:body[text()='
1
']"
)
),
),
]
+
[
]
+
[
# followed by 98 more messages
# followed by 98 more messages
...
@@ -2151,10 +2151,10 @@ if __name__ == '__main__':
...
@@ -2151,10 +2151,10 @@ if __name__ == '__main__':
"/message/mam:result[@queryid='qid1']/forward:forwarded/client:message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/client:body"
)
"/message/mam:result[@queryid='qid1']/forward:forwarded/client:message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/client:body"
)
),
),
]
*
98
+
[
]
*
98
+
[
# and finally the message "
14
9"
# and finally the message "
9
9"
partial
(
expect_stanza
,
partial
(
expect_stanza
,
(
"/message/mam:result[@queryid='qid1']/forward:forwarded/delay:delay"
,
(
"/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()='1
49
']"
)
"/message/mam:result[@queryid='qid1']/forward:forwarded/client:message[@from='#foo%{irc_server_one}/{nick_one}'][@type='groupchat']/client:body[text()='1
00
']"
)
),
),
# And it should not be marked as complete
# And it should not be marked as complete
partial
(
expect_stanza
,
partial
(
expect_stanza
,
...
@@ -2220,9 +2220,6 @@ if __name__ == '__main__':
...
@@ -2220,9 +2220,6 @@ if __name__ == '__main__':
# Second user joins
# Second user joins
partial
(
send_stanza
,
partial
(
send_stanza
,
"<presence from='{jid_one}/{resource_two}' to='#foo%{irc_server_one}/{nick_one}' />"
),
"<presence from='{jid_one}/{resource_two}' to='#foo%{irc_server_one}/{nick_one}' />"
),
# connection_sequence("irc.localhost", '{jid_one}/{resource_two}'),
# partial(expect_stanza,
# "/message/body[text()='Mode #foo [+nt] by {irc_host_one}']"),
partial
(
expect_stanza
,
partial
(
expect_stanza
,
(
"/presence[@to='{jid_one}/{resource_two}'][@from='#foo%{irc_server_one}/{nick_one}']/muc_user:x/muc_user:item[@affiliation='admin'][@jid='~nick@localhost'][@role='moderator']"
,
(
"/presence[@to='{jid_one}/{resource_two}'][@from='#foo%{irc_server_one}/{nick_one}']/muc_user:x/muc_user:item[@affiliation='admin'][@jid='~nick@localhost'][@role='moderator']"
,
"/presence/muc_user:x/muc_user:status[@code='110']"
)
"/presence/muc_user:x/muc_user:status[@code='110']"
)
...
...
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