Built motion from commit (unavailable).|2.5.30
[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 _0xf808=['findOne','then','update','info','error','user','body','omit','phone','fax','mobile','../../config/logger','openchannel-interactions','fax-interactions','sms-interactions','chat-interactions','whatsapp-interactions','InteractionId','upperFirst','unknown','toLowerCase','name','role','null'];(function(_0x507f9e,_0x308d20){var _0x250f7e=function(_0x144202){while(--_0x144202){_0x507f9e['push'](_0x507f9e['shift']());}};_0x250f7e(++_0x308d20);}(_0xf808,0x83));var _0x8f80=function(_0x5d48b0,_0xff27bd){_0x5d48b0=_0x5d48b0-0x0;var _0x486a3f=_0xf808[_0x5d48b0];return _0x486a3f;};'use strict';var _=require('lodash');var db=require('../../mysqldb')['db'];var loggers={'openchannel':require(_0x8f80('0x0'))(_0x8f80('0x1')),'mail':require(_0x8f80('0x0'))('mail-interactions'),'fax':require(_0x8f80('0x0'))(_0x8f80('0x2')),'sms':require(_0x8f80('0x0'))(_0x8f80('0x3')),'chat':require('../../config/logger')(_0x8f80('0x4')),'whatsapp':require('../../config/logger')(_0x8f80('0x5'))};function getInteractionId(_0x4e2e35,_0xf7be4c,_0x456dd6){if(_0x4e2e35&&_0x4e2e35[_['upperFirst'](_0x456dd6)+_0x8f80('0x6')]){return _0x4e2e35[_[_0x8f80('0x7')](_0x456dd6)+_0x8f80('0x6')];}else if(_0x4e2e35&&_0x4e2e35['id']){return _0x4e2e35['id'];}else if(_0xf7be4c&&_0xf7be4c['id']){return _0xf7be4c['id'];}else{return _0x8f80('0x8');}}function log(_0x1f982a,_0x28d9ac,_0x1899a8,_0x5a3530,_0x2f0939,_0xa42eaf){loggers[_0x2f0939[_0x8f80('0x9')]()][_0x1f982a]('[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0xa42eaf['toUpperCase'](),_0x28d9ac?_0x28d9ac['id']:null,_0x28d9ac?_0x28d9ac[_0x8f80('0xa')]:null,_0x28d9ac?_0x28d9ac[_0x8f80('0xb')]:null,getInteractionId(_0x1899a8,_0x5a3530,_0x2f0939),_0x1899a8?JSON['stringify'](_0x1899a8):_0x8f80('0xc'));}function updateUser(_0x335bb8,_0x34096d,_0x127c89,_0xa95119,_0xb69cc){db[_[_0x8f80('0x7')](_0xa95119)+'Interaction'][_0x8f80('0xd')]({'where':{'id':getInteractionId(_0x34096d,_0x127c89,_0xa95119)}})[_0x8f80('0xe')](function(_0x53bbf0){if(_0x53bbf0){return _0x53bbf0[_0x8f80('0xf')]({'UserId':_0x335bb8?_0x335bb8['id']:null});}})[_0x8f80('0xe')](function(_0x2280c8){if(_0x2280c8){log(_0x8f80('0x10'),_0x335bb8,_0x34096d,_0x127c89,_0xa95119,_0xb69cc);}})['catch'](function(){log(_0x8f80('0x11'),_0x335bb8,_0x34096d,_0x127c89,_0xa95119,_0xb69cc);});}exports['tracked']=function(_0x1ffac1,_0x16187d){return function(_0x1fba32,_0x586e3c,_0x329f9b){var _0x2306de=_0x1fba32[_0x8f80('0x12')];var _0x2d0a8c={};var _0x1a245d=_0x1fba32['query'];if(_0x2d0a8c){_0x2d0a8c=_['clone'](_0x1fba32[_0x8f80('0x13')]);_0x2d0a8c=_[_0x8f80('0x14')](_0x2d0a8c,[_0x8f80('0x13'),'html',_0x8f80('0x15'),_0x8f80('0x16'),_0x8f80('0x17')]);}updateUser(_0x2306de,_0x2d0a8c,_0x1a245d,_0x1ffac1,_0x16187d);_0x329f9b(null);};};