Built motion from commit 67e5df37.|2.0.66
[motion2.git] / server / api / openchannelInteraction / openchannelInteraction.rpc.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 _0x24cf=['info','OpenchannelInteraction,\x20%s,\x20%s','request\x20sent','OpenchannelInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','UpdateOpenchannelInteraction','OpenchannelInteraction','update','body','options','raw','where','attributes','limit','debug','AddTagsToOpenchannelInteraction','find','ids','omit','AddTags','moment','bluebird','randomstring','../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','./openchannelInteraction.socket','request','then'];(function(_0x295bc6,_0x12b2d5){var _0x7308fc=function(_0x3b5bc4){while(--_0x3b5bc4){_0x295bc6['push'](_0x295bc6['shift']());}};_0x7308fc(++_0x12b2d5);}(_0x24cf,0x1d5));var _0xf24c=function(_0x3644ac,_0x13175a){_0x3644ac=_0x3644ac-0x0;var _0x1f9390=_0x24cf[_0x3644ac];return _0x1f9390;};'use strict';var _=require('lodash');var util=require('util');var moment=require(_0xf24c('0x0'));var BPromise=require(_0xf24c('0x1'));var rs=require(_0xf24c('0x2'));var fs=require('fs');var db=require(_0xf24c('0x3'))['db'];var utils=require(_0xf24c('0x4'));var logger=require('../../config/logger')(_0xf24c('0x5'));var config=require(_0xf24c('0x6'));var jayson=require(_0xf24c('0x7'));var client=jayson[_0xf24c('0x8')]['http']({'port':0x232a});var socket=require('socket.io-emitter')({'host':'localhost','port':0x18eb});require(_0xf24c('0x9'))['register'](socket);function respondWithRpcPromise(_0x3b7cf1,_0x13163e,_0x29841c){return new BPromise(function(_0x458507,_0x4b3ea3){return client[_0xf24c('0xa')](_0x3b7cf1,_0x29841c)[_0xf24c('0xb')](function(_0x260dfd){logger[_0xf24c('0xc')](_0xf24c('0xd'),_0x13163e,_0xf24c('0xe'));logger['debug'](_0xf24c('0xf'),_0x13163e,_0xf24c('0xe'),JSON[_0xf24c('0x10')](_0x260dfd));if(_0x260dfd['error']){if(_0x260dfd[_0xf24c('0x11')][_0xf24c('0x12')]===0x1f4){logger['error']('OpenchannelInteraction,\x20%s,\x20%s',_0x13163e,_0x260dfd[_0xf24c('0x11')]['message']);return _0x4b3ea3(_0x260dfd[_0xf24c('0x11')][_0xf24c('0x13')]);}logger['error'](_0xf24c('0xd'),_0x13163e,_0x260dfd[_0xf24c('0x11')][_0xf24c('0x13')]);return _0x458507(_0x260dfd[_0xf24c('0x11')][_0xf24c('0x13')]);}else{logger['info']('OpenchannelInteraction,\x20%s,\x20%s',_0x13163e,_0xf24c('0xe'));_0x458507(_0x260dfd[_0xf24c('0x14')]['message']);}})[_0xf24c('0x15')](function(_0x35eb58){logger[_0xf24c('0x11')](_0xf24c('0xd'),_0x13163e,_0x35eb58);_0x4b3ea3(_0x35eb58);});});}exports[_0xf24c('0x16')]=function(_0x3a0b61){var _0x36ceba=this;return new Promise(function(_0x565fef,_0x1ebfa1){return db[_0xf24c('0x17')][_0xf24c('0x18')](_0x3a0b61[_0xf24c('0x19')],{'raw':_0x3a0b61['options']?_0x3a0b61[_0xf24c('0x1a')][_0xf24c('0x1b')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x3a0b61['options']?_0x3a0b61[_0xf24c('0x1a')][_0xf24c('0x1c')]||null:null,'attributes':_0x3a0b61[_0xf24c('0x1a')]?_0x3a0b61['options'][_0xf24c('0x1d')]||null:null,'limit':_0x3a0b61['options']?_0x3a0b61[_0xf24c('0x1a')][_0xf24c('0x1e')]||null:null})['then'](function(_0x1a54ea){logger[_0xf24c('0xc')](_0xf24c('0x16'),_0x3a0b61);logger[_0xf24c('0x1f')](_0xf24c('0x16'),_0x3a0b61,JSON[_0xf24c('0x10')](_0x1a54ea));_0x565fef(_0x1a54ea);})[_0xf24c('0x15')](function(_0x13cda8){logger[_0xf24c('0x11')](_0xf24c('0x16'),_0x13cda8[_0xf24c('0x13')],_0x3a0b61);_0x1ebfa1(_0x36ceba['error'](0x1f4,_0x13cda8['message']));});});};exports[_0xf24c('0x20')]=function(_0x4940e0){return new Promise(function(_0x535e78,_0x46d94b){return db['OpenchannelInteraction'][_0xf24c('0x21')]({'where':_0x4940e0[_0xf24c('0x1a')]?_0x4940e0['options']['where']||null:null})['then'](function(_0x12129f){if(_0x12129f){return _0x12129f['addTags'](_0x4940e0[_0xf24c('0x19')][_0xf24c('0x22')],_[_0xf24c('0x23')](_0x4940e0['body'],[_0xf24c('0x22'),'id'])||{});}})['spread'](function(_0x580b35){logger[_0xf24c('0xc')](_0xf24c('0x24'),_0x4940e0);logger[_0xf24c('0x1f')](_0xf24c('0x24'),_0x4940e0,JSON['stringify'](_0x580b35));_0x535e78(_0x580b35);})[_0xf24c('0x15')](function(_0x13adfb){logger[_0xf24c('0x11')](_0xf24c('0x24'),_0x13adfb[_0xf24c('0x13')],_0x4940e0);_0x46d94b(_this[_0xf24c('0x11')](0x1f4,_0x13adfb['message']));});});};