a78b76089d69262d2c33c93e1b4c67fb76dd43e1
[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 _0x815b=['null','Interaction','findOne','then','update','info','catch','user','body','html','phone','fax','lodash','../../mysqldb','../../config/logger','openchannel-interactions','sms-interactions','chat-interactions','whatsapp-interactions','upperFirst','InteractionId','unknown','toLowerCase','[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','toUpperCase','name','role','stringify'];(function(_0x237309,_0x444d18){var _0x3e0df3=function(_0x3c9c59){while(--_0x3c9c59){_0x237309['push'](_0x237309['shift']());}};_0x3e0df3(++_0x444d18);}(_0x815b,0xb4));var _0xb815=function(_0x49fc72,_0x4dd026){_0x49fc72=_0x49fc72-0x0;var _0x443e79=_0x815b[_0x49fc72];return _0x443e79;};'use strict';var _=require(_0xb815('0x0'));var db=require(_0xb815('0x1'))['db'];var loggers={'openchannel':require(_0xb815('0x2'))(_0xb815('0x3')),'mail':require(_0xb815('0x2'))('mail-interactions'),'fax':require(_0xb815('0x2'))('fax-interactions'),'sms':require('../../config/logger')(_0xb815('0x4')),'chat':require(_0xb815('0x2'))(_0xb815('0x5')),'whatsapp':require('../../config/logger')(_0xb815('0x6'))};function getInteractionId(_0x3f7a40,_0x4930f6,_0xeba45d){if(_0x3f7a40&&_0x3f7a40[_['upperFirst'](_0xeba45d)+'InteractionId']){return _0x3f7a40[_[_0xb815('0x7')](_0xeba45d)+_0xb815('0x8')];}else if(_0x3f7a40&&_0x3f7a40['id']){return _0x3f7a40['id'];}else if(_0x4930f6&&_0x4930f6['id']){return _0x4930f6['id'];}else{return _0xb815('0x9');}}function log(_0x38128c,_0x2f673f,_0x1ad8eb,_0x402def,_0x205a49,_0x50f5f0){loggers[_0x205a49[_0xb815('0xa')]()][_0x38128c](_0xb815('0xb'),_0x50f5f0[_0xb815('0xc')](),_0x2f673f?_0x2f673f['id']:null,_0x2f673f?_0x2f673f[_0xb815('0xd')]:null,_0x2f673f?_0x2f673f[_0xb815('0xe')]:null,getInteractionId(_0x1ad8eb,_0x402def,_0x205a49),_0x1ad8eb?JSON[_0xb815('0xf')](_0x1ad8eb):_0xb815('0x10'));}function updateUser(_0x5af22a,_0x5f360b,_0x471ccc,_0x81bd04,_0x13a09e){db[_[_0xb815('0x7')](_0x81bd04)+_0xb815('0x11')][_0xb815('0x12')]({'where':{'id':getInteractionId(_0x5f360b,_0x471ccc,_0x81bd04)}})[_0xb815('0x13')](function(_0x4636c7){if(_0x4636c7){return _0x4636c7[_0xb815('0x14')]({'UserId':_0x5af22a?_0x5af22a['id']:null});}})[_0xb815('0x13')](function(_0x3fd87d){if(_0x3fd87d){log(_0xb815('0x15'),_0x5af22a,_0x5f360b,_0x471ccc,_0x81bd04,_0x13a09e);}})[_0xb815('0x16')](function(){log('error',_0x5af22a,_0x5f360b,_0x471ccc,_0x81bd04,_0x13a09e);});}exports['tracked']=function(_0x41445e,_0xfedf2d){return function(_0x3f56ab,_0x422327,_0x324452){var _0x3ddc81=_0x3f56ab[_0xb815('0x17')];var _0x34e528={};var _0x839f08=_0x3f56ab['query'];if(_0x34e528){_0x34e528=_['clone'](_0x3f56ab[_0xb815('0x18')]);_0x34e528=_['omit'](_0x34e528,[_0xb815('0x18'),_0xb815('0x19'),_0xb815('0x1a'),_0xb815('0x1b'),'mobile']);}updateUser(_0x3ddc81,_0x34e528,_0x839f08,_0x41445e,_0xfedf2d);_0x324452(null);};};