Ignore nick change when there is a configured nick
The user has configured their nick and that's what we should use. If they send a nick change, just reply letting them know what their nick actually is.
This commit is contained in:
@@ -599,6 +599,29 @@ void Bridge::send_irc_nick_change(const Iid& iid, const std::string& new_nick, c
|
||||
if (new_nick == irc->get_own_nick())
|
||||
return;
|
||||
|
||||
#ifdef USE_DATABASE
|
||||
auto soptions = Database::get_irc_server_options(this->get_bare_jid(), iid.get_server());
|
||||
const auto& db_nick = soptions.col<Database::Nick>();
|
||||
if (!db_nick.empty())
|
||||
{
|
||||
IrcChannel* channel = irc->get_channel(iid.get_local());
|
||||
const IrcUser* self = channel ? channel->get_self() : nullptr;
|
||||
// Send presence 110+210 to let them know the nick we're actually using
|
||||
if (self)
|
||||
{
|
||||
this->send_user_join(iid.get_server(), iid.get_local(), self,
|
||||
self->get_most_significant_mode(irc->get_sorted_user_modes()),
|
||||
true, requesting_resource);
|
||||
}
|
||||
else
|
||||
{
|
||||
IrcUser user(irc->get_own_nick());
|
||||
this->send_user_join(iid.get_server(), iid.get_local(), &user, '\0', true, requesting_resource);
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
irc->send_nick_command(new_nick);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
from scenarios import *
|
||||
|
||||
scenario = (
|
||||
send_stanza("<presence from='{jid_one}/{resource_one}' to='#foo%{irc_server_one}/{nick_one}' ><x xmlns='http://jabber.org/protocol/muc'/></presence>"),
|
||||
sequences.connection(),
|
||||
expect_stanza("/presence[@to='{jid_one}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_one}']/muc_user:x/muc_user:item[@affiliation='admin'][@role='moderator']",
|
||||
"/presence/muc_user:x/muc_user:status[@code='110']"),
|
||||
expect_stanza("/message[@from='#foo%{irc_server_one}'][@type='groupchat']/subject[not(text())]"),
|
||||
|
||||
# Configure a nickname in the database for this server
|
||||
send_stanza("<iq type='set' id='conf1' from='{jid_one}/{resource_one}' to='{irc_server_one}'><command xmlns='http://jabber.org/protocol/commands' node='configure' action='execute' /></iq>"),
|
||||
expect_stanza("/iq[@type='result']",
|
||||
after = save_value("sessionid", extract_attribute("/iq[@type='result']/commands:command[@node='configure']", "sessionid"))),
|
||||
send_stanza("<iq type='set' id='conf2' from='{jid_one}/{resource_one}' to='{irc_server_one}'>"
|
||||
"<command xmlns='http://jabber.org/protocol/commands' node='configure' sessionid='{sessionid}' action='complete'>"
|
||||
"<x xmlns='jabber:x:data' type='submit'>"
|
||||
"<field var='nick'><value>{nick_one}</value></field>"
|
||||
"</x></command></iq>"),
|
||||
expect_stanza("/iq[@type='result']/commands:command[@node='configure'][@status='completed']/commands:note[@type='info'][text()='Configuration successfully applied.']"),
|
||||
|
||||
# Now with a DB nick configured, attempt to change nick: should reply with 110 + 210 presence rewriting to DB nick
|
||||
send_stanza("<presence from='{jid_one}/{resource_one}' to='#foo%{irc_server_one}/SomeOtherNick' />"),
|
||||
expect_stanza("/presence[@to='{jid_one}/{resource_one}'][@from='#foo%{irc_server_one}/{nick_one}']/muc_user:x/muc_user:item[@affiliation='admin'][@role='moderator']",
|
||||
"/presence/muc_user:x/muc_user:status[@code='110']",
|
||||
"/presence/muc_user:x/muc_user:status[@code='210']"),
|
||||
)
|
||||
Reference in New Issue
Block a user