plugin XEP-0045: room configuration returns a success or failure message
This commit is contained in:
parent
f08b22ecb2
commit
e18adb373d
1 changed files with 11 additions and 8 deletions
|
|
@ -17,7 +17,7 @@
|
|||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from sat.core.i18n import _
|
||||
from sat.core.i18n import _, D_
|
||||
from sat.core.constants import Const as C
|
||||
from sat.core.log import getLogger
|
||||
log = getLogger(__name__)
|
||||
|
|
@ -124,9 +124,9 @@ class XEP_0045(object):
|
|||
# we have a nickname conflict, we try again with "_" suffixed to current nickname
|
||||
nick += '_'
|
||||
return self.clients[profile].join(room_jid, nick, history_options, password).addCallbacks(self.__room_joined, self.__err_joining_room, callbackKeywords={'profile': profile}, errbackArgs=[room_jid, nick, history_options, password, profile])
|
||||
mess = _("Error while joining the room %s" % room_jid.userhost())
|
||||
mess = D_("Error while joining the room %s" % room_jid.userhost())
|
||||
log.error(mess)
|
||||
self.host.bridge.newAlert(mess, _("Group chat error"), "ERROR", profile)
|
||||
self.host.bridge.newAlert(mess, D_("Group chat error"), "ERROR", profile)
|
||||
raise failure
|
||||
|
||||
def getRoomsJoined(self, profile_key=C.PROF_KEY_NONE):
|
||||
|
|
@ -206,7 +206,7 @@ class XEP_0045(object):
|
|||
if not self.__check_profile(profile):
|
||||
raise exceptions.ProfileUnknownError("Unknown or disconnected profile")
|
||||
if room_jid.userhost() not in self.clients[profile].joined_rooms:
|
||||
raise UnknownRoom("This room has not been joined")
|
||||
raise UnknownRoom(D_("This room has not been joined"))
|
||||
|
||||
def config2XMLUI(result):
|
||||
if not result:
|
||||
|
|
@ -225,13 +225,16 @@ class XEP_0045(object):
|
|||
try:
|
||||
session_data = self._sessions.profileGet(raw_data["session_id"], profile)
|
||||
except KeyError:
|
||||
log.warning ("session id doesn't exist, session has probably expired")
|
||||
# TODO: send error dialog
|
||||
return defer.succeed({})
|
||||
log.warning(D_("Session ID doesn't exist, session has probably expired."))
|
||||
_dialog = xml_tools.XMLUI('popup', title=D_('Room configuration failed'))
|
||||
_dialog.addText(D_("Session ID doesn't exist, session has probably expired."))
|
||||
return defer.succeed({'xmlui': _dialog.toXml()})
|
||||
|
||||
data = xml_tools.XMLUIResult2DataFormResult(raw_data)
|
||||
d = self.clients[profile].configure(session_data['room_jid'], data)
|
||||
d.addCallback(lambda ignore: {})
|
||||
_dialog = xml_tools.XMLUI('popup', title=D_('Room configuration succeed'))
|
||||
_dialog.addText(D_("The new settings have been saved."))
|
||||
d.addCallback(lambda ignore: {'xmlui': _dialog.toXml()})
|
||||
del self._sessions[raw_data["session_id"]]
|
||||
return d
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue