Mercurial > libervia-backend
diff src/plugins/plugin_xep_0048.py @ 1963:a2bc5089c2eb
backend, frontends: message refactoring (huge commit):
/!\ several features are temporarily disabled, like notifications in frontends
next step in refactoring, with the following changes:
- jp: updated jp message to follow changes in backend/bridge
- jp: added --lang, --subject, --subject_lang, and --type options to jp message + fixed unicode handling for jid
- quick_frontend (QuickApp, QuickChat):
- follow backend changes
- refactored chat, message are now handled in OrderedDict and uid are kept so they can be updated
- Message and Occupant classes handle metadata, so frontend just have to display them
- Primitivus (Chat):
- follow backend/QuickFrontend changes
- info & standard messages are handled in the same MessageWidget class
- improved/simplified handling of messages, removed update() method
- user joined/left messages are merged when next to each other
- a separator is shown when message is received while widget is out of focus, so user can quickly see the new messages
- affiliation/role are shown (in a basic way for now) in occupants panel
- removed "/me" messages handling, as it will be done by a backend plugin
- message language is displayed when available (only one language per message for now)
- fixed :history and :search commands
- core (constants): new constants for messages type, XML namespace, entity type
- core: *Message methods renamed to follow new code sytle (e.g. sendMessageToBridge => messageSendToBridge)
- core (messages handling): fixed handling of language
- core (messages handling): mes_data['from'] and ['to'] are now jid.JID
- core (core.xmpp): reorganised message methods, added getNick() method to client.roster
- plugin text commands: fixed plugin and adapted to new messages behaviour. client is now used in arguments instead of profile
- plugins: added information for cancellation reason in CancelError calls
- plugin XEP-0045: various improvments, but this plugin still need work:
- trigger is used to avoid message already handled by the plugin to be handled a second time
- changed the way to handle history, the last message from DB is checked and we request only messages since this one, in seconds (thanks Poezio folks :))
- subject reception is waited before sending the roomJoined signal, this way we are sure that everything including history is ready
- cmd_* method now follow the new convention with client instead of profile
- roomUserJoined and roomUserLeft messages are removed, the events are now handled with info message with a "ROOM_USER_JOINED" info subtype
- probably other forgotten stuffs :p
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 20 Jun 2016 18:41:53 +0200 |
parents | 2daf7b4c6756 |
children | 1d3f73e065e1 |
line wrap: on
line diff
--- a/src/plugins/plugin_xep_0048.py Sun Jun 19 22:22:13 2016 +0200 +++ b/src/plugins/plugin_xep_0048.py Mon Jun 20 18:41:53 2016 +0200 @@ -88,7 +88,7 @@ for (room_jid, data) in bookmarks[XEP_0048.MUC_TYPE].items(): if data.get('autojoin', 'false') == 'true': nick = data.get('nick', client.jid.user) - self.host.plugins['XEP-0045'].join(room_jid, nick, {}, profile_key=client.profile) + self.host.plugins['XEP-0045'].join(client, room_jid, nick, {}) @defer.inlineCallbacks def _getServerBookmarks(self, storage_type, profile): @@ -219,9 +219,10 @@ log.warning(_("No room jid selected")) return {} - d = self.host.plugins['XEP-0045'].join(room_jid, nick, {}, profile_key=profile) + client = self.host.getClient(profile) + d = self.host.plugins['XEP-0045'].join(client, room_jid, nick, {}) def join_eb(failure): - log.warning(u"Error while trying to join room: %s" % failure) + log.warning(u"Error while trying to join room: {}".format(failure)) # FIXME: failure are badly managed in plugin XEP-0045. Plugin XEP-0045 need to be fixed before managing errors correctly here return {} d.addCallbacks(lambda dummy: {}, join_eb) @@ -417,33 +418,32 @@ location = jid.JID(location) return self.addBookmark(type_, location, data, storage_type, profile_key) - def cmd_bookmark(self, mess_data, profile): + def cmd_bookmark(self, client, mess_data): """(Un)bookmark a MUC room @command (group): [autojoin | remove] - autojoin: join room automatically on connection - remove: remove bookmark(s) for this room """ - client = self.host.getClient(profile) txt_cmd = self.host.plugins[C.TEXT_CMDS] options = mess_data["unparsed"].strip().split() if options and options[0] not in ('autojoin', 'remove'): - txt_cmd.feedBack(_("Bad arguments"), mess_data, profile) + txt_cmd.feedBack(client, _("Bad arguments"), mess_data) return False room_jid = mess_data["to"].userhostJID() if "remove" in options: - self.removeBookmark(XEP_0048.MUC_TYPE, room_jid, profile_key = profile) - txt_cmd.feedBack(_("All [%s] bookmarks are being removed") % room_jid.full(), mess_data, profile) + self.removeBookmark(XEP_0048.MUC_TYPE, room_jid, profile_key = client.profile) + txt_cmd.feedBack(client, _("All [%s] bookmarks are being removed") % room_jid.full(), mess_data) return False data = { "name": room_jid.user, "nick": client.jid.user, "autojoin": "true" if "autojoin" in options else "false", } - self.addBookmark(XEP_0048.MUC_TYPE, room_jid, data, profile_key=profile) - txt_cmd.feedBack(_("Bookmark added"), mess_data, profile) + self.addBookmark(XEP_0048.MUC_TYPE, room_jid, data, profile_key=client.profile) + txt_cmd.feedBack(client, _("Bookmark added"), mess_data) return False