# HG changeset patch # User souliane # Date 1427178872 -3600 # Node ID 73f8582c7c99c5c0da47ee0a447a22d0834c09f4 # Parent 59c48796759ebe440d3ce947bb95d9575b4004ae plugins XEP-0045, XEP-0249: allow to join / invite without specifying the JID's host part (use client's values) diff -r 59c48796759e -r 73f8582c7c99 src/core/constants.py --- a/src/core/constants.py Mon Mar 23 09:34:23 2015 +0100 +++ b/src/core/constants.py Tue Mar 24 07:34:32 2015 +0100 @@ -32,7 +32,7 @@ APP_NAME_FILE = u'sat' APP_NAME_FULL = u'%s (%s)' % (APP_NAME_SHORT, APP_NAME) APP_VERSION = u'0.5.1D' # Please add 'D' at the end for dev versions - APP_URL = 'http://salut-a-toi.org' + APP_URL = u'http://salut-a-toi.org' # Protocol diff -r 59c48796759e -r 73f8582c7c99 src/plugins/plugin_xep_0045.py --- a/src/plugins/plugin_xep_0045.py Mon Mar 23 09:34:23 2015 +0100 +++ b/src/plugins/plugin_xep_0045.py Tue Mar 24 07:34:32 2015 +0100 @@ -363,13 +363,13 @@ if not self.checkClient(profile): return if room_jid_s: + muc_service = self.host.getClient(profile).muc_service try: room_jid = jid.JID(room_jid_s) except (RuntimeError, jid.InvalidFormat, AttributeError): - mess = _("Invalid room JID: %s") % room_jid_s - log.warning(mess) - self.host.bridge.newAlert(mess, _("Group chat error"), "ERROR", profile) - return defer.succeed(None) + return defer.fail(jid.InvalidFormat(_(u"Invalid room identifier: '%s'. Please give a room short or full identifier like 'room' or 'room@%s'.") % (room_jid_s, unicode(muc_service)))) + if not room_jid.user: + room_jid.user, room_jid.host = room_jid.host, muc_service else: room_jid = self.getUniqueName(profile_key=profile_key) # TODO: error management + signal in bridge diff -r 59c48796759e -r 73f8582c7c99 src/plugins/plugin_xep_0249.py --- a/src/plugins/plugin_xep_0249.py Mon Mar 23 09:34:23 2015 +0100 +++ b/src/plugins/plugin_xep_0249.py Tue Mar 24 07:34:32 2015 +0100 @@ -171,18 +171,17 @@ @command (group): JID - JID: the JID of the person to invite """ - jid_s = mess_data["unparsed"].strip() + contact_jid_s = mess_data["unparsed"].strip() + my_host = self.host.profiles[profile].jid.host try: - assert jid_s - jid_ = jid.JID(jid_s) - assert jid_.user - assert jid_.host - except (jid.InvalidFormat, AssertionError): - feedback = _(u"You must provide a valid JID to invite, like in '/invite contact@example.net'") + contact_jid = jid.JID(contact_jid_s) + except (RuntimeError, jid.InvalidFormat, AttributeError): + feedback = _(u"You must provide a valid JID to invite, like in '/invite contact@{host}'").format(host=my_host) self.host.plugins[C.TEXT_CMDS].feedBack(feedback, mess_data, profile) return False - - self.invite(jid_, mess_data["to"], {}, profile) + if not contact_jid.user: + contact_jid.user, contact_jid.host = contact_jid.host, my_host + self.invite(contact_jid, mess_data["to"], {}, profile) return False