Built motion from commit 616d3211.|2.6.4
[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 _0xc782=['catch','tracked','user','query','clone','body','omit','html','phone','fax','lodash','../../mysqldb','../../config/logger','openchannel-interactions','mail-interactions','sms-interactions','whatsapp-interactions','upperFirst','unknown','toLowerCase','name','role','stringify','null','Interaction','findOne','update','then'];(function(_0x20a584,_0xe384a5){var _0x4b41a8=function(_0x2127c6){while(--_0x2127c6){_0x20a584['push'](_0x20a584['shift']());}};_0x4b41a8(++_0xe384a5);}(_0xc782,0x192));var _0x2c78=function(_0x2a568e,_0x4788b1){_0x2a568e=_0x2a568e-0x0;var _0xe1df87=_0xc782[_0x2a568e];return _0xe1df87;};'use strict';var _=require(_0x2c78('0x0'));var db=require(_0x2c78('0x1'))['db'];var loggers={'openchannel':require(_0x2c78('0x2'))(_0x2c78('0x3')),'mail':require('../../config/logger')(_0x2c78('0x4')),'fax':require(_0x2c78('0x2'))('fax-interactions'),'sms':require(_0x2c78('0x2'))(_0x2c78('0x5')),'chat':require('../../config/logger')('chat-interactions'),'whatsapp':require(_0x2c78('0x2'))(_0x2c78('0x6'))};function getInteractionId(_0x1e0dda,_0x596ac3,_0x17b28d){if(_0x1e0dda&&_0x1e0dda[_[_0x2c78('0x7')](_0x17b28d)+'InteractionId']){return _0x1e0dda[_[_0x2c78('0x7')](_0x17b28d)+'InteractionId'];}else if(_0x1e0dda&&_0x1e0dda['id']){return _0x1e0dda['id'];}else if(_0x596ac3&&_0x596ac3['id']){return _0x596ac3['id'];}else{return _0x2c78('0x8');}}function log(_0x24471a,_0x16129a,_0x5e2c21,_0x6e703d,_0x3dda32,_0x1eff3e){loggers[_0x3dda32[_0x2c78('0x9')]()][_0x24471a]('[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x1eff3e['toUpperCase'](),_0x16129a?_0x16129a['id']:null,_0x16129a?_0x16129a[_0x2c78('0xa')]:null,_0x16129a?_0x16129a[_0x2c78('0xb')]:null,getInteractionId(_0x5e2c21,_0x6e703d,_0x3dda32),_0x5e2c21?JSON[_0x2c78('0xc')](_0x5e2c21):_0x2c78('0xd'));}function updateUser(_0x44e0aa,_0xddc170,_0x546800,_0x2831c2,_0x839d3d){db[_['upperFirst'](_0x2831c2)+_0x2c78('0xe')][_0x2c78('0xf')]({'where':{'id':getInteractionId(_0xddc170,_0x546800,_0x2831c2)}})['then'](function(_0x33428f){if(_0x33428f){return _0x33428f[_0x2c78('0x10')]({'UserId':_0x44e0aa?_0x44e0aa['id']:null});}})[_0x2c78('0x11')](function(_0x464668){if(_0x464668){log('info',_0x44e0aa,_0xddc170,_0x546800,_0x2831c2,_0x839d3d);}})[_0x2c78('0x12')](function(){log('error',_0x44e0aa,_0xddc170,_0x546800,_0x2831c2,_0x839d3d);});}exports[_0x2c78('0x13')]=function(_0x221e1a,_0x2c7114){return function(_0x3fea8a,_0x25868a,_0x2146d8){var _0x5b72c2=_0x3fea8a[_0x2c78('0x14')];var _0x5b5ecf={};var _0x52afd1=_0x3fea8a[_0x2c78('0x15')];if(_0x5b5ecf){_0x5b5ecf=_[_0x2c78('0x16')](_0x3fea8a[_0x2c78('0x17')]);_0x5b5ecf=_[_0x2c78('0x18')](_0x5b5ecf,['body',_0x2c78('0x19'),_0x2c78('0x1a'),_0x2c78('0x1b'),'mobile']);}updateUser(_0x5b72c2,_0x5b5ecf,_0x52afd1,_0x221e1a,_0x2c7114);_0x2146d8(null);};};