Built motion from commit 67e5df37.|2.0.66
[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 _0x4b89=['phone','mobile','../../mysqldb','../../config/logger','openchannel-interactions','fax-interactions','sms-interactions','chat-interactions','upperFirst','InteractionId','unknown','toLowerCase','toUpperCase','name','role','stringify','null','Interaction','findOne','then','tracked','query','clone','body','omit','html'];(function(_0x14afaf,_0x1ae7d8){var _0x321165=function(_0x5bd2ec){while(--_0x5bd2ec){_0x14afaf['push'](_0x14afaf['shift']());}};_0x321165(++_0x1ae7d8);}(_0x4b89,0x9e));var _0x94b8=function(_0x301486,_0x27b799){_0x301486=_0x301486-0x0;var _0x418d16=_0x4b89[_0x301486];return _0x418d16;};'use strict';var _=require('lodash');var db=require(_0x94b8('0x0'))['db'];var loggers={'openchannel':require(_0x94b8('0x1'))(_0x94b8('0x2')),'mail':require(_0x94b8('0x1'))('mail-interactions'),'fax':require(_0x94b8('0x1'))(_0x94b8('0x3')),'sms':require(_0x94b8('0x1'))(_0x94b8('0x4')),'chat':require(_0x94b8('0x1'))(_0x94b8('0x5'))};function getInteractionId(_0x354704,_0x29e4a8,_0x17718d){if(_0x354704&&_0x354704[_[_0x94b8('0x6')](_0x17718d)+_0x94b8('0x7')]){return _0x354704[_[_0x94b8('0x6')](_0x17718d)+'InteractionId'];}else if(_0x354704&&_0x354704['id']){return _0x354704['id'];}else if(_0x29e4a8&&_0x29e4a8['id']){return _0x29e4a8['id'];}else{return _0x94b8('0x8');}}function log(_0x524bd4,_0x3735ed,_0x8155d,_0x57762c,_0x51f056,_0x410d48){loggers[_0x51f056[_0x94b8('0x9')]()][_0x524bd4]('[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x410d48[_0x94b8('0xa')](),_0x3735ed?_0x3735ed['id']:null,_0x3735ed?_0x3735ed[_0x94b8('0xb')]:null,_0x3735ed?_0x3735ed[_0x94b8('0xc')]:null,getInteractionId(_0x8155d,_0x57762c,_0x51f056),_0x8155d?JSON[_0x94b8('0xd')](_0x8155d):_0x94b8('0xe'));}function updateUser(_0x3c982c,_0xea0534,_0x1b7d68,_0x5ae745,_0x4e75a1){db[_[_0x94b8('0x6')](_0x5ae745)+_0x94b8('0xf')][_0x94b8('0x10')]({'where':{'id':getInteractionId(_0xea0534,_0x1b7d68,_0x5ae745)}})[_0x94b8('0x11')](function(_0x256c08){if(_0x256c08){return _0x256c08['update']({'UserId':_0x3c982c['id']});}})[_0x94b8('0x11')](function(_0x4e9e84){if(_0x4e9e84){log('info',_0x3c982c,_0xea0534,_0x1b7d68,_0x5ae745,_0x4e75a1);}})['catch'](function(){log('error',_0x3c982c,_0xea0534,_0x1b7d68,_0x5ae745,_0x4e75a1);});}exports[_0x94b8('0x12')]=function(_0x6c0f35,_0x199fb4){return function(_0x2d2bce,_0x413e10,_0x59e473){var _0x4eb81c=_0x2d2bce['user'];var _0x11fc20={};var _0x2381ec=_0x2d2bce[_0x94b8('0x13')];if(_0x11fc20){_0x11fc20=_[_0x94b8('0x14')](_0x2d2bce[_0x94b8('0x15')]);_0x11fc20=_[_0x94b8('0x16')](_0x11fc20,[_0x94b8('0x15'),_0x94b8('0x17'),_0x94b8('0x18'),'fax',_0x94b8('0x19')]);}updateUser(_0x4eb81c,_0x11fc20,_0x2381ec,_0x6c0f35,_0x199fb4);_0x59e473(null);};};