From 19f65c8510f0c4b385a753f0817ea79877ccdc4a Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Sun, 10 Jun 2012 14:42:54 -0700 Subject: Simplify send_presence_subscription. It is technically obsolete now, but remains because it set a default subscription type of 'subscribe'. --- sleekxmpp/basexmpp.py | 19 +++++++++---------- 1 file 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): -- cgit v1.2.3