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
98
Issues
98
List
Boards
Labels
Service Desk
Milestones
Merge Requests
12
Merge Requests
12
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
d1626c92
Commit
d1626c92
authored
Aug 22, 2016
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
When joining a channel, send the most recent history found in the database
parent
593b3268
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
72 additions
and
1 deletion
+72
-1
louloulibs/xmpp/xmpp_component.cpp
louloulibs/xmpp/xmpp_component.cpp
+28
-0
louloulibs/xmpp/xmpp_component.hpp
louloulibs/xmpp/xmpp_component.hpp
+5
-0
src/bridge/bridge.cpp
src/bridge/bridge.cpp
+20
-0
src/bridge/bridge.hpp
src/bridge/bridge.hpp
+5
-0
src/database/database.cpp
src/database/database.cpp
+9
-0
src/database/database.hpp
src/database/database.hpp
+2
-0
src/irc/irc_client.cpp
src/irc/irc_client.cpp
+3
-1
No files found.
louloulibs/xmpp/xmpp_component.cpp
View file @
d1626c92
...
...
@@ -16,6 +16,9 @@
#include <uuid.h>
#include <cstdlib>
#include <iomanip>
#include <louloulibs.h>
#ifdef SYSTEMD_FOUND
# include <systemd/sd-daemon.h>
...
...
@@ -426,6 +429,31 @@ void XmppComponent::send_muc_message(const std::string& muc_name, const std::str
this
->
send_stanza
(
message
);
}
void
XmppComponent
::
send_history_message
(
const
std
::
string
&
muc_name
,
const
std
::
string
&
nick
,
const
std
::
string
&
body_txt
,
const
std
::
string
&
jid_to
,
std
::
time_t
timestamp
)
{
Stanza
message
(
"message"
);
message
[
"to"
]
=
jid_to
;
if
(
!
nick
.
empty
())
message
[
"from"
]
=
muc_name
+
"@"
+
this
->
served_hostname
+
"/"
+
nick
;
else
message
[
"from"
]
=
muc_name
+
"@"
+
this
->
served_hostname
;
message
[
"type"
]
=
"groupchat"
;
XmlNode
body
(
"body"
);
body
.
set_inner
(
body_txt
);
message
.
add_child
(
std
::
move
(
body
));
XmlNode
delay
(
"delay"
);
delay
[
"xmlns"
]
=
"urn:xmpp:delay"
;
delay
[
"from"
]
=
muc_name
+
"@"
+
this
->
served_hostname
;
std
::
stringstream
date_ss
;
date_ss
<<
std
::
put_time
(
std
::
gmtime
(
&
timestamp
),
"%FT%Tz"
)
<<
std
::
endl
;
delay
[
"stamp"
]
=
date_ss
.
str
();
message
.
add_child
(
std
::
move
(
delay
));
this
->
send_stanza
(
message
);
}
void
XmppComponent
::
send_muc_leave
(
const
std
::
string
&
muc_name
,
std
::
string
&&
nick
,
Xmpp
::
body
&&
message
,
const
std
::
string
&
jid_to
,
const
bool
self
)
{
Stanza
presence
(
"presence"
);
...
...
louloulibs/xmpp/xmpp_component.hpp
View file @
d1626c92
...
...
@@ -134,6 +134,11 @@ public:
* Send a (non-private) message to the MUC
*/
void
send_muc_message
(
const
std
::
string
&
muc_name
,
const
std
::
string
&
nick
,
Xmpp
::
body
&&
body
,
const
std
::
string
&
jid_to
);
/**
* Send a message, with a <delay/> element, part of a MUC history
*/
void
send_history_message
(
const
std
::
string
&
muc_name
,
const
std
::
string
&
nick
,
const
std
::
string
&
body
,
const
std
::
string
&
jid_to
,
const
std
::
time_t
timestamp
);
/**
* Send an unavailable presence for this nick
*/
...
...
src/bridge/bridge.cpp
View file @
d1626c92
...
...
@@ -744,6 +744,26 @@ void Bridge::send_topic(const std::string& hostname, const std::string& chan_nam
}
void
Bridge
::
send_room_history
(
const
std
::
string
&
hostname
,
const
std
::
string
&
chan_name
)
{
for
(
const
auto
&
resource
:
this
->
resources_in_chan
[
ChannelKey
{
chan_name
,
hostname
}])
this
->
send_room_history
(
hostname
,
chan_name
,
resource
);
}
void
Bridge
::
send_room_history
(
const
std
::
string
&
hostname
,
const
std
::
string
&
chan_name
,
const
std
::
string
&
resource
)
{
#ifdef USE_DATABASE
const
auto
coptions
=
Database
::
get_irc_channel_options_with_server_and_global_default
(
this
->
user_jid
,
hostname
,
chan_name
);
const
auto
lines
=
Database
::
get_muc_logs
(
this
->
user_jid
,
chan_name
,
hostname
,
coptions
.
maxHistoryLength
.
value
());
for
(
const
auto
&
line
:
lines
)
{
const
auto
seconds
=
line
.
date
.
value
().
timeStamp
();
this
->
xmpp
.
send_history_message
(
chan_name
+
"%"
+
hostname
,
line
.
nick
.
value
(),
line
.
body
.
value
(),
this
->
user_jid
+
"/"
+
resource
,
seconds
);
}
#endif
}
std
::
string
Bridge
::
get_own_nick
(
const
Iid
&
iid
)
{
IrcClient
*
irc
=
this
->
find_irc_client
(
iid
.
get_server
());
...
...
src/bridge/bridge.hpp
View file @
d1626c92
...
...
@@ -137,6 +137,11 @@ public:
*/
void
send_topic
(
const
std
::
string
&
hostname
,
const
std
::
string
&
chan_name
,
const
std
::
string
&
topic
,
const
std
::
string
&
who
);
void
send_topic
(
const
std
::
string
&
hostname
,
const
std
::
string
&
chan_name
,
const
std
::
string
&
topic
,
const
std
::
string
&
who
,
const
std
::
string
&
resource
);
/**
* Send the MUC history to the user
*/
void
send_room_history
(
const
std
::
string
&
hostname
,
const
std
::
string
&
chan_name
);
void
send_room_history
(
const
std
::
string
&
hostname
,
const
std
::
string
&
chan_name
,
const
std
::
string
&
resource
);
/**
* Send a MUC message from some participant
*/
...
...
src/database/database.cpp
View file @
d1626c92
...
...
@@ -136,6 +136,15 @@ void Database::store_muc_message(const std::string& owner, const Iid& iid,
line
.
update
();
}
std
::
vector
<
db
::
MucLogLine
>
Database
::
get_muc_logs
(
const
std
::
string
&
owner
,
const
std
::
string
&
chan_name
,
const
std
::
string
&
server
,
const
int
limit
)
{
auto
res
=
litesql
::
select
<
db
::
MucLogLine
>
(
*
Database
::
db
,
db
::
MucLogLine
::
Owner
==
owner
&&
db
::
MucLogLine
::
IrcChanName
==
chan_name
&&
db
::
MucLogLine
::
IrcServerName
==
server
).
orderBy
(
db
::
MucLogLine
::
Date
,
false
).
limit
(
limit
).
all
();
return
{
res
.
rbegin
(),
res
.
rend
()};
}
void
Database
::
close
()
{
Database
::
db
.
reset
(
nullptr
);
...
...
src/database/database.hpp
View file @
d1626c92
...
...
@@ -48,6 +48,8 @@ public:
static
db
::
IrcChannelOptions
get_irc_channel_options_with_server_and_global_default
(
const
std
::
string
&
owner
,
const
std
::
string
&
server
,
const
std
::
string
&
channel
);
static
std
::
vector
<
db
::
MucLogLine
>
get_muc_logs
(
const
std
::
string
&
owner
,
const
std
::
string
&
chan_name
,
const
std
::
string
&
server
,
const
int
limit
);
static
void
store_muc_message
(
const
std
::
string
&
owner
,
const
Iid
&
iid
,
time_point
date
,
const
std
::
string
&
body
,
const
std
::
string
&
nick
);
...
...
src/irc/irc_client.cpp
View file @
d1626c92
...
...
@@ -755,7 +755,9 @@ void IrcClient::on_channel_completely_joined(const IrcMessage& message)
const
std
::
string
chan_name
=
utils
::
tolower
(
message
.
arguments
[
1
]);
IrcChannel
*
channel
=
this
->
get_channel
(
chan_name
);
channel
->
joined
=
true
;
this
->
bridge
.
send_user_join
(
this
->
hostname
,
chan_name
,
channel
->
get_self
(),
channel
->
get_self
()
->
get_most_significant_mode
(
this
->
sorted_user_modes
),
true
);
this
->
bridge
.
send_user_join
(
this
->
hostname
,
chan_name
,
channel
->
get_self
(),
channel
->
get_self
()
->
get_most_significant_mode
(
this
->
sorted_user_modes
),
true
);
this
->
bridge
.
send_room_history
(
this
->
hostname
,
chan_name
);
this
->
bridge
.
send_topic
(
this
->
hostname
,
chan_name
,
channel
->
topic
,
channel
->
topic_author
);
}
...
...
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