Mercurial > libervia-backend
comparison src/core/sat_main.py @ 2131:628c1c95f442
plugin XEP-0334: fixed and improved message processing hints:
- wrong elements were used in this plugging, it could not work properly
- use constants for hints
- add addHint method so other plugins can add a hint easily
- hints can be added by frontends in mess_data['extra']['hints'] (serialized dict) or by other plugins using addHint
- if history is skipped on message reception, mess_data['extra']['history']['skipped'] is set
- introduced PLUGIN_INFO['usage'] for usage information for developers
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 05 Feb 2017 14:55:19 +0100 |
parents | 6a66c8c5a567 |
children | 6e509ee853a8 |
comparison
equal
deleted
inserted
replaced
2130:f0bc29dc8157 | 2131:628c1c95f442 |
---|---|
670 """Actualy send the message to the server | 670 """Actualy send the message to the server |
671 | 671 |
672 @param data: message data dictionnary | 672 @param data: message data dictionnary |
673 @param client: profile's client | 673 @param client: profile's client |
674 """ | 674 """ |
675 client.send(data['xml']) | 675 client.send(data[u'xml']) |
676 return data | 676 return data |
677 | 677 |
678 def messageAddToHistory(self, data, client): | 678 def messageAddToHistory(self, data, client): |
679 """Store message into database (for local history) | 679 """Store message into database (for local history) |
680 | 680 |
681 @param data: message data dictionnary | 681 @param data: message data dictionnary |
682 @param client: profile's client | 682 @param client: profile's client |
683 """ | 683 """ |
684 if data["type"] != C.MESS_TYPE_GROUPCHAT: | 684 if data[u"type"] != C.MESS_TYPE_GROUPCHAT: |
685 # we don't add groupchat message to history, as we get them back | 685 # we don't add groupchat message to history, as we get them back |
686 # and they will be added then | 686 # and they will be added then |
687 if data['message'] or data['subject']: # we need a message to store | 687 if data[u'message'] or data[u'subject']: # we need a message to store |
688 self.memory.addToHistory(client, data) | 688 self.memory.addToHistory(client, data) |
689 else: | 689 else: |
690 log.warning(u"No message found") # empty body should be managed by plugins before this point | 690 log.warning(u"No message found") # empty body should be managed by plugins before this point |
691 return data | 691 return data |
692 | 692 |
694 """Send message to bridge, so frontends can display it | 694 """Send message to bridge, so frontends can display it |
695 | 695 |
696 @param data: message data dictionnary | 696 @param data: message data dictionnary |
697 @param client: profile's client | 697 @param client: profile's client |
698 """ | 698 """ |
699 if data["type"] != C.MESS_TYPE_GROUPCHAT: | 699 if data[u"type"] != C.MESS_TYPE_GROUPCHAT: |
700 # we don't send groupchat message to bridge, as we get them back | 700 # we don't send groupchat message to bridge, as we get them back |
701 # and they will be added the | 701 # and they will be added the |
702 if data['message'] or data['subject']: # we need a message to send something | 702 if data[u'message'] or data[u'subject']: # we need a message to send something |
703 # We send back the message, so all frontends are aware of it | 703 # We send back the message, so all frontends are aware of it |
704 self.bridge.messageNew(data['uid'], data['timestamp'], data['from'].full(), data['to'].full(), data['message'], data['subject'], data['type'], data['extra'], profile=client.profile) | 704 self.bridge.messageNew(data[u'uid'], data[u'timestamp'], data[u'from'].full(), data[u'to'].full(), data[u'message'], data[u'subject'], data[u'type'], data[u'extra'], profile=client.profile) |
705 else: | 705 else: |
706 log.warning(_("No message found")) | 706 log.warning(_(u"No message found")) |
707 return data | 707 return data |
708 | 708 |
709 def _setPresence(self, to="", show="", statuses=None, profile_key=C.PROF_KEY_NONE): | 709 def _setPresence(self, to="", show="", statuses=None, profile_key=C.PROF_KEY_NONE): |
710 return self.setPresence(jid.JID(to) if to else None, show, statuses, profile_key) | 710 return self.setPresence(jid.JID(to) if to else None, show, statuses, profile_key) |
711 | 711 |