Built motion from commit (unavailable).|2.5.8
[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 _0x5144=['name','stringify','null','Interaction','findOne','then','info','catch','error','tracked','user','query','clone','body','omit','phone','../../mysqldb','../../config/logger','openchannel-interactions','mail-interactions','fax-interactions','sms-interactions','chat-interactions','whatsapp-interactions','upperFirst','InteractionId','unknown','toLowerCase','[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','toUpperCase'];(function(_0x1857cd,_0x360319){var _0x260817=function(_0x9387f2){while(--_0x9387f2){_0x1857cd['push'](_0x1857cd['shift']());}};_0x260817(++_0x360319);}(_0x5144,0xe2));var _0x4514=function(_0x233f47,_0x1fb1de){_0x233f47=_0x233f47-0x0;var _0x239581=_0x5144[_0x233f47];return _0x239581;};'use strict';var _=require('lodash');var db=require(_0x4514('0x0'))['db'];var loggers={'openchannel':require(_0x4514('0x1'))(_0x4514('0x2')),'mail':require(_0x4514('0x1'))(_0x4514('0x3')),'fax':require('../../config/logger')(_0x4514('0x4')),'sms':require('../../config/logger')(_0x4514('0x5')),'chat':require(_0x4514('0x1'))(_0x4514('0x6')),'whatsapp':require('../../config/logger')(_0x4514('0x7'))};function getInteractionId(_0xde1113,_0x9651f0,_0x273e20){if(_0xde1113&&_0xde1113[_[_0x4514('0x8')](_0x273e20)+'InteractionId']){return _0xde1113[_['upperFirst'](_0x273e20)+_0x4514('0x9')];}else if(_0xde1113&&_0xde1113['id']){return _0xde1113['id'];}else if(_0x9651f0&&_0x9651f0['id']){return _0x9651f0['id'];}else{return _0x4514('0xa');}}function log(_0x42d4a4,_0x44a21e,_0x2bd7e4,_0x4b71ca,_0x4ed391,_0x43a0bf){loggers[_0x4ed391[_0x4514('0xb')]()][_0x42d4a4](_0x4514('0xc'),_0x43a0bf[_0x4514('0xd')](),_0x44a21e?_0x44a21e['id']:null,_0x44a21e?_0x44a21e[_0x4514('0xe')]:null,_0x44a21e?_0x44a21e['role']:null,getInteractionId(_0x2bd7e4,_0x4b71ca,_0x4ed391),_0x2bd7e4?JSON[_0x4514('0xf')](_0x2bd7e4):_0x4514('0x10'));}function updateUser(_0x2e0ccc,_0x51d9ed,_0x346178,_0x3ad0bc,_0x496170){db[_[_0x4514('0x8')](_0x3ad0bc)+_0x4514('0x11')][_0x4514('0x12')]({'where':{'id':getInteractionId(_0x51d9ed,_0x346178,_0x3ad0bc)}})['then'](function(_0x11919f){if(_0x11919f){return _0x11919f['update']({'UserId':_0x2e0ccc?_0x2e0ccc['id']:null});}})[_0x4514('0x13')](function(_0x922d77){if(_0x922d77){log(_0x4514('0x14'),_0x2e0ccc,_0x51d9ed,_0x346178,_0x3ad0bc,_0x496170);}})[_0x4514('0x15')](function(){log(_0x4514('0x16'),_0x2e0ccc,_0x51d9ed,_0x346178,_0x3ad0bc,_0x496170);});}exports[_0x4514('0x17')]=function(_0x15cee9,_0xcf739f){return function(_0xf990e3,_0x126fdc,_0x356782){var _0x127a14=_0xf990e3[_0x4514('0x18')];var _0x4faafb={};var _0x35c502=_0xf990e3[_0x4514('0x19')];if(_0x4faafb){_0x4faafb=_[_0x4514('0x1a')](_0xf990e3[_0x4514('0x1b')]);_0x4faafb=_[_0x4514('0x1c')](_0x4faafb,[_0x4514('0x1b'),'html',_0x4514('0x1d'),'fax','mobile']);}updateUser(_0x127a14,_0x4faafb,_0x35c502,_0x15cee9,_0xcf739f);_0x356782(null);};};