Enforce email check

This commit is contained in:
Yax 2018-02-11 14:48:48 +01:00
parent 3064dca6ca
commit ad8c1cf115
2 changed files with 20 additions and 12 deletions

View file

@ -12,14 +12,21 @@ logger = logging.getLogger(__name__)
def process_message(chan, method, properties, body):
topic = method.routing_key
data = json.loads(body)
if topic == 'mail.message':
logger.info('new message => {}'.format(data))
processor.enqueue({'request': 'new_mail', 'data': data})
else:
logger.warn('unsupported message [topic={}]'.format(topic))
try:
topic = method.routing_key
data = json.loads(body)
if topic == 'mail.message':
if "STACOSYS" in data['subject']:
logger.info('new message => {}'.format(data))
processor.enqueue({'request': 'new_mail', 'data': data})
else:
logger.info('ignore message => {}'.format(data))
else:
logger.warn('unsupported message [topic={}]'.format(topic))
except:
logger.exception('cannot process message')
class MessageConsumer(Thread):