Built motion from commit (unavailable).|2.5.6
[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 _0xac8d=['mail-interactions','fax-interactions','chat-interactions','whatsapp-interactions','upperFirst','InteractionId','toLowerCase','toUpperCase','name','role','null','Interaction','findOne','then','update','info','error','tracked','user','clone','body','omit','html','fax','lodash','../../mysqldb','../../config/logger','openchannel-interactions'];(function(_0x3a6074,_0x15f4af){var _0x1ff88a=function(_0x12484a){while(--_0x12484a){_0x3a6074['push'](_0x3a6074['shift']());}};_0x1ff88a(++_0x15f4af);}(_0xac8d,0x1d8));var _0xdac8=function(_0x415d81,_0x3bc339){_0x415d81=_0x415d81-0x0;var _0x54432f=_0xac8d[_0x415d81];return _0x54432f;};'use strict';var _=require(_0xdac8('0x0'));var db=require(_0xdac8('0x1'))['db'];var loggers={'openchannel':require(_0xdac8('0x2'))(_0xdac8('0x3')),'mail':require(_0xdac8('0x2'))(_0xdac8('0x4')),'fax':require(_0xdac8('0x2'))(_0xdac8('0x5')),'sms':require(_0xdac8('0x2'))('sms-interactions'),'chat':require(_0xdac8('0x2'))(_0xdac8('0x6')),'whatsapp':require(_0xdac8('0x2'))(_0xdac8('0x7'))};function getInteractionId(_0x1e1cc7,_0x3677da,_0x8f90bd){if(_0x1e1cc7&&_0x1e1cc7[_[_0xdac8('0x8')](_0x8f90bd)+_0xdac8('0x9')]){return _0x1e1cc7[_['upperFirst'](_0x8f90bd)+_0xdac8('0x9')];}else if(_0x1e1cc7&&_0x1e1cc7['id']){return _0x1e1cc7['id'];}else if(_0x3677da&&_0x3677da['id']){return _0x3677da['id'];}else{return'unknown';}}function log(_0xe2d455,_0x3c6884,_0x1c1c20,_0x2f9c0d,_0x2d68be,_0x4aa513){loggers[_0x2d68be[_0xdac8('0xa')]()][_0xe2d455]('[%s]\x20id=%s\x20name=%s\x20role=%s\x20interaction=%s\x20body=%s',_0x4aa513[_0xdac8('0xb')](),_0x3c6884?_0x3c6884['id']:null,_0x3c6884?_0x3c6884[_0xdac8('0xc')]:null,_0x3c6884?_0x3c6884[_0xdac8('0xd')]:null,getInteractionId(_0x1c1c20,_0x2f9c0d,_0x2d68be),_0x1c1c20?JSON['stringify'](_0x1c1c20):_0xdac8('0xe'));}function updateUser(_0x506bfa,_0x4b7872,_0x15d1da,_0x47886b,_0x3aecc4){db[_[_0xdac8('0x8')](_0x47886b)+_0xdac8('0xf')][_0xdac8('0x10')]({'where':{'id':getInteractionId(_0x4b7872,_0x15d1da,_0x47886b)}})[_0xdac8('0x11')](function(_0x59900e){if(_0x59900e){return _0x59900e[_0xdac8('0x12')]({'UserId':_0x506bfa?_0x506bfa['id']:null});}})[_0xdac8('0x11')](function(_0x3719f4){if(_0x3719f4){log(_0xdac8('0x13'),_0x506bfa,_0x4b7872,_0x15d1da,_0x47886b,_0x3aecc4);}})['catch'](function(){log(_0xdac8('0x14'),_0x506bfa,_0x4b7872,_0x15d1da,_0x47886b,_0x3aecc4);});}exports[_0xdac8('0x15')]=function(_0x41a288,_0x18dcb5){return function(_0x272803,_0x466bfa,_0x4033e1){var _0x64a73f=_0x272803[_0xdac8('0x16')];var _0x414005={};var _0x21f219=_0x272803['query'];if(_0x414005){_0x414005=_[_0xdac8('0x17')](_0x272803[_0xdac8('0x18')]);_0x414005=_[_0xdac8('0x19')](_0x414005,[_0xdac8('0x18'),_0xdac8('0x1a'),'phone',_0xdac8('0x1b'),'mobile']);}updateUser(_0x64a73f,_0x414005,_0x21f219,_0x41a288,_0x18dcb5);_0x4033e1(null);};};