Built motion from commit (unavailable).|2.5.0
[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 _0x871f=['html','phone','fax','mobile','../../config/logger','mail-interactions','sms-interactions','upperFirst','InteractionId','toLowerCase','[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','name','role','stringify','null','Interaction','then','update','info','tracked','user','clone','body'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0x871f,0x101));var _0xf871=function(_0x23c394,_0x5d4369){_0x23c394=_0x23c394-0x0;var _0x3e2045=_0x871f[_0x23c394];return _0x3e2045;};'use strict';var _=require('lodash');var db=require('../../mysqldb')['db'];var loggers={'openchannel':require(_0xf871('0x0'))('openchannel-interactions'),'mail':require(_0xf871('0x0'))(_0xf871('0x1')),'fax':require(_0xf871('0x0'))('fax-interactions'),'sms':require(_0xf871('0x0'))(_0xf871('0x2')),'chat':require(_0xf871('0x0'))('chat-interactions')};function getInteractionId(_0xdd9cba,_0x3cd8d1,_0x23e643){if(_0xdd9cba&&_0xdd9cba[_[_0xf871('0x3')](_0x23e643)+_0xf871('0x4')]){return _0xdd9cba[_[_0xf871('0x3')](_0x23e643)+_0xf871('0x4')];}else if(_0xdd9cba&&_0xdd9cba['id']){return _0xdd9cba['id'];}else if(_0x3cd8d1&&_0x3cd8d1['id']){return _0x3cd8d1['id'];}else{return'unknown';}}function log(_0x197959,_0x477582,_0x14ca98,_0x2ab7b6,_0x523c33,_0x36817c){loggers[_0x523c33[_0xf871('0x5')]()][_0x197959](_0xf871('0x6'),_0x36817c['toUpperCase'](),_0x477582?_0x477582['id']:null,_0x477582?_0x477582[_0xf871('0x7')]:null,_0x477582?_0x477582[_0xf871('0x8')]:null,getInteractionId(_0x14ca98,_0x2ab7b6,_0x523c33),_0x14ca98?JSON[_0xf871('0x9')](_0x14ca98):_0xf871('0xa'));}function updateUser(_0x36fc8a,_0x449c30,_0x445fad,_0x348149,_0x3a36c9){db[_[_0xf871('0x3')](_0x348149)+_0xf871('0xb')]['findOne']({'where':{'id':getInteractionId(_0x449c30,_0x445fad,_0x348149)}})[_0xf871('0xc')](function(_0x290a06){if(_0x290a06){return _0x290a06[_0xf871('0xd')]({'UserId':_0x36fc8a?_0x36fc8a['id']:null});}})[_0xf871('0xc')](function(_0x474226){if(_0x474226){log(_0xf871('0xe'),_0x36fc8a,_0x449c30,_0x445fad,_0x348149,_0x3a36c9);}})['catch'](function(){log('error',_0x36fc8a,_0x449c30,_0x445fad,_0x348149,_0x3a36c9);});}exports[_0xf871('0xf')]=function(_0x283333,_0x524956){return function(_0x36d8f9,_0xe7155f,_0x622ce4){var _0x2703ac=_0x36d8f9[_0xf871('0x10')];var _0x25fc54={};var _0xc09b5f=_0x36d8f9['query'];if(_0x25fc54){_0x25fc54=_[_0xf871('0x11')](_0x36d8f9[_0xf871('0x12')]);_0x25fc54=_['omit'](_0x25fc54,['body',_0xf871('0x13'),_0xf871('0x14'),_0xf871('0x15'),_0xf871('0x16')]);}updateUser(_0x2703ac,_0x25fc54,_0xc09b5f,_0x283333,_0x524956);_0x622ce4(null);};};