c319a478ad8240f3b2356ffae7dce6369c7e306e
[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 _0x238f=['upperFirst','InteractionId','toLowerCase','role','null','Interaction','update','then','catch','tracked','user','clone','body','omit','html','phone','fax','mobile','lodash','../../mysqldb','../../config/logger','openchannel-interactions','mail-interactions','fax-interactions','sms-interactions'];(function(_0x51766c,_0x4110ef){var _0x243c62=function(_0xdefdbe){while(--_0xdefdbe){_0x51766c['push'](_0x51766c['shift']());}};_0x243c62(++_0x4110ef);}(_0x238f,0x1d4));var _0xf238=function(_0x3105b3,_0x5a1835){_0x3105b3=_0x3105b3-0x0;var _0x375d28=_0x238f[_0x3105b3];return _0x375d28;};'use strict';var _=require(_0xf238('0x0'));var db=require(_0xf238('0x1'))['db'];var loggers={'openchannel':require(_0xf238('0x2'))(_0xf238('0x3')),'mail':require(_0xf238('0x2'))(_0xf238('0x4')),'fax':require(_0xf238('0x2'))(_0xf238('0x5')),'sms':require(_0xf238('0x2'))(_0xf238('0x6')),'chat':require(_0xf238('0x2'))('chat-interactions'),'whatsapp':require(_0xf238('0x2'))('whatsapp-interactions')};function getInteractionId(_0x598a56,_0x5334d4,_0xbf4b15){if(_0x598a56&&_0x598a56[_[_0xf238('0x7')](_0xbf4b15)+_0xf238('0x8')]){return _0x598a56[_['upperFirst'](_0xbf4b15)+_0xf238('0x8')];}else if(_0x598a56&&_0x598a56['id']){return _0x598a56['id'];}else if(_0x5334d4&&_0x5334d4['id']){return _0x5334d4['id'];}else{return'unknown';}}function log(_0x448421,_0x52c322,_0x49aca3,_0x33907a,_0x26a174,_0x1cc918){loggers[_0x26a174[_0xf238('0x9')]()][_0x448421]('[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x1cc918['toUpperCase'](),_0x52c322?_0x52c322['id']:null,_0x52c322?_0x52c322['name']:null,_0x52c322?_0x52c322[_0xf238('0xa')]:null,getInteractionId(_0x49aca3,_0x33907a,_0x26a174),_0x49aca3?JSON['stringify'](_0x49aca3):_0xf238('0xb'));}function updateUser(_0x2d4467,_0x4a1dbd,_0x2cd6ac,_0x5a286b,_0x5a0855){db[_[_0xf238('0x7')](_0x5a286b)+_0xf238('0xc')]['findOne']({'where':{'id':getInteractionId(_0x4a1dbd,_0x2cd6ac,_0x5a286b)}})['then'](function(_0x95b431){if(_0x95b431){return _0x95b431[_0xf238('0xd')]({'UserId':_0x2d4467?_0x2d4467['id']:null});}})[_0xf238('0xe')](function(_0x5345ac){if(_0x5345ac){log('info',_0x2d4467,_0x4a1dbd,_0x2cd6ac,_0x5a286b,_0x5a0855);}})[_0xf238('0xf')](function(){log('error',_0x2d4467,_0x4a1dbd,_0x2cd6ac,_0x5a286b,_0x5a0855);});}exports[_0xf238('0x10')]=function(_0x5af383,_0x21e0fc){return function(_0x25da5b,_0x3e3400,_0x2671cf){var _0x3086a3=_0x25da5b[_0xf238('0x11')];var _0xdfca05={};var _0x283a3a=_0x25da5b['query'];if(_0xdfca05){_0xdfca05=_[_0xf238('0x12')](_0x25da5b[_0xf238('0x13')]);_0xdfca05=_[_0xf238('0x14')](_0xdfca05,[_0xf238('0x13'),_0xf238('0x15'),_0xf238('0x16'),_0xf238('0x17'),_0xf238('0x18')]);}updateUser(_0x3086a3,_0xdfca05,_0x283a3a,_0x5af383,_0x21e0fc);_0x2671cf(null);};};