Built motion from commit da617fac.|2.6.6
[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 _0x10d2=['fax-interactions','sms-interactions','whatsapp-interactions','chat','Account','InteractionId','upperFirst','unknown','accounts','_interaction_has_tags','_messages','user_has_','_interactions','isArray','toLowerCase','[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','toUpperCase','name','role','stringify','null','Interaction','findOne','then','update','info','catch','error','exports','../../config/logger'];(function(_0x19950b,_0x53d0d7){var _0x3c6b41=function(_0x3924ad){while(--_0x3924ad){_0x19950b['push'](_0x19950b['shift']());}};_0x3c6b41(++_0x53d0d7);}(_0x10d2,0x77));var _0x210d=function(_0x502ee2,_0x20d426){_0x502ee2=_0x502ee2-0x0;var _0x1bac51=_0x10d2[_0x502ee2];return _0x1bac51;};'use strict';var _=require('lodash');var db=require('../../mysqldb')['db'];var loggers={'openchannel':require(_0x210d('0x0'))('openchannel-interactions'),'mail':require(_0x210d('0x0'))('mail-interactions'),'fax':require(_0x210d('0x0'))(_0x210d('0x1')),'sms':require(_0x210d('0x0'))(_0x210d('0x2')),'chat':require(_0x210d('0x0'))('chat-interactions'),'whatsapp':require(_0x210d('0x0'))(_0x210d('0x3'))};function getAccountFK(_0x533bb5){return _['capitalize'](_0x533bb5)+(_0x533bb5===_0x210d('0x4')?'Website':_0x210d('0x5'))+'Id';}function getInteractionFK(_0xd284cc){return _['capitalize'](_0xd284cc)+_0x210d('0x6');}function getInteractionId(_0x250aef,_0x2ef719,_0x1db66b){if(_0x250aef&&_0x250aef[_[_0x210d('0x7')](_0x1db66b)+'InteractionId']){return _0x250aef[_[_0x210d('0x7')](_0x1db66b)+_0x210d('0x6')];}else if(_0x250aef&&_0x250aef['id']){return _0x250aef['id'];}else if(_0x2ef719&&_0x2ef719['id']){return _0x2ef719['id'];}else{return _0x210d('0x8');}}function getInteractionsTables(_0x4625c7){return{'accounts':_0x4625c7+'_'+(_0x4625c7===_0x210d('0x4')?'websites':_0x210d('0x9')),'interactions':_0x4625c7+'_interactions','interactionsTags':_0x4625c7+_0x210d('0xa'),'messages':_0x4625c7+_0x210d('0xb'),'userInteractions':_0x210d('0xc')+_0x4625c7+_0x210d('0xd')};}function getSelectedTags(_0x495165){var _0x4a341f=[];if(_0x495165){_0x4a341f=Array[_0x210d('0xe')](_0x495165)?_0x495165:[_0x495165];}return _0x4a341f;}function log(_0x4e22b9,_0x3bf882,_0x1b3cf,_0x212ffa,_0x5d0585,_0x3d9bb0){loggers[_0x5d0585[_0x210d('0xf')]()][_0x4e22b9](_0x210d('0x10'),_0x3d9bb0[_0x210d('0x11')](),_0x3bf882?_0x3bf882['id']:null,_0x3bf882?_0x3bf882[_0x210d('0x12')]:null,_0x3bf882?_0x3bf882[_0x210d('0x13')]:null,getInteractionId(_0x1b3cf,_0x212ffa,_0x5d0585),_0x1b3cf?JSON[_0x210d('0x14')](_0x1b3cf):_0x210d('0x15'));}function updateUser(_0x43ffe6,_0x12a005,_0xfef854,_0x3108c6,_0x45b075){db[_[_0x210d('0x7')](_0x3108c6)+_0x210d('0x16')][_0x210d('0x17')]({'where':{'id':getInteractionId(_0x12a005,_0xfef854,_0x3108c6)}})[_0x210d('0x18')](function(_0x320526){if(_0x320526){return _0x320526[_0x210d('0x19')]({'UserId':_0x43ffe6?_0x43ffe6['id']:null});}})[_0x210d('0x18')](function(_0x567fa8){if(_0x567fa8){log(_0x210d('0x1a'),_0x43ffe6,_0x12a005,_0xfef854,_0x3108c6,_0x45b075);}})[_0x210d('0x1b')](function(){log(_0x210d('0x1c'),_0x43ffe6,_0x12a005,_0xfef854,_0x3108c6,_0x45b075);});}module[_0x210d('0x1d')]={'getAccountFK':getAccountFK,'getInteractionFK':getInteractionFK,'getInteractionsTables':getInteractionsTables,'getSelectedTags':getSelectedTags,'updateUser':updateUser};