Built motion from commit (unavailable).|2.5.22
[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 _0xb3c2=['../../config/logger','mail-interactions','sms-interactions','chat-interactions','upperFirst','InteractionId','unknown','toLowerCase','[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','toUpperCase','name','role','stringify','Interaction','findOne','update','then','catch','error','tracked','user','query','clone','omit','body','html','fax','mobile','lodash','../../mysqldb','openchannel-interactions'];(function(_0x4f84c3,_0x6d094d){var _0x460f9f=function(_0x5af5bd){while(--_0x5af5bd){_0x4f84c3['push'](_0x4f84c3['shift']());}};_0x460f9f(++_0x6d094d);}(_0xb3c2,0x152));var _0x2b3c=function(_0x20a584,_0xe384a5){_0x20a584=_0x20a584-0x0;var _0x4b41a8=_0xb3c2[_0x20a584];return _0x4b41a8;};'use strict';var _=require(_0x2b3c('0x0'));var db=require(_0x2b3c('0x1'))['db'];var loggers={'openchannel':require('../../config/logger')(_0x2b3c('0x2')),'mail':require(_0x2b3c('0x3'))(_0x2b3c('0x4')),'fax':require(_0x2b3c('0x3'))('fax-interactions'),'sms':require(_0x2b3c('0x3'))(_0x2b3c('0x5')),'chat':require(_0x2b3c('0x3'))(_0x2b3c('0x6')),'whatsapp':require(_0x2b3c('0x3'))('whatsapp-interactions')};function getInteractionId(_0xb477eb,_0x44266d,_0x2362a9){if(_0xb477eb&&_0xb477eb[_[_0x2b3c('0x7')](_0x2362a9)+'InteractionId']){return _0xb477eb[_['upperFirst'](_0x2362a9)+_0x2b3c('0x8')];}else if(_0xb477eb&&_0xb477eb['id']){return _0xb477eb['id'];}else if(_0x44266d&&_0x44266d['id']){return _0x44266d['id'];}else{return _0x2b3c('0x9');}}function log(_0x3fea73,_0x535546,_0x149a3a,_0x1a8e9d,_0x32209a,_0x2465e2){loggers[_0x32209a[_0x2b3c('0xa')]()][_0x3fea73](_0x2b3c('0xb'),_0x2465e2[_0x2b3c('0xc')](),_0x535546?_0x535546['id']:null,_0x535546?_0x535546[_0x2b3c('0xd')]:null,_0x535546?_0x535546[_0x2b3c('0xe')]:null,getInteractionId(_0x149a3a,_0x1a8e9d,_0x32209a),_0x149a3a?JSON[_0x2b3c('0xf')](_0x149a3a):'null');}function updateUser(_0x194c22,_0x5b5518,_0x37fce5,_0x3604f2,_0x539c4a){db[_[_0x2b3c('0x7')](_0x3604f2)+_0x2b3c('0x10')][_0x2b3c('0x11')]({'where':{'id':getInteractionId(_0x5b5518,_0x37fce5,_0x3604f2)}})['then'](function(_0x3238a9){if(_0x3238a9){return _0x3238a9[_0x2b3c('0x12')]({'UserId':_0x194c22?_0x194c22['id']:null});}})[_0x2b3c('0x13')](function(_0x392c19){if(_0x392c19){log('info',_0x194c22,_0x5b5518,_0x37fce5,_0x3604f2,_0x539c4a);}})[_0x2b3c('0x14')](function(){log(_0x2b3c('0x15'),_0x194c22,_0x5b5518,_0x37fce5,_0x3604f2,_0x539c4a);});}exports[_0x2b3c('0x16')]=function(_0x38b053,_0x149d59){return function(_0x696908,_0x2b1703,_0x18864c){var _0x433ce6=_0x696908[_0x2b3c('0x17')];var _0x5ad3d9={};var _0x14fb01=_0x696908[_0x2b3c('0x18')];if(_0x5ad3d9){_0x5ad3d9=_[_0x2b3c('0x19')](_0x696908['body']);_0x5ad3d9=_[_0x2b3c('0x1a')](_0x5ad3d9,[_0x2b3c('0x1b'),_0x2b3c('0x1c'),'phone',_0x2b3c('0x1d'),_0x2b3c('0x1e')]);}updateUser(_0x433ce6,_0x5ad3d9,_0x14fb01,_0x38b053,_0x149d59);_0x18864c(null);};};