Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0249.py @ 1970:200cd707a46d
plugin XEP-0045, quick_frontend + primitivus (chat): cleaning of XEP-0045 (first pass):
- bridge methods/signals now all start with "muc" to follow new convention
- internal method use client instead of profile to follow new convention
- removed excetpions from plugin XEP-0045 in favor of core.exceptions, NotReady added
- cleaned/simplified several part of the code. checkClient removed as it is not needed anymore
- self.clients map removed, muc data are now stored directly in client
- getRoomEntityNick and getRoomNicksOfUsers are removed as they don't look sane.
/!\ This break all room game plugins for the moment
- use of uuid4 instead of uuid1 for getUniqueName, as host ID and current time are used for uuid1
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 27 Jun 2016 21:45:11 +0200 |
parents | a2bc5089c2eb |
children | a5eb6f6b8db2 |
comparison
equal
deleted
inserted
replaced
1969:5fbe09b9b568 | 1970:200cd707a46d |
---|---|
17 # You should have received a copy of the GNU Affero General Public License | 17 # You should have received a copy of the GNU Affero General Public License |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 from sat.core.i18n import _ | 20 from sat.core.i18n import _ |
21 from sat.core.constants import Const as C | 21 from sat.core.constants import Const as C |
22 from sat.core import exceptions | |
22 from sat.core.log import getLogger | 23 from sat.core.log import getLogger |
23 log = getLogger(__name__) | 24 log = getLogger(__name__) |
24 from twisted.words.xish import domish | 25 from twisted.words.xish import domish |
25 from twisted.words.protocols.jabber import jid | 26 from twisted.words.protocols.jabber import jid |
26 | 27 |
134 """ | 135 """ |
135 called when an invitation is received | 136 called when an invitation is received |
136 @param message: message element | 137 @param message: message element |
137 @profile: %(doc_profile)s | 138 @profile: %(doc_profile)s |
138 """ | 139 """ |
140 client = self.host.getClient(profile) | |
139 try: | 141 try: |
140 room_jid_s = message.firstChildElement()['jid'] | 142 room_jid_s = message.firstChildElement()['jid'] |
141 log.info(_(u'Invitation received for room %(room)s [%(profile)s]') % {'room': room_jid_s, 'profile': profile}) | 143 log.info(_(u'Invitation received for room %(room)s [%(profile)s]') % {'room': room_jid_s, 'profile': profile}) |
142 except: | 144 except: |
143 log.error(_('Error while parsing invitation')) | 145 log.error(_('Error while parsing invitation')) |
144 return | 146 return |
145 from_jid_s = message["from"] | 147 from_jid_s = message["from"] |
146 room_jid = jid.JID(room_jid_s) | 148 room_jid = jid.JID(room_jid_s) |
147 if room_jid in self.host.plugins["XEP-0045"].clients[profile].joined_rooms: | 149 try: |
148 log.info(_("Invitation silently discarded because user is already in the room.")) | 150 self.host.plugins["XEP-0045"].checkRoomJoined(client, room_jid) |
151 except exceptions.NotFound: | |
152 pass | |
153 else: | |
154 log.info(_(u"Invitation silently discarded because user is already in the room.")) | |
149 return | 155 return |
156 | |
150 autojoin = self.host.memory.getParamA(AUTOJOIN_NAME, AUTOJOIN_KEY, profile_key=profile) | 157 autojoin = self.host.memory.getParamA(AUTOJOIN_NAME, AUTOJOIN_KEY, profile_key=profile) |
151 | 158 |
152 def accept_cb(conf_id, accepted, data, profile): | 159 def accept_cb(conf_id, accepted, data, profile): |
153 if conf_id == room_jid_s and accepted: | 160 if conf_id == room_jid_s and accepted: |
154 self._accept(room_jid, profile) | 161 self._accept(room_jid, profile) |