Built motion from commit 994c64e1.|2.6.1
[motion2.git] / server / api / intDeskAccount / intDeskAccount.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 _0xcd66=['result','catch','GetDeskAccount','DeskAccount','findAll','options','raw','where','limit','include','map','model','attributes','find','ShowDeskAccount','lodash','util','moment','bluebird','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','then','info','DeskAccount,\x20%s,\x20%s','debug','DeskAccount,\x20%s,\x20%s,\x20%s','stringify','error','message','request\x20sent'];(function(_0x4d657d,_0x8d4c9f){var _0x52400c=function(_0xb4cffa){while(--_0xb4cffa){_0x4d657d['push'](_0x4d657d['shift']());}};_0x52400c(++_0x8d4c9f);}(_0xcd66,0x1e3));var _0x6cd6=function(_0xe4a19d,_0x118532){_0xe4a19d=_0xe4a19d-0x0;var _0x28a8b7=_0xcd66[_0xe4a19d];return _0x28a8b7;};'use strict';var _=require(_0x6cd6('0x0'));var util=require(_0x6cd6('0x1'));var moment=require(_0x6cd6('0x2'));var BPromise=require(_0x6cd6('0x3'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require(_0x6cd6('0x4'))['db'];var utils=require(_0x6cd6('0x5'));var logger=require(_0x6cd6('0x6'))(_0x6cd6('0x7'));var config=require(_0x6cd6('0x8'));var jayson=require(_0x6cd6('0x9'));var client=jayson['client'][_0x6cd6('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x19a21b,_0x132c50,_0x580477){return new BPromise(function(_0x566f4b,_0x3a0ee1){return client[_0x6cd6('0xb')](_0x19a21b,_0x580477)[_0x6cd6('0xc')](function(_0x2c3375){logger[_0x6cd6('0xd')](_0x6cd6('0xe'),_0x132c50,'request\x20sent');logger[_0x6cd6('0xf')](_0x6cd6('0x10'),_0x132c50,'request\x20sent',JSON[_0x6cd6('0x11')](_0x2c3375));if(_0x2c3375[_0x6cd6('0x12')]){if(_0x2c3375['error']['code']===0x1f4){logger[_0x6cd6('0x12')](_0x6cd6('0xe'),_0x132c50,_0x2c3375[_0x6cd6('0x12')][_0x6cd6('0x13')]);return _0x3a0ee1(_0x2c3375['error']['message']);}logger[_0x6cd6('0x12')](_0x6cd6('0xe'),_0x132c50,_0x2c3375['error'][_0x6cd6('0x13')]);return _0x566f4b(_0x2c3375[_0x6cd6('0x12')]['message']);}else{logger[_0x6cd6('0xd')](_0x6cd6('0xe'),_0x132c50,_0x6cd6('0x14'));_0x566f4b(_0x2c3375[_0x6cd6('0x15')]['message']);}})[_0x6cd6('0x16')](function(_0x58a3cc){logger[_0x6cd6('0x12')](_0x6cd6('0xe'),_0x132c50,_0x58a3cc);_0x3a0ee1(_0x58a3cc);});});}exports[_0x6cd6('0x17')]=function(_0xf68e35){var _0x4eb657=this;return new Promise(function(_0x19cf7e,_0x1edf30){return db[_0x6cd6('0x18')][_0x6cd6('0x19')]({'raw':_0xf68e35[_0x6cd6('0x1a')]?_0xf68e35[_0x6cd6('0x1a')][_0x6cd6('0x1b')]===undefined?!![]:![]:!![],'where':_0xf68e35['options']?_0xf68e35[_0x6cd6('0x1a')][_0x6cd6('0x1c')]||null:null,'attributes':_0xf68e35[_0x6cd6('0x1a')]?_0xf68e35[_0x6cd6('0x1a')]['attributes']||null:null,'limit':_0xf68e35[_0x6cd6('0x1a')]?_0xf68e35['options'][_0x6cd6('0x1d')]||null:null,'include':_0xf68e35['options']?_0xf68e35[_0x6cd6('0x1a')][_0x6cd6('0x1e')]?_[_0x6cd6('0x1f')](_0xf68e35[_0x6cd6('0x1a')]['include'],function(_0x46ae31){return{'model':db[_0x46ae31[_0x6cd6('0x20')]],'as':_0x46ae31['as'],'attributes':_0x46ae31[_0x6cd6('0x21')],'include':_0x46ae31[_0x6cd6('0x1e')]?_[_0x6cd6('0x1f')](_0x46ae31[_0x6cd6('0x1e')],function(_0x478029){return{'model':db[_0x478029['model']],'as':_0x478029['as'],'attributes':_0x478029[_0x6cd6('0x21')],'include':_0x478029[_0x6cd6('0x1e')]?_[_0x6cd6('0x1f')](_0x478029[_0x6cd6('0x1e')],function(_0x7bf8cc){return{'model':db[_0x7bf8cc[_0x6cd6('0x20')]],'as':_0x7bf8cc['as'],'attributes':_0x7bf8cc['attributes']};}):[]};}):[]};}):[]:[]})[_0x6cd6('0xc')](function(_0x558e83){logger['info']('GetDeskAccount',_0xf68e35);logger[_0x6cd6('0xf')]('GetDeskAccount',_0xf68e35,JSON[_0x6cd6('0x11')](_0x558e83));_0x19cf7e(_0x558e83);})[_0x6cd6('0x16')](function(_0x3ab2f8){logger['error'](_0x6cd6('0x17'),_0x3ab2f8[_0x6cd6('0x13')],_0xf68e35);_0x1edf30(_0x4eb657['error'](0x1f4,_0x3ab2f8[_0x6cd6('0x13')]));});});};exports['ShowDeskAccount']=function(_0x4064c0){var _0x2fff73=this;return new Promise(function(_0x11f396,_0x286bf1){return db[_0x6cd6('0x18')][_0x6cd6('0x22')]({'raw':_0x4064c0['options']?_0x4064c0[_0x6cd6('0x1a')][_0x6cd6('0x1b')]===undefined?!![]:![]:!![],'where':_0x4064c0[_0x6cd6('0x1a')]?_0x4064c0[_0x6cd6('0x1a')][_0x6cd6('0x1c')]||null:null,'attributes':_0x4064c0[_0x6cd6('0x1a')]?_0x4064c0[_0x6cd6('0x1a')]['attributes']||null:null,'include':_0x4064c0[_0x6cd6('0x1a')]?_0x4064c0[_0x6cd6('0x1a')]['include']?_[_0x6cd6('0x1f')](_0x4064c0[_0x6cd6('0x1a')]['include'],function(_0x45be54){return{'model':db[_0x45be54['model']],'as':_0x45be54['as'],'attributes':_0x45be54[_0x6cd6('0x21')],'include':_0x45be54['include']?_[_0x6cd6('0x1f')](_0x45be54[_0x6cd6('0x1e')],function(_0x72750f){return{'model':db[_0x72750f[_0x6cd6('0x20')]],'as':_0x72750f['as'],'attributes':_0x72750f['attributes'],'include':_0x72750f[_0x6cd6('0x1e')]?_['map'](_0x72750f[_0x6cd6('0x1e')],function(_0x49ba17){return{'model':db[_0x49ba17[_0x6cd6('0x20')]],'as':_0x49ba17['as'],'attributes':_0x49ba17['attributes']};}):[]};}):[]};}):[]:[]})[_0x6cd6('0xc')](function(_0x4b35f0){logger['info']('ShowDeskAccount',_0x4064c0);logger[_0x6cd6('0xf')](_0x6cd6('0x23'),_0x4064c0,JSON[_0x6cd6('0x11')](_0x4b35f0));_0x11f396(_0x4b35f0);})[_0x6cd6('0x16')](function(_0x44d593){logger[_0x6cd6('0x12')](_0x6cd6('0x23'),_0x44d593['message'],_0x4064c0);_0x286bf1(_0x2fff73[_0x6cd6('0x12')](0x1f4,_0x44d593[_0x6cd6('0x13')]));});});};