Send admin contac tot user
This commit is contained in:
parent
ab72dd03c6
commit
7067865738
2 changed files with 16 additions and 1 deletions
|
@ -8,7 +8,7 @@ backend_host=localhost
|
|||
pidfile=./test.pid
|
||||
# < this option doesn't work yet
|
||||
#backend_port=10001
|
||||
admin_username=admin
|
||||
admin_jid=admin@localhost
|
||||
admin_password=test
|
||||
#cert=server.pfx #patch to PKCS#12 certificate
|
||||
#cert_password=test #password to that certificate if any
|
||||
|
|
|
@ -152,6 +152,21 @@ void UserManager::handlePresence(Swift::Presence::ref presence) {
|
|||
if (!user) {
|
||||
// Admin user is not legacy network user, so do not create User class instance for him
|
||||
if (m_component->inServerMode() && CONFIG_STRING(m_component->getConfig(), "service.admin_jid") == presence->getFrom().toBare().toString()) {
|
||||
// Send admin contact to the user.
|
||||
Swift::RosterPayload::ref payload = Swift::RosterPayload::ref(new Swift::RosterPayload());
|
||||
Swift::RosterItemPayload item;
|
||||
item.setJID(m_component->getJID());
|
||||
item.setName("Admin");
|
||||
item.setSubscription(Swift::RosterItemPayload::Both);
|
||||
payload->addItem(item);
|
||||
|
||||
Swift::SetRosterRequest::ref request = Swift::SetRosterRequest::create(payload, presence->getFrom(), m_component->getIQRouter());
|
||||
request->send();
|
||||
|
||||
Swift::Presence::ref response = Swift::Presence::create();
|
||||
response->setTo(presence->getFrom());
|
||||
response->setFrom(m_component->getJID());
|
||||
m_component->getStanzaChannel()->sendPresence(response);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue