Built motion from commit (unavailable).|2.5.1
[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 _0xe4a5=['sms-interactions','chat-interactions','whatsapp-interactions','upperFirst','InteractionId','toLowerCase','[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','toUpperCase','role','stringify','null','Interaction','findOne','then','update','info','catch','error','tracked','user','query','body','omit','html','lodash','../../mysqldb','../../config/logger','openchannel-interactions','mail-interactions','fax-interactions'];(function(_0x4ee192,_0x1e8f15){var _0xe9538d=function(_0x1f8ac5){while(--_0x1f8ac5){_0x4ee192['push'](_0x4ee192['shift']());}};_0xe9538d(++_0x1e8f15);}(_0xe4a5,0xea));var _0x5e4a=function(_0x42868d,_0x165917){_0x42868d=_0x42868d-0x0;var _0xd29bb1=_0xe4a5[_0x42868d];return _0xd29bb1;};'use strict';var _=require(_0x5e4a('0x0'));var db=require(_0x5e4a('0x1'))['db'];var loggers={'openchannel':require(_0x5e4a('0x2'))(_0x5e4a('0x3')),'mail':require(_0x5e4a('0x2'))(_0x5e4a('0x4')),'fax':require('../../config/logger')(_0x5e4a('0x5')),'sms':require(_0x5e4a('0x2'))(_0x5e4a('0x6')),'chat':require(_0x5e4a('0x2'))(_0x5e4a('0x7')),'whatsapp':require(_0x5e4a('0x2'))(_0x5e4a('0x8'))};function getInteractionId(_0x54264e,_0x1f84ca,_0x18d8ee){if(_0x54264e&&_0x54264e[_[_0x5e4a('0x9')](_0x18d8ee)+'InteractionId']){return _0x54264e[_[_0x5e4a('0x9')](_0x18d8ee)+_0x5e4a('0xa')];}else if(_0x54264e&&_0x54264e['id']){return _0x54264e['id'];}else if(_0x1f84ca&&_0x1f84ca['id']){return _0x1f84ca['id'];}else{return'unknown';}}function log(_0x6eb81f,_0x559e4c,_0x10239a,_0x176af2,_0x3c4ef7,_0x3c7b39){loggers[_0x3c4ef7[_0x5e4a('0xb')]()][_0x6eb81f](_0x5e4a('0xc'),_0x3c7b39[_0x5e4a('0xd')](),_0x559e4c?_0x559e4c['id']:null,_0x559e4c?_0x559e4c['name']:null,_0x559e4c?_0x559e4c[_0x5e4a('0xe')]:null,getInteractionId(_0x10239a,_0x176af2,_0x3c4ef7),_0x10239a?JSON[_0x5e4a('0xf')](_0x10239a):_0x5e4a('0x10'));}function updateUser(_0x33ce58,_0x38711f,_0x302d62,_0x25ebdd,_0x5575a3){db[_['upperFirst'](_0x25ebdd)+_0x5e4a('0x11')][_0x5e4a('0x12')]({'where':{'id':getInteractionId(_0x38711f,_0x302d62,_0x25ebdd)}})[_0x5e4a('0x13')](function(_0x297dd1){if(_0x297dd1){return _0x297dd1[_0x5e4a('0x14')]({'UserId':_0x33ce58?_0x33ce58['id']:null});}})[_0x5e4a('0x13')](function(_0x146e69){if(_0x146e69){log(_0x5e4a('0x15'),_0x33ce58,_0x38711f,_0x302d62,_0x25ebdd,_0x5575a3);}})[_0x5e4a('0x16')](function(){log(_0x5e4a('0x17'),_0x33ce58,_0x38711f,_0x302d62,_0x25ebdd,_0x5575a3);});}exports[_0x5e4a('0x18')]=function(_0x2145f0,_0x2cd88c){return function(_0x3e8160,_0x4c8a9d,_0x549371){var _0x426061=_0x3e8160[_0x5e4a('0x19')];var _0x432fd0={};var _0x552178=_0x3e8160[_0x5e4a('0x1a')];if(_0x432fd0){_0x432fd0=_['clone'](_0x3e8160[_0x5e4a('0x1b')]);_0x432fd0=_[_0x5e4a('0x1c')](_0x432fd0,[_0x5e4a('0x1b'),_0x5e4a('0x1d'),'phone','fax','mobile']);}updateUser(_0x426061,_0x432fd0,_0x552178,_0x2145f0,_0x2cd88c);_0x549371(null);};};