Built motion from commit (unavailable).|2.6.0
[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 _0xf0db=['info','catch','error','tracked','user','query','body','omit','html','fax','mobile','lodash','../../mysqldb','openchannel-interactions','../../config/logger','mail-interactions','fax-interactions','chat-interactions','whatsapp-interactions','upperFirst','InteractionId','unknown','toLowerCase','[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','toUpperCase','name','role','stringify','Interaction','findOne','then','update'];(function(_0x17d9e3,_0x1f969c){var _0x14192d=function(_0x159745){while(--_0x159745){_0x17d9e3['push'](_0x17d9e3['shift']());}};_0x14192d(++_0x1f969c);}(_0xf0db,0x12b));var _0xbf0d=function(_0x6e2020,_0x5f3b6a){_0x6e2020=_0x6e2020-0x0;var _0x475ca5=_0xf0db[_0x6e2020];return _0x475ca5;};'use strict';var _=require(_0xbf0d('0x0'));var db=require(_0xbf0d('0x1'))['db'];var loggers={'openchannel':require('../../config/logger')(_0xbf0d('0x2')),'mail':require(_0xbf0d('0x3'))(_0xbf0d('0x4')),'fax':require('../../config/logger')(_0xbf0d('0x5')),'sms':require(_0xbf0d('0x3'))('sms-interactions'),'chat':require('../../config/logger')(_0xbf0d('0x6')),'whatsapp':require(_0xbf0d('0x3'))(_0xbf0d('0x7'))};function getInteractionId(_0x2dc074,_0x49d4f2,_0x1ebf0c){if(_0x2dc074&&_0x2dc074[_[_0xbf0d('0x8')](_0x1ebf0c)+_0xbf0d('0x9')]){return _0x2dc074[_[_0xbf0d('0x8')](_0x1ebf0c)+_0xbf0d('0x9')];}else if(_0x2dc074&&_0x2dc074['id']){return _0x2dc074['id'];}else if(_0x49d4f2&&_0x49d4f2['id']){return _0x49d4f2['id'];}else{return _0xbf0d('0xa');}}function log(_0x154401,_0xb7715f,_0x55cb8f,_0x5a28a3,_0x170113,_0x54f700){loggers[_0x170113[_0xbf0d('0xb')]()][_0x154401](_0xbf0d('0xc'),_0x54f700[_0xbf0d('0xd')](),_0xb7715f?_0xb7715f['id']:null,_0xb7715f?_0xb7715f[_0xbf0d('0xe')]:null,_0xb7715f?_0xb7715f[_0xbf0d('0xf')]:null,getInteractionId(_0x55cb8f,_0x5a28a3,_0x170113),_0x55cb8f?JSON[_0xbf0d('0x10')](_0x55cb8f):'null');}function updateUser(_0x22056f,_0x944006,_0x524565,_0xa968b9,_0x1ffb38){db[_[_0xbf0d('0x8')](_0xa968b9)+_0xbf0d('0x11')][_0xbf0d('0x12')]({'where':{'id':getInteractionId(_0x944006,_0x524565,_0xa968b9)}})[_0xbf0d('0x13')](function(_0xce31f1){if(_0xce31f1){return _0xce31f1[_0xbf0d('0x14')]({'UserId':_0x22056f?_0x22056f['id']:null});}})[_0xbf0d('0x13')](function(_0x21330d){if(_0x21330d){log(_0xbf0d('0x15'),_0x22056f,_0x944006,_0x524565,_0xa968b9,_0x1ffb38);}})[_0xbf0d('0x16')](function(){log(_0xbf0d('0x17'),_0x22056f,_0x944006,_0x524565,_0xa968b9,_0x1ffb38);});}exports[_0xbf0d('0x18')]=function(_0x523802,_0x11a5f1){return function(_0xb2ec78,_0x1ba1f2,_0xc051ec){var _0x31970b=_0xb2ec78[_0xbf0d('0x19')];var _0x288ceb={};var _0x4cb1aa=_0xb2ec78[_0xbf0d('0x1a')];if(_0x288ceb){_0x288ceb=_['clone'](_0xb2ec78[_0xbf0d('0x1b')]);_0x288ceb=_[_0xbf0d('0x1c')](_0x288ceb,[_0xbf0d('0x1b'),_0xbf0d('0x1d'),'phone',_0xbf0d('0x1e'),_0xbf0d('0x1f')]);}updateUser(_0x31970b,_0x288ceb,_0x4cb1aa,_0x523802,_0x11a5f1);_0xc051ec(null);};};