core: moved CHAT_* constants from frontends to core constants + uses constants for MESS_TYPE_* in sendMessage

This commit is contained in:
Goffi 2018-01-03 00:13:48 +01:00
commit a9fb2e568e

View file

@ -356,6 +356,9 @@ class SatXMPPEntity(object):
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 @@ class SatXMPPEntity(object):
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 @@ class SatXMPPEntity(object):
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