Commit 2fafa923 authored by jssuzanne's avatar jssuzanne
Browse files

Fix missing contenttype, log another error when no status

--HG--
branch : 8.0
parent b6557f124cf8
......@@ -29,7 +29,10 @@ class AnybusMessage(models.Model):
method = fields.Char(track_visibility="onchange")
message = fields.Binary(required=True, track_visibility="onchange")
contenttype = fields.Char(required=True, track_visibility="onchange")
contenttype = fields.Char(
required=True, track_visibility="onchange",
default='text/plain',
)
error = fields.Text(readonly=True, track_visibility="onchange")
def _needaction_domain_get(self, *a, **kw):
......
......@@ -20,7 +20,6 @@ def anybus_schema_validation(schema):
def method_wrapper(method):
def call_wrapper(self, body=None):
print(' ==> ', body)
res = schema.load(loads(body))
data, error = res.data, res.errors
if error:
......
......@@ -120,19 +120,32 @@ class Consumer:
self._channel.basic_reject(basic_deliver.delivery_tag)
logger.info('reject queue %s tag %r',
queue, basic_deliver.delivery_tag)
elif status is MessageStatus.ERROR or status is None:
elif status is MessageStatus.ERROR:
self.session.env['anybus.message'].create(dict(
sequence=basic_deliver.delivery_tag,
queue=queue,
model=model_id,
method=method,
message=b64encode(body),
contenttype=properties.content_type,
contenttype=properties.content_type or 'text/plain',
error=error
))
self._channel.basic_ack(basic_deliver.delivery_tag)
logger.info('save message of the queue %s tag %r',
queue, basic_deliver.delivery_tag)
logger.error('save message of the queue %s tag %r',
queue, basic_deliver.delivery_tag)
elif status is None:
self.session.env['anybus.message'].create(dict(
sequence=basic_deliver.delivery_tag,
queue=queue,
model=model_id,
method=method,
message=b64encode(body),
contenttype=properties.content_type or 'text/plain',
error="No returned status"
))
self._channel.basic_ack(basic_deliver.delivery_tag)
logger.error('save message of the queue %s tag %r',
queue, basic_deliver.delivery_tag)
self.session.env.cr.commit()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment