Built motion from commit (unavailable).|2.5.4
[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 _0xf996=['../../config/environment','jayson/promise','client','http','redis','defaults','socket.io-emitter','./mailInteraction.socket','register','request','then','info','MailInteraction,\x20%s,\x20%s,\x20%s','request\x20sent','stringify','error','code','MailInteraction,\x20%s,\x20%s','message','result','catch','UpdateMailInteraction','MailInteraction','options','where','attributes','limit','debug','AddTagsToMailInteraction','addTags','ids','omit','spread','AddTags','lodash','util','moment','randomstring','../../config/utils','../../config/logger','rpc'];(function(_0x2c8543,_0x2c2b3e){var _0x516ba2=function(_0x251bbb){while(--_0x251bbb){_0x2c8543['push'](_0x2c8543['shift']());}};_0x516ba2(++_0x2c2b3e);}(_0xf996,0x74));var _0x6f99=function(_0xfb7fd4,_0xdf44ed){_0xfb7fd4=_0xfb7fd4-0x0;var _0x12b4c4=_0xf996[_0xfb7fd4];return _0x12b4c4;};'use strict';var _=require(_0x6f99('0x0'));var util=require(_0x6f99('0x1'));var moment=require(_0x6f99('0x2'));var BPromise=require('bluebird');var rs=require(_0x6f99('0x3'));var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0x6f99('0x4'));var logger=require(_0x6f99('0x5'))(_0x6f99('0x6'));var config=require(_0x6f99('0x7'));var jayson=require(_0x6f99('0x8'));var client=jayson[_0x6f99('0x9')][_0x6f99('0xa')]({'port':0x232a});config[_0x6f99('0xb')]=_[_0x6f99('0xc')](config[_0x6f99('0xb')],{'host':'localhost','port':0x18eb});var socket=require(_0x6f99('0xd'))(new Redis(config['redis']));require(_0x6f99('0xe'))[_0x6f99('0xf')](socket);function respondWithRpcPromise(_0x41f436,_0x161b64,_0xf42ba3){return new BPromise(function(_0x2edd9,_0x43b5c0){return client[_0x6f99('0x10')](_0x41f436,_0xf42ba3)[_0x6f99('0x11')](function(_0x509929){logger[_0x6f99('0x12')]('MailInteraction,\x20%s,\x20%s',_0x161b64,'request\x20sent');logger['debug'](_0x6f99('0x13'),_0x161b64,_0x6f99('0x14'),JSON[_0x6f99('0x15')](_0x509929));if(_0x509929[_0x6f99('0x16')]){if(_0x509929[_0x6f99('0x16')][_0x6f99('0x17')]===0x1f4){logger[_0x6f99('0x16')](_0x6f99('0x18'),_0x161b64,_0x509929[_0x6f99('0x16')][_0x6f99('0x19')]);return _0x43b5c0(_0x509929[_0x6f99('0x16')][_0x6f99('0x19')]);}logger['error'](_0x6f99('0x18'),_0x161b64,_0x509929[_0x6f99('0x16')]['message']);return _0x2edd9(_0x509929['error'][_0x6f99('0x19')]);}else{logger['info'](_0x6f99('0x18'),_0x161b64,_0x6f99('0x14'));_0x2edd9(_0x509929[_0x6f99('0x1a')][_0x6f99('0x19')]);}})[_0x6f99('0x1b')](function(_0x5bfb51){logger[_0x6f99('0x16')]('MailInteraction,\x20%s,\x20%s',_0x161b64,_0x5bfb51);_0x43b5c0(_0x5bfb51);});});}exports[_0x6f99('0x1c')]=function(_0x286edb){var _0x4cfa68=this;return new Promise(function(_0x26cd36,_0x1dc9e5){return db[_0x6f99('0x1d')]['update'](_0x286edb['body'],{'raw':_0x286edb[_0x6f99('0x1e')]?_0x286edb[_0x6f99('0x1e')]['raw']===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x286edb['options']?_0x286edb[_0x6f99('0x1e')][_0x6f99('0x1f')]||null:null,'attributes':_0x286edb[_0x6f99('0x1e')]?_0x286edb[_0x6f99('0x1e')][_0x6f99('0x20')]||null:null,'limit':_0x286edb[_0x6f99('0x1e')]?_0x286edb[_0x6f99('0x1e')][_0x6f99('0x21')]||null:null})[_0x6f99('0x11')](function(_0x41a60b){logger[_0x6f99('0x12')](_0x6f99('0x1c'),_0x286edb);logger[_0x6f99('0x22')](_0x6f99('0x1c'),_0x286edb,JSON['stringify'](_0x41a60b));_0x26cd36(_0x41a60b);})[_0x6f99('0x1b')](function(_0x201070){logger['error']('UpdateMailInteraction',_0x201070[_0x6f99('0x19')],_0x286edb);_0x1dc9e5(_0x4cfa68[_0x6f99('0x16')](0x1f4,_0x201070['message']));});});};exports[_0x6f99('0x23')]=function(_0x3e56f5){return new Promise(function(_0x53ab0e,_0x45fe22){return db[_0x6f99('0x1d')]['find']({'where':_0x3e56f5[_0x6f99('0x1e')]?_0x3e56f5[_0x6f99('0x1e')][_0x6f99('0x1f')]||null:null})[_0x6f99('0x11')](function(_0x292a29){if(_0x292a29){return _0x292a29[_0x6f99('0x24')](_0x3e56f5['body'][_0x6f99('0x25')],_[_0x6f99('0x26')](_0x3e56f5['body'],['ids','id'])||{});}})[_0x6f99('0x27')](function(_0x33ab31){logger[_0x6f99('0x12')](_0x6f99('0x28'),_0x3e56f5);logger[_0x6f99('0x22')](_0x6f99('0x28'),_0x3e56f5,JSON['stringify'](_0x33ab31));_0x53ab0e(_0x33ab31);})['catch'](function(_0x269d9b){logger[_0x6f99('0x16')](_0x6f99('0x28'),_0x269d9b[_0x6f99('0x19')],_0x3e56f5);_0x45fe22(_this[_0x6f99('0x16')](0x1f4,_0x269d9b[_0x6f99('0x19')]));});});};