# HG changeset patch # User Goffi # Date 1514934828 -3600 # Node ID feaacc462fef39217e84abda819e0bb48b9cb148 # Parent a9c092bf4ee92ace44148850321f603fe9edfd92 core: moved CHAT_* constants from frontends to core constants + uses constants for MESS_TYPE_* in sendMessage diff -r a9c092bf4ee9 -r feaacc462fef frontends/src/quick_frontend/constants.py --- a/frontends/src/quick_frontend/constants.py Tue Dec 12 01:07:25 2017 +0100 +++ b/frontends/src/quick_frontend/constants.py Wed Jan 03 00:13:48 2018 +0100 @@ -53,8 +53,6 @@ CONTACT_DATA_FORBIDDEN = {CONTACT_GROUPS, CONTACT_RESOURCES, CONTACT_MAIN_RESOURCE, CONTACT_SELECTED, CONTACT_PROFILE} # set of forbidden names for contact data # Chats - CHAT_ONE2ONE = 'one2one' - CHAT_GROUP = 'group' CHAT_STATE_ICON = { "": u" ", "active": u'✔', diff -r a9c092bf4ee9 -r feaacc462fef src/core/constants.py --- a/src/core/constants.py Tue Dec 12 01:07:25 2017 +0100 +++ b/src/core/constants.py Wed Jan 03 00:13:48 2018 +0100 @@ -119,6 +119,11 @@ MESS_EXTRA_INFO = "info_type" + ## Chat ## + CHAT_ONE2ONE = 'one2one' + CHAT_GROUP = 'group' + + ## Presence ## PRESENCE_UNAVAILABLE = 'unavailable' PRESENCE_SHOW_AWAY = 'away' diff -r a9c092bf4ee9 -r feaacc462fef src/core/xmpp.py --- a/src/core/xmpp.py Tue Dec 12 01:07:25 2017 +0100 +++ b/src/core/xmpp.py Wed Jan 03 00:13:48 2018 +0100 @@ -356,6 +356,9 @@ subject = {} if extra is None: extra = {} + + assert mess_type in C.MESS_TYPE_ALL + data = { # dict is similar to the one used in client.onMessage "from": self.jid, "to": to_jid, @@ -369,10 +372,10 @@ pre_xml_treatments = defer.Deferred() # XXX: plugin can add their pre XML treatments to this deferred post_xml_treatments = defer.Deferred() # XXX: plugin can add their post XML treatments to this deferred - if data["type"] == "auto": + if data["type"] == C.MESS_TYPE_AUTO: # we try to guess the type if data["subject"]: - data["type"] = 'normal' + data["type"] = C.MESS_TYPE_NORMAL elif not data["to"].resource: # if to JID has a resource, the type is not 'groupchat' # we may have a groupchat message, we check if the we know this jid try: @@ -382,12 +385,12 @@ entity_type = "contact" if entity_type == "chatroom": - data["type"] = 'groupchat' + data["type"] = C.MESS_TYPE_GROUPCHAT else: - data["type"] = 'chat' + data["type"] = C.MESS_TYPE_CHAT else: - data["type"] == 'chat' - data["type"] == "chat" if data["subject"] else "normal" + data["type"] == C.MESS_TYPE_CHAT + data["type"] == C.MESS_TYPE_CHAT if data["subject"] else C.MESS_TYPE_NORMAL # FIXME: send_only is used by libervia's OTR plugin to avoid # the triggers from frontend, and no_trigger do the same