2738863d41774d18e4afa19e0cfa451c8faaeb92
[motion2.git] / server / components / interaction / utils.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 _0xf34a=['mail-interactions','fax-interactions','sms-interactions','capitalize','chat','Website','Account','InteractionId','upperFirst','unknown','websites','accounts','_interactions','_interaction_has_tags','user_has_','isArray','[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','toUpperCase','name','role','stringify','Interaction','then','update','info','catch','error','lodash','../../mysqldb','../../config/logger','openchannel-interactions'];(function(_0x48df04,_0x1522b1){var _0x4de5fa=function(_0x3ae6db){while(--_0x3ae6db){_0x48df04['push'](_0x48df04['shift']());}};_0x4de5fa(++_0x1522b1);}(_0xf34a,0x78));var _0xaf34=function(_0x1b6fb7,_0x2cea7f){_0x1b6fb7=_0x1b6fb7-0x0;var _0x327d7a=_0xf34a[_0x1b6fb7];return _0x327d7a;};'use strict';var _=require(_0xaf34('0x0'));var db=require(_0xaf34('0x1'))['db'];var loggers={'openchannel':require(_0xaf34('0x2'))(_0xaf34('0x3')),'mail':require('../../config/logger')(_0xaf34('0x4')),'fax':require(_0xaf34('0x2'))(_0xaf34('0x5')),'sms':require(_0xaf34('0x2'))(_0xaf34('0x6')),'chat':require(_0xaf34('0x2'))('chat-interactions'),'whatsapp':require(_0xaf34('0x2'))('whatsapp-interactions')};function getAccountFK(_0x414768){return _[_0xaf34('0x7')](_0x414768)+(_0x414768===_0xaf34('0x8')?_0xaf34('0x9'):_0xaf34('0xa'))+'Id';}function getInteractionFK(_0x469021){return _[_0xaf34('0x7')](_0x469021)+_0xaf34('0xb');}function getInteractionId(_0x39ede4,_0x1f5235,_0x5eed6c){if(_0x39ede4&&_0x39ede4[_['upperFirst'](_0x5eed6c)+_0xaf34('0xb')]){return _0x39ede4[_[_0xaf34('0xc')](_0x5eed6c)+_0xaf34('0xb')];}else if(_0x39ede4&&_0x39ede4['id']){return _0x39ede4['id'];}else if(_0x1f5235&&_0x1f5235['id']){return _0x1f5235['id'];}else{return _0xaf34('0xd');}}function getInteractionsTables(_0x2e5024){return{'accounts':_0x2e5024+'_'+(_0x2e5024==='chat'?_0xaf34('0xe'):_0xaf34('0xf')),'interactions':_0x2e5024+_0xaf34('0x10'),'interactionsTags':_0x2e5024+_0xaf34('0x11'),'messages':_0x2e5024+'_messages','userInteractions':_0xaf34('0x12')+_0x2e5024+_0xaf34('0x10')};}function getSelectedTags(_0x4a2215){var _0x39eb86=[];if(_0x4a2215){_0x39eb86=Array[_0xaf34('0x13')](_0x4a2215)?_0x4a2215:[_0x4a2215];}return _0x39eb86;}function log(_0x5399c4,_0xfe8084,_0x253d24,_0x2db311,_0x51206d,_0x5e5d1c){loggers[_0x51206d['toLowerCase']()][_0x5399c4](_0xaf34('0x14'),_0x5e5d1c[_0xaf34('0x15')](),_0xfe8084?_0xfe8084['id']:null,_0xfe8084?_0xfe8084[_0xaf34('0x16')]:null,_0xfe8084?_0xfe8084[_0xaf34('0x17')]:null,getInteractionId(_0x253d24,_0x2db311,_0x51206d),_0x253d24?JSON[_0xaf34('0x18')](_0x253d24):'null');}function updateUser(_0x4ae4c9,_0x564ff1,_0xbaa446,_0x2edc3f,_0x522bcf){db[_['upperFirst'](_0x2edc3f)+_0xaf34('0x19')]['findOne']({'where':{'id':getInteractionId(_0x564ff1,_0xbaa446,_0x2edc3f)}})[_0xaf34('0x1a')](function(_0x48baa1){if(_0x48baa1){return _0x48baa1[_0xaf34('0x1b')]({'UserId':_0x4ae4c9?_0x4ae4c9['id']:null});}})['then'](function(_0x7d7d9){if(_0x7d7d9){log(_0xaf34('0x1c'),_0x4ae4c9,_0x564ff1,_0xbaa446,_0x2edc3f,_0x522bcf);}})[_0xaf34('0x1d')](function(){log(_0xaf34('0x1e'),_0x4ae4c9,_0x564ff1,_0xbaa446,_0x2edc3f,_0x522bcf);});}module['exports']={'getAccountFK':getAccountFK,'getInteractionFK':getInteractionFK,'getInteractionsTables':getInteractionsTables,'getSelectedTags':getSelectedTags,'updateUser':updateUser};