ff68c0b19139180032bf72210a9a6ca33698af65
[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 _0x1f10=['body','omit','html','phone','fax','mobile','lodash','../../mysqldb','openchannel-interactions','../../config/logger','fax-interactions','sms-interactions','chat-interactions','whatsapp-interactions','upperFirst','InteractionId','toLowerCase','[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','toUpperCase','name','role','stringify','null','Interaction','then','update','info','catch','error','tracked','user','query','clone'];(function(_0x16d369,_0xbbaa52){var _0x53c1ca=function(_0x49908d){while(--_0x49908d){_0x16d369['push'](_0x16d369['shift']());}};_0x53c1ca(++_0xbbaa52);}(_0x1f10,0x69));var _0x01f1=function(_0x3d3ffc,_0x39cc32){_0x3d3ffc=_0x3d3ffc-0x0;var _0x5b2bb1=_0x1f10[_0x3d3ffc];return _0x5b2bb1;};'use strict';var _=require(_0x01f1('0x0'));var db=require(_0x01f1('0x1'))['db'];var loggers={'openchannel':require('../../config/logger')(_0x01f1('0x2')),'mail':require(_0x01f1('0x3'))('mail-interactions'),'fax':require('../../config/logger')(_0x01f1('0x4')),'sms':require('../../config/logger')(_0x01f1('0x5')),'chat':require(_0x01f1('0x3'))(_0x01f1('0x6')),'whatsapp':require('../../config/logger')(_0x01f1('0x7'))};function getInteractionId(_0x35b9d4,_0x33e3d5,_0x17f4d1){if(_0x35b9d4&&_0x35b9d4[_[_0x01f1('0x8')](_0x17f4d1)+_0x01f1('0x9')]){return _0x35b9d4[_[_0x01f1('0x8')](_0x17f4d1)+_0x01f1('0x9')];}else if(_0x35b9d4&&_0x35b9d4['id']){return _0x35b9d4['id'];}else if(_0x33e3d5&&_0x33e3d5['id']){return _0x33e3d5['id'];}else{return'unknown';}}function log(_0x120bd1,_0x413939,_0x46dd46,_0x38c644,_0x4fee68,_0x4a510b){loggers[_0x4fee68[_0x01f1('0xa')]()][_0x120bd1](_0x01f1('0xb'),_0x4a510b[_0x01f1('0xc')](),_0x413939?_0x413939['id']:null,_0x413939?_0x413939[_0x01f1('0xd')]:null,_0x413939?_0x413939[_0x01f1('0xe')]:null,getInteractionId(_0x46dd46,_0x38c644,_0x4fee68),_0x46dd46?JSON[_0x01f1('0xf')](_0x46dd46):_0x01f1('0x10'));}function updateUser(_0x28b3d0,_0x486b89,_0x42373f,_0xecd06d,_0x177e69){db[_[_0x01f1('0x8')](_0xecd06d)+_0x01f1('0x11')]['findOne']({'where':{'id':getInteractionId(_0x486b89,_0x42373f,_0xecd06d)}})[_0x01f1('0x12')](function(_0x51116e){if(_0x51116e){return _0x51116e[_0x01f1('0x13')]({'UserId':_0x28b3d0?_0x28b3d0['id']:null});}})[_0x01f1('0x12')](function(_0xa7c876){if(_0xa7c876){log(_0x01f1('0x14'),_0x28b3d0,_0x486b89,_0x42373f,_0xecd06d,_0x177e69);}})[_0x01f1('0x15')](function(){log(_0x01f1('0x16'),_0x28b3d0,_0x486b89,_0x42373f,_0xecd06d,_0x177e69);});}exports[_0x01f1('0x17')]=function(_0x29d37d,_0x3e6612){return function(_0x2ea799,_0x1465c2,_0x3b0e2e){var _0x234024=_0x2ea799[_0x01f1('0x18')];var _0x57a5c1={};var _0xb1cbdc=_0x2ea799[_0x01f1('0x19')];if(_0x57a5c1){_0x57a5c1=_[_0x01f1('0x1a')](_0x2ea799[_0x01f1('0x1b')]);_0x57a5c1=_[_0x01f1('0x1c')](_0x57a5c1,['body',_0x01f1('0x1d'),_0x01f1('0x1e'),_0x01f1('0x1f'),_0x01f1('0x20')]);}updateUser(_0x234024,_0x57a5c1,_0xb1cbdc,_0x29d37d,_0x3e6612);_0x3b0e2e(null);};};