6b320267f1ed35188e6074548d4bb72399c7e89d
[motion2.git] / server / api / openchannelQueue / openchannelQueue.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 _0x178a=['options','attributes','limit','include','map','model','info','ShowOpenchannelQueue','OpenchannelQueue','raw','where','stringify','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','client','defaults','redis','socket.io-emitter','./openchannelQueue.socket','register','request','then','request\x20sent','debug','OpenchannelQueue,\x20%s,\x20%s,\x20%s','error','message','OpenchannelQueue,\x20%s,\x20%s','catch','GetOpenchannelQueue','findAll'];(function(_0x4bc100,_0x4b64c0){var _0x55d077=function(_0x52277f){while(--_0x52277f){_0x4bc100['push'](_0x4bc100['shift']());}};_0x55d077(++_0x4b64c0);}(_0x178a,0x162));var _0xa178=function(_0x3ca58f,_0x44e83e){_0x3ca58f=_0x3ca58f-0x0;var _0xceeb54=_0x178a[_0x3ca58f];return _0xceeb54;};'use strict';var _=require('lodash');var util=require(_0xa178('0x0'));var moment=require(_0xa178('0x1'));var BPromise=require('bluebird');var rs=require(_0xa178('0x2'));var fs=require('fs');var Redis=require(_0xa178('0x3'));var db=require(_0xa178('0x4'))['db'];var utils=require(_0xa178('0x5'));var logger=require(_0xa178('0x6'))(_0xa178('0x7'));var config=require(_0xa178('0x8'));var jayson=require('jayson/promise');var client=jayson[_0xa178('0x9')]['http']({'port':0x232a});config['redis']=_[_0xa178('0xa')](config[_0xa178('0xb')],{'host':'localhost','port':0x18eb});var socket=require(_0xa178('0xc'))(new Redis(config['redis']));require(_0xa178('0xd'))[_0xa178('0xe')](socket);function respondWithRpcPromise(_0x5afd8c,_0x2c5909,_0x30ce71){return new BPromise(function(_0x20d76a,_0x3d8c96){return client[_0xa178('0xf')](_0x5afd8c,_0x30ce71)[_0xa178('0x10')](function(_0x12dd5c){logger['info']('OpenchannelQueue,\x20%s,\x20%s',_0x2c5909,_0xa178('0x11'));logger[_0xa178('0x12')](_0xa178('0x13'),_0x2c5909,_0xa178('0x11'),JSON['stringify'](_0x12dd5c));if(_0x12dd5c['error']){if(_0x12dd5c[_0xa178('0x14')]['code']===0x1f4){logger['error']('OpenchannelQueue,\x20%s,\x20%s',_0x2c5909,_0x12dd5c[_0xa178('0x14')][_0xa178('0x15')]);return _0x3d8c96(_0x12dd5c['error'][_0xa178('0x15')]);}logger['error'](_0xa178('0x16'),_0x2c5909,_0x12dd5c[_0xa178('0x14')][_0xa178('0x15')]);return _0x20d76a(_0x12dd5c[_0xa178('0x14')][_0xa178('0x15')]);}else{logger['info']('OpenchannelQueue,\x20%s,\x20%s',_0x2c5909,_0xa178('0x11'));_0x20d76a(_0x12dd5c['result'][_0xa178('0x15')]);}})[_0xa178('0x17')](function(_0x3b84c0){logger[_0xa178('0x14')](_0xa178('0x16'),_0x2c5909,_0x3b84c0);_0x3d8c96(_0x3b84c0);});});}exports[_0xa178('0x18')]=function(_0x5ecc86){var _0x3c44f4=this;return new Promise(function(_0x436fb6,_0x519839){return db['OpenchannelQueue'][_0xa178('0x19')]({'raw':_0x5ecc86['options']?_0x5ecc86['options']['raw']===undefined?!![]:![]:!![],'where':_0x5ecc86[_0xa178('0x1a')]?_0x5ecc86['options']['where']||null:null,'attributes':_0x5ecc86[_0xa178('0x1a')]?_0x5ecc86['options'][_0xa178('0x1b')]||null:null,'limit':_0x5ecc86[_0xa178('0x1a')]?_0x5ecc86['options'][_0xa178('0x1c')]||null:null,'include':_0x5ecc86[_0xa178('0x1a')]?_0x5ecc86[_0xa178('0x1a')][_0xa178('0x1d')]?_[_0xa178('0x1e')](_0x5ecc86[_0xa178('0x1a')][_0xa178('0x1d')],function(_0x1c0aa0){return{'model':db[_0x1c0aa0['model']],'as':_0x1c0aa0['as'],'attributes':_0x1c0aa0[_0xa178('0x1b')],'include':_0x1c0aa0[_0xa178('0x1d')]?_[_0xa178('0x1e')](_0x1c0aa0[_0xa178('0x1d')],function(_0x1758ad){return{'model':db[_0x1758ad[_0xa178('0x1f')]],'as':_0x1758ad['as'],'attributes':_0x1758ad[_0xa178('0x1b')],'include':_0x1758ad[_0xa178('0x1d')]?_[_0xa178('0x1e')](_0x1758ad[_0xa178('0x1d')],function(_0x3f5337){return{'model':db[_0x3f5337['model']],'as':_0x3f5337['as'],'attributes':_0x3f5337[_0xa178('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xa178('0x10')](function(_0x4b4c2f){logger[_0xa178('0x20')](_0xa178('0x18'),_0x5ecc86);logger[_0xa178('0x12')]('GetOpenchannelQueue',_0x5ecc86,JSON['stringify'](_0x4b4c2f));_0x436fb6(_0x4b4c2f);})['catch'](function(_0x59de3d){logger[_0xa178('0x14')](_0xa178('0x18'),_0x59de3d[_0xa178('0x15')],_0x5ecc86);_0x519839(_0x3c44f4[_0xa178('0x14')](0x1f4,_0x59de3d['message']));});});};exports[_0xa178('0x21')]=function(_0xe18e75){var _0x331787=this;return new Promise(function(_0x305f7a,_0x3e7fc5){return db[_0xa178('0x22')]['find']({'raw':_0xe18e75['options']?_0xe18e75[_0xa178('0x1a')][_0xa178('0x23')]===undefined?!![]:![]:!![],'where':_0xe18e75[_0xa178('0x1a')]?_0xe18e75[_0xa178('0x1a')][_0xa178('0x24')]||null:null,'attributes':_0xe18e75[_0xa178('0x1a')]?_0xe18e75[_0xa178('0x1a')][_0xa178('0x1b')]||null:null,'include':_0xe18e75['options']?_0xe18e75['options'][_0xa178('0x1d')]?_[_0xa178('0x1e')](_0xe18e75[_0xa178('0x1a')][_0xa178('0x1d')],function(_0x4d0bbd){return{'model':db[_0x4d0bbd[_0xa178('0x1f')]],'as':_0x4d0bbd['as'],'attributes':_0x4d0bbd[_0xa178('0x1b')],'include':_0x4d0bbd[_0xa178('0x1d')]?_['map'](_0x4d0bbd[_0xa178('0x1d')],function(_0x25e9f3){return{'model':db[_0x25e9f3[_0xa178('0x1f')]],'as':_0x25e9f3['as'],'attributes':_0x25e9f3[_0xa178('0x1b')],'include':_0x25e9f3['include']?_[_0xa178('0x1e')](_0x25e9f3['include'],function(_0x48b112){return{'model':db[_0x48b112[_0xa178('0x1f')]],'as':_0x48b112['as'],'attributes':_0x48b112[_0xa178('0x1b')]};}):[]};}):[]};}):[]:[]})[_0xa178('0x10')](function(_0x266503){logger[_0xa178('0x20')](_0xa178('0x21'),_0xe18e75);logger[_0xa178('0x12')](_0xa178('0x21'),_0xe18e75,JSON[_0xa178('0x25')](_0x266503));_0x305f7a(_0x266503);})['catch'](function(_0x134253){logger[_0xa178('0x14')](_0xa178('0x21'),_0x134253[_0xa178('0x15')],_0xe18e75);_0x3e7fc5(_0x331787[_0xa178('0x14')](0x1f4,_0x134253['message']));});});};