source:
ralphm-patches/roster_item_more.patch
@
54:03ec57713c90
Last change on this file since 54:03ec57713c90 was 54:03ec57713c90, checked in by Ralph Meijer <ralphm@…>, 11 years ago | |
---|---|
File size: 3.1 KB |
-
wokkel/im.py
# HG changeset patch # Parent a8623e33ce6e62e39e0049451c5f65016c8b30b7 Record sender on received roster sets to support alternative roster sources. TODO: roster item removal notifications. diff -r a8623e33ce6e wokkel/im.py
a b 371 371 @ivar groups: Set of groups this contact is categorized in. Groups are 372 372 represented by an opaque identifier of type C{unicode}. 373 373 @type groups: C{set} 374 @ivar approved: Signals pre-approved subscription. 375 @type approved: C{bool} 376 @ivar remove: Signals roster item removal. 377 @type remove: C{bool} 378 @ivar sender: The JID of the entity that sent this roster item. 379 @type sender: L{JID} 374 380 """ 375 381 376 382 __subscriptionStates = {(False, False): None, … … 381 387 def __init__(self, entity, subscriptionTo=False, subscriptionFrom=False, 382 388 name=None, groups=None): 383 389 self.entity = entity 390 self.name = name 384 391 self.subscriptionTo = subscriptionTo 385 392 self.subscriptionFrom = subscriptionFrom 386 self.name = name387 393 self.groups = groups or set() 388 394 389 395 self.pendingOut = False 390 396 self.approved = False 391 397 self.remove = False 392 398 399 self.sender = None 400 393 401 394 402 def toElement(self): 395 403 element = domish.Element((NS_ROSTER, 'item')) … … 505 513 raise error.StanzaError('service-unavailable') 506 514 507 515 item = RosterItem.fromElement(iq.query.item) 516 if iq.hasAttribute('from'): 517 item.sender = jid.internJID(iq['from']) 508 518 509 519 if item.remove: 510 520 d = defer.maybeDeferred(self.onRosterRemove, item.entity) -
wokkel/test/test_im.py
diff -r a8623e33ce6e wokkel/test/test_im.py
a b 764 764 return d 765 765 766 766 767 def test_onRosterSet Untrusted(self):767 def test_onRosterSetIgnored(self): 768 768 """ 769 Roster pushes from untrusted sources will be not be handled.769 Ignored roster pushes return a service unavailable error. 770 770 """ 771 771 xml = """ 772 772 <iq type='set' from='bad@example.org'> … … 790 790 return d 791 791 792 792 793 def test_onRosterSetOtherSource(self): 794 """ 795 Roster pushes can be sent from other entities, too. 796 """ 797 xml = """ 798 <iq type='set' from='other@example.org'> 799 <query xmlns='jabber:iq:roster'> 800 <item jid='user@example.org'/> 801 </query> 802 </iq> 803 """ 804 805 items = [] 806 807 def onRosterSet(item): 808 items.append(item) 809 810 def cb(result): 811 item = items[0] 812 self.assertEquals(JID('other@example.org'), item.sender) 813 814 self.service.onRosterSet = onRosterSet 815 816 d = self.handleRequest(xml) 817 d.addCallback(cb) 818 return d 819 820 793 821 def test_onRosterRemove(self): 794 822 """ 795 823 A roster push causes onRosterSet to be called with the parsed item.
Note: See TracBrowser
for help on using the repository browser.