Built motion from commit (unavailable).|2.4.21
[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 _0x5c3a=['Interaction','findOne','then','info','error','user','query','clone','omit','body','html','phone','fax','mobile','../../mysqldb','openchannel-interactions','../../config/logger','fax-interactions','sms-interactions','chat-interactions','upperFirst','InteractionId','unknown','toLowerCase','[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s','name','role','stringify','null'];(function(_0x2bfd4f,_0x1bbf2c){var _0x341849=function(_0x4c246e){while(--_0x4c246e){_0x2bfd4f['push'](_0x2bfd4f['shift']());}};_0x341849(++_0x1bbf2c);}(_0x5c3a,0xbc));var _0xa5c3=function(_0x5524ea,_0x1d93ab){_0x5524ea=_0x5524ea-0x0;var _0x16b78c=_0x5c3a[_0x5524ea];return _0x16b78c;};'use strict';var _=require('lodash');var db=require(_0xa5c3('0x0'))['db'];var loggers={'openchannel':require('../../config/logger')(_0xa5c3('0x1')),'mail':require(_0xa5c3('0x2'))('mail-interactions'),'fax':require(_0xa5c3('0x2'))(_0xa5c3('0x3')),'sms':require('../../config/logger')(_0xa5c3('0x4')),'chat':require(_0xa5c3('0x2'))(_0xa5c3('0x5'))};function getInteractionId(_0x44f677,_0x37405c,_0x31e68c){if(_0x44f677&&_0x44f677[_[_0xa5c3('0x6')](_0x31e68c)+_0xa5c3('0x7')]){return _0x44f677[_[_0xa5c3('0x6')](_0x31e68c)+_0xa5c3('0x7')];}else if(_0x44f677&&_0x44f677['id']){return _0x44f677['id'];}else if(_0x37405c&&_0x37405c['id']){return _0x37405c['id'];}else{return _0xa5c3('0x8');}}function log(_0x1ef77b,_0x1cd457,_0x2ea2b4,_0x2d4f50,_0x857989,_0x5b04e2){loggers[_0x857989[_0xa5c3('0x9')]()][_0x1ef77b](_0xa5c3('0xa'),_0x5b04e2['toUpperCase'](),_0x1cd457?_0x1cd457['id']:null,_0x1cd457?_0x1cd457[_0xa5c3('0xb')]:null,_0x1cd457?_0x1cd457[_0xa5c3('0xc')]:null,getInteractionId(_0x2ea2b4,_0x2d4f50,_0x857989),_0x2ea2b4?JSON[_0xa5c3('0xd')](_0x2ea2b4):_0xa5c3('0xe'));}function updateUser(_0x374888,_0x3f8342,_0x120aec,_0x9b1aa5,_0x4c2be7){db[_['upperFirst'](_0x9b1aa5)+_0xa5c3('0xf')][_0xa5c3('0x10')]({'where':{'id':getInteractionId(_0x3f8342,_0x120aec,_0x9b1aa5)}})[_0xa5c3('0x11')](function(_0x5a17ce){if(_0x5a17ce){return _0x5a17ce['update']({'UserId':_0x374888?_0x374888['id']:null});}})[_0xa5c3('0x11')](function(_0x238905){if(_0x238905){log(_0xa5c3('0x12'),_0x374888,_0x3f8342,_0x120aec,_0x9b1aa5,_0x4c2be7);}})['catch'](function(){log(_0xa5c3('0x13'),_0x374888,_0x3f8342,_0x120aec,_0x9b1aa5,_0x4c2be7);});}exports['tracked']=function(_0x362e05,_0x156501){return function(_0x4f0963,_0x43237d,_0x102ebd){var _0x308161=_0x4f0963[_0xa5c3('0x14')];var _0x457b2a={};var _0x13b0ca=_0x4f0963[_0xa5c3('0x15')];if(_0x457b2a){_0x457b2a=_[_0xa5c3('0x16')](_0x4f0963['body']);_0x457b2a=_[_0xa5c3('0x17')](_0x457b2a,[_0xa5c3('0x18'),_0xa5c3('0x19'),_0xa5c3('0x1a'),_0xa5c3('0x1b'),_0xa5c3('0x1c')]);}updateUser(_0x308161,_0x457b2a,_0x13b0ca,_0x362e05,_0x156501);_0x102ebd(null);};};