f1cfaa4988b230e417edf83c40890dc627fc7b7c
[motion2.git] / server / components / interaction / service.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0x4d61=['stringify','null','upperFirst','Interaction','then','update','info','catch','error','user','query','clone','omit','body','html','fax','mobile','lodash','../../mysqldb','../../config/logger','openchannel-interactions','mail-interactions','fax-interactions','chat-interactions','whatsapp-interactions','InteractionId','toLowerCase','[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','toUpperCase','name','role'];(function(_0x1c5661,_0x4a39e7){var _0x290047=function(_0x1bc0e6){while(--_0x1bc0e6){_0x1c5661['push'](_0x1c5661['shift']());}};_0x290047(++_0x4a39e7);}(_0x4d61,0x147));var _0x14d6=function(_0x284622,_0x1e419f){_0x284622=_0x284622-0x0;var _0x4d48d6=_0x4d61[_0x284622];return _0x4d48d6;};'use strict';var _=require(_0x14d6('0x0'));var db=require(_0x14d6('0x1'))['db'];var loggers={'openchannel':require(_0x14d6('0x2'))(_0x14d6('0x3')),'mail':require(_0x14d6('0x2'))(_0x14d6('0x4')),'fax':require(_0x14d6('0x2'))(_0x14d6('0x5')),'sms':require(_0x14d6('0x2'))('sms-interactions'),'chat':require(_0x14d6('0x2'))(_0x14d6('0x6')),'whatsapp':require(_0x14d6('0x2'))(_0x14d6('0x7'))};function getInteractionId(_0x349eac,_0x1b2daa,_0x344fb8){if(_0x349eac&&_0x349eac[_['upperFirst'](_0x344fb8)+_0x14d6('0x8')]){return _0x349eac[_['upperFirst'](_0x344fb8)+_0x14d6('0x8')];}else if(_0x349eac&&_0x349eac['id']){return _0x349eac['id'];}else if(_0x1b2daa&&_0x1b2daa['id']){return _0x1b2daa['id'];}else{return'unknown';}}function log(_0x25b8eb,_0x1cec66,_0x4ed3a6,_0x16db02,_0x11f087,_0x664c26){loggers[_0x11f087[_0x14d6('0x9')]()][_0x25b8eb](_0x14d6('0xa'),_0x664c26[_0x14d6('0xb')](),_0x1cec66?_0x1cec66['id']:null,_0x1cec66?_0x1cec66[_0x14d6('0xc')]:null,_0x1cec66?_0x1cec66[_0x14d6('0xd')]:null,getInteractionId(_0x4ed3a6,_0x16db02,_0x11f087),_0x4ed3a6?JSON[_0x14d6('0xe')](_0x4ed3a6):_0x14d6('0xf'));}function updateUser(_0x3b80b6,_0x51db48,_0x3047ee,_0x46ce98,_0x2ed01f){db[_[_0x14d6('0x10')](_0x46ce98)+_0x14d6('0x11')]['findOne']({'where':{'id':getInteractionId(_0x51db48,_0x3047ee,_0x46ce98)}})[_0x14d6('0x12')](function(_0x3b42d5){if(_0x3b42d5){return _0x3b42d5[_0x14d6('0x13')]({'UserId':_0x3b80b6?_0x3b80b6['id']:null});}})[_0x14d6('0x12')](function(_0x56182a){if(_0x56182a){log(_0x14d6('0x14'),_0x3b80b6,_0x51db48,_0x3047ee,_0x46ce98,_0x2ed01f);}})[_0x14d6('0x15')](function(){log(_0x14d6('0x16'),_0x3b80b6,_0x51db48,_0x3047ee,_0x46ce98,_0x2ed01f);});}exports['tracked']=function(_0x463487,_0x31cc63){return function(_0x3da4f5,_0x4654db,_0x10192d){var _0x2428d7=_0x3da4f5[_0x14d6('0x17')];var _0x315fc5={};var _0x1dd050=_0x3da4f5[_0x14d6('0x18')];if(_0x315fc5){_0x315fc5=_[_0x14d6('0x19')](_0x3da4f5['body']);_0x315fc5=_[_0x14d6('0x1a')](_0x315fc5,[_0x14d6('0x1b'),_0x14d6('0x1c'),'phone',_0x14d6('0x1d'),_0x14d6('0x1e')]);}updateUser(_0x2428d7,_0x315fc5,_0x1dd050,_0x463487,_0x31cc63);_0x10192d(null);};};