summaryrefslogtreecommitdiff
path: root/sleekxmpp/basexmpp.py
diff options
context:
space:
mode:
authorLance Stout <lancestout@gmail.com>2012-06-10 14:42:54 -0700
committerLance Stout <lancestout@gmail.com>2012-06-10 14:42:54 -0700
commit19f65c8510f0c4b385a753f0817ea79877ccdc4a (patch)
treef862e765c081783c8cc1a724438bb5dbdbae6f43 /sleekxmpp/basexmpp.py
parentf70b49882ffdfa23becc715a878d4ad41ca6f17e (diff)
downloadslixmpp-19f65c8510f0c4b385a753f0817ea79877ccdc4a.tar.gz
slixmpp-19f65c8510f0c4b385a753f0817ea79877ccdc4a.tar.bz2
slixmpp-19f65c8510f0c4b385a753f0817ea79877ccdc4a.tar.xz
slixmpp-19f65c8510f0c4b385a753f0817ea79877ccdc4a.zip
Simplify send_presence_subscription.
It is technically obsolete now, but remains because it set a default subscription type of 'subscribe'.
Diffstat (limited to 'sleekxmpp/basexmpp.py')
-rw-r--r--sleekxmpp/basexmpp.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/sleekxmpp/basexmpp.py b/sleekxmpp/basexmpp.py
index 43ea6063..ae32ebec 100644
--- a/sleekxmpp/basexmpp.py
+++ b/sleekxmpp/basexmpp.py
@@ -530,13 +530,16 @@ class BaseXMPP(XMLStream):
:param pnick: Optional nickname of the presence's sender.
"""
# Python2.6 chokes on Unicode strings for dict keys.
- args = {str('pto'): pto,
- str('ptype'): ptype,
+ args = {str('ptype'): ptype,
str('pshow'): pshow,
str('pstatus'): pstatus,
str('ppriority'): ppriority,
str('pnick'): pnick}
+ if ptype in ('probe', 'subscribe', 'subscribed', \
+ 'unsubscribe', 'unsubscribed'):
+ args[str('pto')] = pto.bare
+
if self.is_component:
self.roster[pfrom].send_presence(**args)
else:
@@ -554,14 +557,10 @@ class BaseXMPP(XMLStream):
:param ptype: The type of presence, such as ``'subscribe'``.
:param pnick: Optional nickname of the presence's sender.
"""
- presence = self.makePresence(ptype=ptype,
- pfrom=pfrom,
- pto=self.getjidbare(pto))
- if pnick:
- nick = ET.Element('{http://jabber.org/protocol/nick}nick')
- nick.text = pnick
- presence.append(nick)
- presence.send()
+ self.send_presence(pto=pto,
+ pfrom=pfrom,
+ ptype=ptype,
+ pnick=pnick)
@property
def jid(self):