e60926ebbf4b2b2c2b61741de6b858618ab0237a
[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 _0x7429=['upperFirst','InteractionId','unknown','[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','toUpperCase','name','stringify','null','Interaction','findOne','then','info','catch','error','tracked','user','query','clone','body','omit','html','phone','fax','mobile','../../config/logger','mail-interactions','fax-interactions','sms-interactions','chat-interactions'];(function(_0x6a27db,_0x2731a7){var _0xd814f5=function(_0x19d645){while(--_0x19d645){_0x6a27db['push'](_0x6a27db['shift']());}};_0xd814f5(++_0x2731a7);}(_0x7429,0x6f));var _0x9742=function(_0xb6d872,_0x2b982b){_0xb6d872=_0xb6d872-0x0;var _0x5b8cc9=_0x7429[_0xb6d872];return _0x5b8cc9;};'use strict';var _=require('lodash');var db=require('../../mysqldb')['db'];var loggers={'openchannel':require(_0x9742('0x0'))('openchannel-interactions'),'mail':require(_0x9742('0x0'))(_0x9742('0x1')),'fax':require('../../config/logger')(_0x9742('0x2')),'sms':require(_0x9742('0x0'))(_0x9742('0x3')),'chat':require(_0x9742('0x0'))(_0x9742('0x4')),'whatsapp':require('../../config/logger')('whatsapp-interactions')};function getInteractionId(_0xaae8db,_0x380390,_0x4ead4b){if(_0xaae8db&&_0xaae8db[_[_0x9742('0x5')](_0x4ead4b)+_0x9742('0x6')]){return _0xaae8db[_['upperFirst'](_0x4ead4b)+_0x9742('0x6')];}else if(_0xaae8db&&_0xaae8db['id']){return _0xaae8db['id'];}else if(_0x380390&&_0x380390['id']){return _0x380390['id'];}else{return _0x9742('0x7');}}function log(_0x1ce654,_0x57107f,_0xa507f9,_0x5e459e,_0x192551,_0x179db5){loggers[_0x192551['toLowerCase']()][_0x1ce654](_0x9742('0x8'),_0x179db5[_0x9742('0x9')](),_0x57107f?_0x57107f['id']:null,_0x57107f?_0x57107f[_0x9742('0xa')]:null,_0x57107f?_0x57107f['role']:null,getInteractionId(_0xa507f9,_0x5e459e,_0x192551),_0xa507f9?JSON[_0x9742('0xb')](_0xa507f9):_0x9742('0xc'));}function updateUser(_0x405327,_0x5adbd2,_0x3e2821,_0x2055d3,_0x5693fc){db[_[_0x9742('0x5')](_0x2055d3)+_0x9742('0xd')][_0x9742('0xe')]({'where':{'id':getInteractionId(_0x5adbd2,_0x3e2821,_0x2055d3)}})[_0x9742('0xf')](function(_0x674b9f){if(_0x674b9f){return _0x674b9f['update']({'UserId':_0x405327?_0x405327['id']:null});}})[_0x9742('0xf')](function(_0x4d69d5){if(_0x4d69d5){log(_0x9742('0x10'),_0x405327,_0x5adbd2,_0x3e2821,_0x2055d3,_0x5693fc);}})[_0x9742('0x11')](function(){log(_0x9742('0x12'),_0x405327,_0x5adbd2,_0x3e2821,_0x2055d3,_0x5693fc);});}exports[_0x9742('0x13')]=function(_0x416614,_0x58c895){return function(_0x53e69d,_0x400f5f,_0x4beb18){var _0x224fea=_0x53e69d[_0x9742('0x14')];var _0x2eb668={};var _0x339a0d=_0x53e69d[_0x9742('0x15')];if(_0x2eb668){_0x2eb668=_[_0x9742('0x16')](_0x53e69d[_0x9742('0x17')]);_0x2eb668=_[_0x9742('0x18')](_0x2eb668,['body',_0x9742('0x19'),_0x9742('0x1a'),_0x9742('0x1b'),_0x9742('0x1c')]);}updateUser(_0x224fea,_0x2eb668,_0x339a0d,_0x416614,_0x58c895);_0x4beb18(null);};};