Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / mailApplication / mailApplication.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 _0xed22=['MailApplication,\x20%s,\x20%s','request\x20sent','debug','MailApplication,\x20%s,\x20%s,\x20%s','stringify','error','message','info','result','catch','UpdateMailApplication','MailApplication','body','options','where','attributes','limit','util','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','request','then'];(function(_0x2293da,_0x3a3686){var _0x11c5cd=function(_0x3e43f0){while(--_0x3e43f0){_0x2293da['push'](_0x2293da['shift']());}};_0x11c5cd(++_0x3a3686);}(_0xed22,0x101));var _0x2ed2=function(_0x501078,_0x5bb1e9){_0x501078=_0x501078-0x0;var _0x18eaac=_0xed22[_0x501078];return _0x18eaac;};'use strict';var _=require('lodash');var util=require(_0x2ed2('0x0'));var moment=require('moment');var BPromise=require('bluebird');var rs=require(_0x2ed2('0x1'));var fs=require('fs');var Redis=require(_0x2ed2('0x2'));var db=require(_0x2ed2('0x3'))['db'];var utils=require(_0x2ed2('0x4'));var logger=require(_0x2ed2('0x5'))(_0x2ed2('0x6'));var config=require(_0x2ed2('0x7'));var jayson=require(_0x2ed2('0x8'));var client=jayson[_0x2ed2('0x9')][_0x2ed2('0xa')]({'port':0x232a});function respondWithRpcPromise(_0xd6db37,_0xd7eb08,_0x2fb359){return new BPromise(function(_0x2becf6,_0x1d0d9a){return client[_0x2ed2('0xb')](_0xd6db37,_0x2fb359)[_0x2ed2('0xc')](function(_0x69125d){logger['info'](_0x2ed2('0xd'),_0xd7eb08,_0x2ed2('0xe'));logger[_0x2ed2('0xf')](_0x2ed2('0x10'),_0xd7eb08,'request\x20sent',JSON[_0x2ed2('0x11')](_0x69125d));if(_0x69125d[_0x2ed2('0x12')]){if(_0x69125d[_0x2ed2('0x12')]['code']===0x1f4){logger[_0x2ed2('0x12')](_0x2ed2('0xd'),_0xd7eb08,_0x69125d[_0x2ed2('0x12')][_0x2ed2('0x13')]);return _0x1d0d9a(_0x69125d[_0x2ed2('0x12')][_0x2ed2('0x13')]);}logger[_0x2ed2('0x12')](_0x2ed2('0xd'),_0xd7eb08,_0x69125d['error'][_0x2ed2('0x13')]);return _0x2becf6(_0x69125d[_0x2ed2('0x12')][_0x2ed2('0x13')]);}else{logger[_0x2ed2('0x14')](_0x2ed2('0xd'),_0xd7eb08,_0x2ed2('0xe'));_0x2becf6(_0x69125d[_0x2ed2('0x15')][_0x2ed2('0x13')]);}})[_0x2ed2('0x16')](function(_0x1b7a9f){logger[_0x2ed2('0x12')](_0x2ed2('0xd'),_0xd7eb08,_0x1b7a9f);_0x1d0d9a(_0x1b7a9f);});});}exports[_0x2ed2('0x17')]=function(_0x1b5456){var _0x446644=this;return new Promise(function(_0x43e81e,_0x1d0471){return db[_0x2ed2('0x18')]['update'](_0x1b5456[_0x2ed2('0x19')],{'raw':_0x1b5456[_0x2ed2('0x1a')]?_0x1b5456['options']['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x1b5456[_0x2ed2('0x1a')]?_0x1b5456[_0x2ed2('0x1a')][_0x2ed2('0x1b')]||null:null,'attributes':_0x1b5456['options']?_0x1b5456[_0x2ed2('0x1a')][_0x2ed2('0x1c')]||null:null,'limit':_0x1b5456[_0x2ed2('0x1a')]?_0x1b5456['options'][_0x2ed2('0x1d')]||null:null})[_0x2ed2('0xc')](function(_0x4c0be7){logger[_0x2ed2('0x14')]('UpdateMailApplication',_0x1b5456);logger[_0x2ed2('0xf')](_0x2ed2('0x17'),_0x1b5456,JSON[_0x2ed2('0x11')](_0x4c0be7));_0x43e81e(_0x4c0be7);})[_0x2ed2('0x16')](function(_0x487978){logger['error'](_0x2ed2('0x17'),_0x487978['message'],_0x1b5456);_0x1d0471(_0x446644[_0x2ed2('0x12')](0x1f4,_0x487978[_0x2ed2('0x13')]));});});};