Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / mailInteraction / mailInteraction.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 _0xfcbe=['ids','omit','spread','AddTags','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','http','redis','socket.io-emitter','./mailInteraction.socket','request','then','info','MailInteraction,\x20%s,\x20%s','debug','MailInteraction,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','message','result','catch','MailInteraction','update','body','options','raw','where','attributes','UpdateMailInteraction','AddTagsToMailInteraction','find','addTags'];(function(_0x2dadb9,_0x42cfe6){var _0x2f0097=function(_0x21163f){while(--_0x21163f){_0x2dadb9['push'](_0x2dadb9['shift']());}};_0x2f0097(++_0x42cfe6);}(_0xfcbe,0x1b1));var _0xefcb=function(_0x39b070,_0x1855a3){_0x39b070=_0x39b070-0x0;var _0x25517d=_0xfcbe[_0x39b070];return _0x25517d;};'use strict';var _=require('lodash');var util=require(_0xefcb('0x0'));var moment=require(_0xefcb('0x1'));var BPromise=require(_0xefcb('0x2'));var rs=require(_0xefcb('0x3'));var fs=require('fs');var Redis=require(_0xefcb('0x4'));var db=require(_0xefcb('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0xefcb('0x6'))(_0xefcb('0x7'));var config=require('../../config/environment');var jayson=require('jayson/promise');var client=jayson['client'][_0xefcb('0x8')]({'port':0x232a});config['redis']=_['defaults'](config[_0xefcb('0x9')],{'host':'localhost','port':0x18eb});var socket=require(_0xefcb('0xa'))(new Redis(config[_0xefcb('0x9')]));require(_0xefcb('0xb'))['register'](socket);function respondWithRpcPromise(_0x35630e,_0x35f070,_0x527170){return new BPromise(function(_0x533ee5,_0x326270){return client[_0xefcb('0xc')](_0x35630e,_0x527170)[_0xefcb('0xd')](function(_0x3f9204){logger[_0xefcb('0xe')](_0xefcb('0xf'),_0x35f070,'request\x20sent');logger[_0xefcb('0x10')](_0xefcb('0x11'),_0x35f070,_0xefcb('0x12'),JSON[_0xefcb('0x13')](_0x3f9204));if(_0x3f9204[_0xefcb('0x14')]){if(_0x3f9204['error']['code']===0x1f4){logger[_0xefcb('0x14')](_0xefcb('0xf'),_0x35f070,_0x3f9204['error'][_0xefcb('0x15')]);return _0x326270(_0x3f9204['error'][_0xefcb('0x15')]);}logger['error'](_0xefcb('0xf'),_0x35f070,_0x3f9204[_0xefcb('0x14')][_0xefcb('0x15')]);return _0x533ee5(_0x3f9204[_0xefcb('0x14')][_0xefcb('0x15')]);}else{logger[_0xefcb('0xe')]('MailInteraction,\x20%s,\x20%s',_0x35f070,_0xefcb('0x12'));_0x533ee5(_0x3f9204[_0xefcb('0x16')][_0xefcb('0x15')]);}})[_0xefcb('0x17')](function(_0x1bd57c){logger[_0xefcb('0x14')](_0xefcb('0xf'),_0x35f070,_0x1bd57c);_0x326270(_0x1bd57c);});});}exports['UpdateMailInteraction']=function(_0x39ab04){var _0x3b7509=this;return new Promise(function(_0x5695b4,_0x12a93f){return db[_0xefcb('0x18')][_0xefcb('0x19')](_0x39ab04[_0xefcb('0x1a')],{'raw':_0x39ab04[_0xefcb('0x1b')]?_0x39ab04['options'][_0xefcb('0x1c')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x39ab04[_0xefcb('0x1b')]?_0x39ab04[_0xefcb('0x1b')][_0xefcb('0x1d')]||null:null,'attributes':_0x39ab04[_0xefcb('0x1b')]?_0x39ab04[_0xefcb('0x1b')][_0xefcb('0x1e')]||null:null,'limit':_0x39ab04[_0xefcb('0x1b')]?_0x39ab04['options']['limit']||null:null})['then'](function(_0x104212){logger[_0xefcb('0xe')](_0xefcb('0x1f'),_0x39ab04);logger[_0xefcb('0x10')](_0xefcb('0x1f'),_0x39ab04,JSON[_0xefcb('0x13')](_0x104212));_0x5695b4(_0x104212);})[_0xefcb('0x17')](function(_0x52ce86){logger[_0xefcb('0x14')](_0xefcb('0x1f'),_0x52ce86[_0xefcb('0x15')],_0x39ab04);_0x12a93f(_0x3b7509[_0xefcb('0x14')](0x1f4,_0x52ce86[_0xefcb('0x15')]));});});};exports[_0xefcb('0x20')]=function(_0x16757b){return new Promise(function(_0x36521c,_0x1c7ee1){return db[_0xefcb('0x18')][_0xefcb('0x21')]({'where':_0x16757b[_0xefcb('0x1b')]?_0x16757b[_0xefcb('0x1b')][_0xefcb('0x1d')]||null:null})[_0xefcb('0xd')](function(_0x518447){if(_0x518447){return _0x518447[_0xefcb('0x22')](_0x16757b[_0xefcb('0x1a')][_0xefcb('0x23')],_[_0xefcb('0x24')](_0x16757b[_0xefcb('0x1a')],[_0xefcb('0x23'),'id'])||{});}})[_0xefcb('0x25')](function(_0x5a436c){logger['info'](_0xefcb('0x26'),_0x16757b);logger[_0xefcb('0x10')]('AddTags',_0x16757b,JSON[_0xefcb('0x13')](_0x5a436c));_0x36521c(_0x5a436c);})[_0xefcb('0x17')](function(_0x3e7da7){logger['error'](_0xefcb('0x26'),_0x3e7da7[_0xefcb('0x15')],_0x16757b);_0x1c7ee1(_this[_0xefcb('0x14')](0x1f4,_0x3e7da7['message']));});});};