summaryrefslogtreecommitdiff
path: root/src/xmpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/xmpp')
-rw-r--r--src/xmpp/xmpp_component.cpp48
-rw-r--r--src/xmpp/xmpp_component.hpp9
2 files changed, 18 insertions, 39 deletions
diff --git a/src/xmpp/xmpp_component.cpp b/src/xmpp/xmpp_component.cpp
index 1cc4c25..f0d1d3a 100644
--- a/src/xmpp/xmpp_component.cpp
+++ b/src/xmpp/xmpp_component.cpp
@@ -294,7 +294,10 @@ void XmppComponent::send_message(const std::string& from, Xmpp::body&& body, con
void XmppComponent::send_user_join(const std::string& from,
const std::string& nick,
const std::string& realjid,
- const std::string& to)
+ const std::string& affiliation,
+ const std::string& role,
+ const std::string& to,
+ const bool self)
{
XmlNode node("presence");
node["to"] = to;
@@ -305,8 +308,8 @@ void XmppComponent::send_user_join(const std::string& from,
// TODO: put real values here
XmlNode item("item");
- item["affiliation"] = "member";
- item["role"] = "participant";
+ item["affiliation"] = affiliation;
+ item["role"] = role;
if (!realjid.empty())
{
const std::string preped_jid = jidprep(realjid);
@@ -315,35 +318,15 @@ void XmppComponent::send_user_join(const std::string& from,
}
item.close();
x.add_child(std::move(item));
- x.close();
- node.add_child(std::move(x));
- node.close();
- this->send_stanza(node);
-}
-
-void XmppComponent::send_self_join(const std::string& from, const std::string& nick, const std::string& to)
-{
- XmlNode node("presence");
- node["to"] = to;
- node["from"] = from + "@" + this->served_hostname + "/" + nick;
-
- XmlNode x("x");
- x["xmlns"] = MUC_USER_NS;
-
- // TODO: put real values here
- XmlNode item("item");
- item["affiliation"] = "member";
- item["role"] = "participant";
- item.close();
- x.add_child(std::move(item));
-
- XmlNode status("status");
- status["code"] = "110";
- status.close();
- x.add_child(std::move(status));
+ if (self)
+ {
+ XmlNode status("status");
+ status["code"] = "110";
+ status.close();
+ x.add_child(std::move(status));
+ }
x.close();
-
node.add_child(std::move(x));
node.close();
this->send_stanza(node);
@@ -438,10 +421,7 @@ void XmppComponent::send_nick_change(const std::string& muc_name, const std::str
presence.close();
this->send_stanza(presence);
- if (self)
- this->send_self_join(muc_name, new_nick, jid_to);
- else
- this->send_user_join(muc_name, new_nick, "", jid_to);
+ this->send_user_join(muc_name, new_nick, "", "participant", "none", jid_to, self);
}
void XmppComponent::kick_user(const std::string& muc_name,
diff --git a/src/xmpp/xmpp_component.hpp b/src/xmpp/xmpp_component.hpp
index 63eb88f..c10f10a 100644
--- a/src/xmpp/xmpp_component.hpp
+++ b/src/xmpp/xmpp_component.hpp
@@ -78,11 +78,10 @@ public:
void send_user_join(const std::string& from,
const std::string& nick,
const std::string& realjid,
- const std::string& to);
- /**
- * Send the self join to the user
- */
- void send_self_join(const std::string& from, const std::string& nick, const std::string& to);
+ const std::string& affiliation,
+ const std::string& role,
+ const std::string& to,
+ const bool self);
/**
* Send the MUC topic to the user
*/