0af562ff17d0ee101418b00cde8ca0835aeb88a4
[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 _0xe599=['update','catch','user','query','clone','omit','body','fax','mobile','lodash','../../mysqldb','../../config/logger','openchannel-interactions','mail-interactions','fax-interactions','chat-interactions','whatsapp-interactions','InteractionId','upperFirst','unknown','toLowerCase','[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','toUpperCase','role','stringify','Interaction','findOne','then'];(function(_0x1e381c,_0x47b5b9){var _0x9b5ea9=function(_0x6d2be5){while(--_0x6d2be5){_0x1e381c['push'](_0x1e381c['shift']());}};_0x9b5ea9(++_0x47b5b9);}(_0xe599,0x1e5));var _0x9e59=function(_0xcb492c,_0xff9d1a){_0xcb492c=_0xcb492c-0x0;var _0x3c9c73=_0xe599[_0xcb492c];return _0x3c9c73;};'use strict';var _=require(_0x9e59('0x0'));var db=require(_0x9e59('0x1'))['db'];var loggers={'openchannel':require(_0x9e59('0x2'))(_0x9e59('0x3')),'mail':require(_0x9e59('0x2'))(_0x9e59('0x4')),'fax':require(_0x9e59('0x2'))(_0x9e59('0x5')),'sms':require(_0x9e59('0x2'))('sms-interactions'),'chat':require(_0x9e59('0x2'))(_0x9e59('0x6')),'whatsapp':require('../../config/logger')(_0x9e59('0x7'))};function getInteractionId(_0x599400,_0x290f63,_0x21c5a9){if(_0x599400&&_0x599400[_['upperFirst'](_0x21c5a9)+_0x9e59('0x8')]){return _0x599400[_[_0x9e59('0x9')](_0x21c5a9)+_0x9e59('0x8')];}else if(_0x599400&&_0x599400['id']){return _0x599400['id'];}else if(_0x290f63&&_0x290f63['id']){return _0x290f63['id'];}else{return _0x9e59('0xa');}}function log(_0x64d093,_0x14a5d7,_0x578fdc,_0x312bc6,_0x5ba142,_0x366941){loggers[_0x5ba142[_0x9e59('0xb')]()][_0x64d093](_0x9e59('0xc'),_0x366941[_0x9e59('0xd')](),_0x14a5d7?_0x14a5d7['id']:null,_0x14a5d7?_0x14a5d7['name']:null,_0x14a5d7?_0x14a5d7[_0x9e59('0xe')]:null,getInteractionId(_0x578fdc,_0x312bc6,_0x5ba142),_0x578fdc?JSON[_0x9e59('0xf')](_0x578fdc):'null');}function updateUser(_0x39407d,_0xdea888,_0x27bf9b,_0x257a39,_0x4eae1e){db[_[_0x9e59('0x9')](_0x257a39)+_0x9e59('0x10')][_0x9e59('0x11')]({'where':{'id':getInteractionId(_0xdea888,_0x27bf9b,_0x257a39)}})[_0x9e59('0x12')](function(_0x1ec55a){if(_0x1ec55a){return _0x1ec55a[_0x9e59('0x13')]({'UserId':_0x39407d?_0x39407d['id']:null});}})[_0x9e59('0x12')](function(_0x82dffd){if(_0x82dffd){log('info',_0x39407d,_0xdea888,_0x27bf9b,_0x257a39,_0x4eae1e);}})[_0x9e59('0x14')](function(){log('error',_0x39407d,_0xdea888,_0x27bf9b,_0x257a39,_0x4eae1e);});}exports['tracked']=function(_0x5eb34e,_0x29dc13){return function(_0x470f7a,_0x51e05b,_0x224bc7){var _0x3e6c34=_0x470f7a[_0x9e59('0x15')];var _0xd789aa={};var _0x2fcfa6=_0x470f7a[_0x9e59('0x16')];if(_0xd789aa){_0xd789aa=_[_0x9e59('0x17')](_0x470f7a['body']);_0xd789aa=_[_0x9e59('0x18')](_0xd789aa,[_0x9e59('0x19'),'html','phone',_0x9e59('0x1a'),_0x9e59('0x1b')]);}updateUser(_0x3e6c34,_0xd789aa,_0x2fcfa6,_0x5eb34e,_0x29dc13);_0x224bc7(null);};};