a8ae3e3ae9ac07ddc0dcd73105bf552ae4369f5b
[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 _0xd07b=['html','phone','fax','mobile','lodash','../../mysqldb','../../config/logger','openchannel-interactions','mail-interactions','fax-interactions','sms-interactions','chat-interactions','whatsapp-interactions','upperFirst','unknown','[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','name','null','Interaction','findOne','then','update','info','catch','error','tracked','user','query','clone','omit','body'];(function(_0x15a25a,_0x4c9336){var _0x5592cd=function(_0x1009b0){while(--_0x1009b0){_0x15a25a['push'](_0x15a25a['shift']());}};_0x5592cd(++_0x4c9336);}(_0xd07b,0xfc));var _0xbd07=function(_0x167cc1,_0x56ef5a){_0x167cc1=_0x167cc1-0x0;var _0x10bc4b=_0xd07b[_0x167cc1];return _0x10bc4b;};'use strict';var _=require(_0xbd07('0x0'));var db=require(_0xbd07('0x1'))['db'];var loggers={'openchannel':require(_0xbd07('0x2'))(_0xbd07('0x3')),'mail':require(_0xbd07('0x2'))(_0xbd07('0x4')),'fax':require('../../config/logger')(_0xbd07('0x5')),'sms':require('../../config/logger')(_0xbd07('0x6')),'chat':require(_0xbd07('0x2'))(_0xbd07('0x7')),'whatsapp':require(_0xbd07('0x2'))(_0xbd07('0x8'))};function getInteractionId(_0x1e8f9c,_0x244e61,_0x1de79b){if(_0x1e8f9c&&_0x1e8f9c[_['upperFirst'](_0x1de79b)+'InteractionId']){return _0x1e8f9c[_[_0xbd07('0x9')](_0x1de79b)+'InteractionId'];}else if(_0x1e8f9c&&_0x1e8f9c['id']){return _0x1e8f9c['id'];}else if(_0x244e61&&_0x244e61['id']){return _0x244e61['id'];}else{return _0xbd07('0xa');}}function log(_0x572247,_0x2e5a49,_0x4f7d5a,_0x4ce7d1,_0x3f685e,_0x2b3f90){loggers[_0x3f685e['toLowerCase']()][_0x572247](_0xbd07('0xb'),_0x2b3f90['toUpperCase'](),_0x2e5a49?_0x2e5a49['id']:null,_0x2e5a49?_0x2e5a49[_0xbd07('0xc')]:null,_0x2e5a49?_0x2e5a49['role']:null,getInteractionId(_0x4f7d5a,_0x4ce7d1,_0x3f685e),_0x4f7d5a?JSON['stringify'](_0x4f7d5a):_0xbd07('0xd'));}function updateUser(_0x2a593d,_0x34a9dd,_0xdbf7d0,_0x42ac1a,_0x31fa1c){db[_[_0xbd07('0x9')](_0x42ac1a)+_0xbd07('0xe')][_0xbd07('0xf')]({'where':{'id':getInteractionId(_0x34a9dd,_0xdbf7d0,_0x42ac1a)}})[_0xbd07('0x10')](function(_0x3f651f){if(_0x3f651f){return _0x3f651f[_0xbd07('0x11')]({'UserId':_0x2a593d?_0x2a593d['id']:null});}})[_0xbd07('0x10')](function(_0x331947){if(_0x331947){log(_0xbd07('0x12'),_0x2a593d,_0x34a9dd,_0xdbf7d0,_0x42ac1a,_0x31fa1c);}})[_0xbd07('0x13')](function(){log(_0xbd07('0x14'),_0x2a593d,_0x34a9dd,_0xdbf7d0,_0x42ac1a,_0x31fa1c);});}exports[_0xbd07('0x15')]=function(_0x5d942b,_0x1841cc){return function(_0x4e35bf,_0x5e40df,_0x26317a){var _0x275c17=_0x4e35bf[_0xbd07('0x16')];var _0x3c5739={};var _0x2b288c=_0x4e35bf[_0xbd07('0x17')];if(_0x3c5739){_0x3c5739=_[_0xbd07('0x18')](_0x4e35bf['body']);_0x3c5739=_[_0xbd07('0x19')](_0x3c5739,[_0xbd07('0x1a'),_0xbd07('0x1b'),_0xbd07('0x1c'),_0xbd07('0x1d'),_0xbd07('0x1e')]);}updateUser(_0x275c17,_0x3c5739,_0x2b288c,_0x5d942b,_0x1841cc);_0x26317a(null);};};