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
fef9c819
Commit
fef9c819
authored
Jan 06, 2014
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Also set the role and affiliation of users already in the chan
parent
7701c907
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
35 deletions
+34
-35
src/bridge/bridge.cpp
src/bridge/bridge.cpp
+24
-32
src/bridge/bridge.hpp
src/bridge/bridge.hpp
+1
-0
src/irc/irc_client.cpp
src/irc/irc_client.cpp
+9
-3
No files found.
src/bridge/bridge.cpp
View file @
fef9c819
...
...
@@ -6,6 +6,7 @@
#include <logger/logger.hpp>
#include <utils/split.hpp>
#include <iostream>
#include <tuple>
static
const
char
*
action_prefix
=
"
\01
ACTION "
;
static
const
size_t
action_prefix_len
=
8
;
...
...
@@ -21,6 +22,22 @@ Bridge::~Bridge()
{
}
/**
* Return the role and affiliation, corresponding to the given irc mode */
static
std
::
tuple
<
std
::
string
,
std
::
string
>
get_role_affiliation_from_irc_mode
(
const
char
mode
)
{
if
(
mode
==
'a'
||
mode
==
'q'
)
return
std
::
make_tuple
(
"moderator"
,
"owner"
);
else
if
(
mode
==
'o'
)
return
std
::
make_tuple
(
"moderator"
,
"admin"
);
else
if
(
mode
==
'h'
)
return
std
::
make_tuple
(
"moderator"
,
"member"
);
else
if
(
mode
==
'v'
)
return
std
::
make_tuple
(
"participant"
,
"member"
);
else
return
std
::
make_tuple
(
"participant"
,
"none"
);
}
void
Bridge
::
shutdown
()
{
for
(
auto
it
=
this
->
irc_clients
.
begin
();
it
!=
this
->
irc_clients
.
end
();
++
it
)
...
...
@@ -197,15 +214,13 @@ void Bridge::send_xmpp_message(const std::string& from, const std::string& autho
void
Bridge
::
send_user_join
(
const
std
::
string
&
hostname
,
const
std
::
string
&
chan_name
,
const
IrcUser
*
user
,
const
char
user_mode
,
const
bool
self
)
{
std
::
string
affiliation
=
"participant"
;
std
::
string
role
=
"none"
;
if
(
user
->
modes
.
find
(
'o'
)
!=
user
->
modes
.
end
())
{
affiliation
=
"admin"
;
role
=
"moderator"
;
}
std
::
string
affiliation
;
std
::
string
role
;
std
::
tie
(
role
,
affiliation
)
=
get_role_affiliation_from_irc_mode
(
user_mode
);
this
->
xmpp
->
send_user_join
(
chan_name
+
"%"
+
hostname
,
user
->
nick
,
user
->
host
,
affiliation
,
role
,
this
->
user_jid
,
self
);
}
...
...
@@ -237,30 +252,7 @@ void Bridge::send_affiliation_role_change(const Iid& iid, const std::string& tar
{
std
::
string
role
;
std
::
string
affiliation
;
if
(
mode
==
0
)
{
role
=
"participant"
;
affiliation
=
"none"
;
}
else
if
(
mode
==
'a'
)
{
role
=
"moderator"
;
affiliation
=
"owner"
;
}
else
if
(
mode
==
'o'
)
{
role
=
"moderator"
;
affiliation
=
"admin"
;
}
else
if
(
mode
==
'h'
)
{
role
=
"moderator"
;
affiliation
=
"member"
;
}
else
if
(
mode
==
'v'
)
{
role
=
"participant"
;
affiliation
=
"member"
;
}
std
::
tie
(
role
,
affiliation
)
=
get_role_affiliation_from_irc_mode
(
mode
);
this
->
xmpp
->
send_affiliation_role_change
(
iid
.
chan
+
"%"
+
iid
.
server
,
target
,
affiliation
,
role
,
this
->
user_jid
);
}
src/bridge/bridge.hpp
View file @
fef9c819
...
...
@@ -68,6 +68,7 @@ public:
void
send_user_join
(
const
std
::
string
&
hostname
,
const
std
::
string
&
chan_name
,
const
IrcUser
*
user
,
const
char
user_mode
,
const
bool
self
);
/**
* Send the topic of the MUC to the user
...
...
src/irc/irc_client.cpp
View file @
fef9c819
...
...
@@ -247,7 +247,9 @@ void IrcClient::set_and_forward_user_list(const IrcMessage& message)
if
(
user
->
nick
!=
channel
->
get_self
()
->
nick
)
{
log_debug
(
"Adding user ["
<<
nick
<<
"] to chan "
<<
chan_name
);
this
->
bridge
->
send_user_join
(
this
->
hostname
,
chan_name
,
user
,
false
);
this
->
bridge
->
send_user_join
(
this
->
hostname
,
chan_name
,
user
,
user
->
get_most_significant_mode
(
this
->
sorted_user_modes
),
false
);
}
else
{
...
...
@@ -270,7 +272,9 @@ void IrcClient::on_channel_join(const IrcMessage& message)
else
{
const
IrcUser
*
user
=
channel
->
add_user
(
nick
,
this
->
prefix_to_mode
);
this
->
bridge
->
send_user_join
(
this
->
hostname
,
chan_name
,
user
,
false
);
this
->
bridge
->
send_user_join
(
this
->
hostname
,
chan_name
,
user
,
user
->
get_most_significant_mode
(
this
->
sorted_user_modes
),
false
);
}
}
...
...
@@ -334,7 +338,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
);
this
->
bridge
->
send_user_join
(
this
->
hostname
,
chan_name
,
channel
->
get_self
(),
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_topic
(
this
->
hostname
,
chan_name
,
channel
->
topic
);
}
...
...
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