Fixed specifying 'from' values in XEP-0045 plugin.

Methods now accept either an ifrom or mfrom parameter
to specify a 'from' value. Client connections should not
need to use these, but component connections must use them.
This commit is contained in:
Lance Stout 2010-12-16 18:14:33 -05:00
parent 4b57b8131f
commit 62b190d0ff

View file

@ -276,10 +276,10 @@ class xep_0045(base.base_plugin):
raise ValueError raise ValueError
return True return True
def invite(self, room, jid, reason=''): def invite(self, room, jid, reason='', mfrom=''):
""" Invite a jid to a room.""" """ Invite a jid to a room."""
msg = self.xmpp.makeMessage(room) msg = self.xmpp.makeMessage(room)
msg['from'] = self.xmpp.boundjid.bare msg['from'] = mfrom
x = ET.Element('{http://jabber.org/protocol/muc#user}x') x = ET.Element('{http://jabber.org/protocol/muc#user}x')
invite = ET.Element('{http://jabber.org/protocol/muc#user}invite', {'to': jid}) invite = ET.Element('{http://jabber.org/protocol/muc#user}invite', {'to': jid})
if reason: if reason:
@ -299,10 +299,10 @@ class xep_0045(base.base_plugin):
self.xmpp.sendPresence(pshow='unavailable', pto="%s/%s" % (room, nick)) self.xmpp.sendPresence(pshow='unavailable', pto="%s/%s" % (room, nick))
del self.rooms[room] del self.rooms[room]
def getRoomConfig(self, room): def getRoomConfig(self, room, ifrom=''):
iq = self.xmpp.makeIqGet('http://jabber.org/protocol/muc#owner') iq = self.xmpp.makeIqGet('http://jabber.org/protocol/muc#owner')
iq['to'] = room iq['to'] = room
iq['from'] = self.xmpp.boundjid.bare iq['from'] = ifrom
result = iq.send() result = iq.send()
if result is None or result['type'] != 'result': if result is None or result['type'] != 'result':
raise ValueError raise ValueError
@ -318,13 +318,13 @@ class xep_0045(base.base_plugin):
iq = self.xmpp.makeIqSet(query) iq = self.xmpp.makeIqSet(query)
iq.send() iq.send()
def setRoomConfig(self, room, config): def setRoomConfig(self, room, config, ifrom=''):
query = ET.Element('{http://jabber.org/protocol/muc#owner}query') query = ET.Element('{http://jabber.org/protocol/muc#owner}query')
x = config.getXML('submit') x = config.getXML('submit')
query.append(x) query.append(x)
iq = self.xmpp.makeIqSet(query) iq = self.xmpp.makeIqSet(query)
iq['to'] = room iq['to'] = room
iq['from'] = self.xmpp.boundjid.bare iq['from'] = ifrom
iq.send() iq.send()
def getJoinedRooms(self): def getJoinedRooms(self):