Built motion from commit (unavailable).|2.5.5
[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 _0x43f3=['upperFirst','InteractionId','unknown','toLowerCase','[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','toUpperCase','role','Interaction','then','update','error','tracked','user','query','clone','body','omit','html','phone','fax','mobile','../../mysqldb','../../config/logger','sms-interactions','whatsapp-interactions'];(function(_0x1d5025,_0x4e8f97){var _0x2a3c16=function(_0xcbd95a){while(--_0xcbd95a){_0x1d5025['push'](_0x1d5025['shift']());}};_0x2a3c16(++_0x4e8f97);}(_0x43f3,0xab));var _0x343f=function(_0x566bdf,_0x1f4861){_0x566bdf=_0x566bdf-0x0;var _0x331215=_0x43f3[_0x566bdf];return _0x331215;};'use strict';var _=require('lodash');var db=require(_0x343f('0x0'))['db'];var loggers={'openchannel':require(_0x343f('0x1'))('openchannel-interactions'),'mail':require(_0x343f('0x1'))('mail-interactions'),'fax':require(_0x343f('0x1'))('fax-interactions'),'sms':require(_0x343f('0x1'))(_0x343f('0x2')),'chat':require(_0x343f('0x1'))('chat-interactions'),'whatsapp':require(_0x343f('0x1'))(_0x343f('0x3'))};function getInteractionId(_0x28d670,_0x1ba815,_0x288ae7){if(_0x28d670&&_0x28d670[_[_0x343f('0x4')](_0x288ae7)+_0x343f('0x5')]){return _0x28d670[_[_0x343f('0x4')](_0x288ae7)+_0x343f('0x5')];}else if(_0x28d670&&_0x28d670['id']){return _0x28d670['id'];}else if(_0x1ba815&&_0x1ba815['id']){return _0x1ba815['id'];}else{return _0x343f('0x6');}}function log(_0xf15a4d,_0x37e416,_0x1377de,_0x37c0b8,_0x16e683,_0x194230){loggers[_0x16e683[_0x343f('0x7')]()][_0xf15a4d](_0x343f('0x8'),_0x194230[_0x343f('0x9')](),_0x37e416?_0x37e416['id']:null,_0x37e416?_0x37e416['name']:null,_0x37e416?_0x37e416[_0x343f('0xa')]:null,getInteractionId(_0x1377de,_0x37c0b8,_0x16e683),_0x1377de?JSON['stringify'](_0x1377de):'null');}function updateUser(_0xa3f54,_0x1923ee,_0x5e965e,_0x4cea1f,_0x3dbbd3){db[_['upperFirst'](_0x4cea1f)+_0x343f('0xb')]['findOne']({'where':{'id':getInteractionId(_0x1923ee,_0x5e965e,_0x4cea1f)}})[_0x343f('0xc')](function(_0x950400){if(_0x950400){return _0x950400[_0x343f('0xd')]({'UserId':_0xa3f54?_0xa3f54['id']:null});}})[_0x343f('0xc')](function(_0x189d1b){if(_0x189d1b){log('info',_0xa3f54,_0x1923ee,_0x5e965e,_0x4cea1f,_0x3dbbd3);}})['catch'](function(){log(_0x343f('0xe'),_0xa3f54,_0x1923ee,_0x5e965e,_0x4cea1f,_0x3dbbd3);});}exports[_0x343f('0xf')]=function(_0x199774,_0x1fc4c9){return function(_0x3dd83a,_0x20a66c,_0x47a6e1){var _0xe84685=_0x3dd83a[_0x343f('0x10')];var _0x1103da={};var _0x1637d9=_0x3dd83a[_0x343f('0x11')];if(_0x1103da){_0x1103da=_[_0x343f('0x12')](_0x3dd83a[_0x343f('0x13')]);_0x1103da=_[_0x343f('0x14')](_0x1103da,[_0x343f('0x13'),_0x343f('0x15'),_0x343f('0x16'),_0x343f('0x17'),_0x343f('0x18')]);}updateUser(_0xe84685,_0x1103da,_0x1637d9,_0x199774,_0x1fc4c9);_0x47a6e1(null);};};