Built motion from commit 4e7c323b.|2.5.34
[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 _0x680f=['tracked','user','body','html','phone','mobile','lodash','openchannel-interactions','../../config/logger','mail-interactions','sms-interactions','whatsapp-interactions','upperFirst','InteractionId','toLowerCase','[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','toUpperCase','name','stringify','null','Interaction','findOne','then','update','catch','error'];(function(_0x6c993a,_0x5ea3ab){var _0x27f547=function(_0x22df20){while(--_0x22df20){_0x6c993a['push'](_0x6c993a['shift']());}};_0x27f547(++_0x5ea3ab);}(_0x680f,0x13e));var _0xf680=function(_0x26ca2f,_0x579f13){_0x26ca2f=_0x26ca2f-0x0;var _0x108f11=_0x680f[_0x26ca2f];return _0x108f11;};'use strict';var _=require(_0xf680('0x0'));var db=require('../../mysqldb')['db'];var loggers={'openchannel':require('../../config/logger')(_0xf680('0x1')),'mail':require(_0xf680('0x2'))(_0xf680('0x3')),'fax':require('../../config/logger')('fax-interactions'),'sms':require(_0xf680('0x2'))(_0xf680('0x4')),'chat':require(_0xf680('0x2'))('chat-interactions'),'whatsapp':require(_0xf680('0x2'))(_0xf680('0x5'))};function getInteractionId(_0x583bb2,_0x5b002d,_0x244a62){if(_0x583bb2&&_0x583bb2[_[_0xf680('0x6')](_0x244a62)+_0xf680('0x7')]){return _0x583bb2[_[_0xf680('0x6')](_0x244a62)+_0xf680('0x7')];}else if(_0x583bb2&&_0x583bb2['id']){return _0x583bb2['id'];}else if(_0x5b002d&&_0x5b002d['id']){return _0x5b002d['id'];}else{return'unknown';}}function log(_0x237fd6,_0x4d449a,_0x32e301,_0x2f71c1,_0xf226ae,_0x45ab3f){loggers[_0xf226ae[_0xf680('0x8')]()][_0x237fd6](_0xf680('0x9'),_0x45ab3f[_0xf680('0xa')](),_0x4d449a?_0x4d449a['id']:null,_0x4d449a?_0x4d449a[_0xf680('0xb')]:null,_0x4d449a?_0x4d449a['role']:null,getInteractionId(_0x32e301,_0x2f71c1,_0xf226ae),_0x32e301?JSON[_0xf680('0xc')](_0x32e301):_0xf680('0xd'));}function updateUser(_0x5deb77,_0x281a70,_0x158d33,_0x916382,_0xf0ef49){db[_[_0xf680('0x6')](_0x916382)+_0xf680('0xe')][_0xf680('0xf')]({'where':{'id':getInteractionId(_0x281a70,_0x158d33,_0x916382)}})[_0xf680('0x10')](function(_0x2a284e){if(_0x2a284e){return _0x2a284e[_0xf680('0x11')]({'UserId':_0x5deb77?_0x5deb77['id']:null});}})[_0xf680('0x10')](function(_0x368d55){if(_0x368d55){log('info',_0x5deb77,_0x281a70,_0x158d33,_0x916382,_0xf0ef49);}})[_0xf680('0x12')](function(){log(_0xf680('0x13'),_0x5deb77,_0x281a70,_0x158d33,_0x916382,_0xf0ef49);});}exports[_0xf680('0x14')]=function(_0x1e74fd,_0x26784f){return function(_0x1cc4b7,_0x5241a6,_0x411ec6){var _0x1f44d7=_0x1cc4b7[_0xf680('0x15')];var _0xd20706={};var _0xc700c1=_0x1cc4b7['query'];if(_0xd20706){_0xd20706=_['clone'](_0x1cc4b7[_0xf680('0x16')]);_0xd20706=_['omit'](_0xd20706,[_0xf680('0x16'),_0xf680('0x17'),_0xf680('0x18'),'fax',_0xf680('0x19')]);}updateUser(_0x1f44d7,_0xd20706,_0xc700c1,_0x1e74fd,_0x26784f);_0x411ec6(null);};};