b55fc4cf89de10fcfcba5f59a5a92330b2bcc2c0
[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 _0xac8f=['bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','rpc','../../config/environment','jayson/promise','client','http','redis','defaults','socket.io-emitter','./mailInteraction.socket','request','then','info','MailInteraction,\x20%s,\x20%s','request\x20sent','debug','MailInteraction,\x20%s,\x20%s,\x20%s','error','code','message','catch','UpdateMailInteraction','MailInteraction','update','options','raw','attributes','limit','stringify','find','where','body','omit','spread','AddTags','lodash','util','moment'];(function(_0x286726,_0x20a337){var _0xcd4fe9=function(_0x4d7da6){while(--_0x4d7da6){_0x286726['push'](_0x286726['shift']());}};_0xcd4fe9(++_0x20a337);}(_0xac8f,0x1d6));var _0xfac8=function(_0x1d70db,_0x142b63){_0x1d70db=_0x1d70db-0x0;var _0x3060c6=_0xac8f[_0x1d70db];return _0x3060c6;};'use strict';var _=require(_0xfac8('0x0'));var util=require(_0xfac8('0x1'));var moment=require(_0xfac8('0x2'));var BPromise=require(_0xfac8('0x3'));var rs=require(_0xfac8('0x4'));var fs=require('fs');var Redis=require(_0xfac8('0x5'));var db=require(_0xfac8('0x6'))['db'];var utils=require(_0xfac8('0x7'));var logger=require(_0xfac8('0x8'))(_0xfac8('0x9'));var config=require(_0xfac8('0xa'));var jayson=require(_0xfac8('0xb'));var client=jayson[_0xfac8('0xc')][_0xfac8('0xd')]({'port':0x232a});config[_0xfac8('0xe')]=_[_0xfac8('0xf')](config[_0xfac8('0xe')],{'host':'localhost','port':0x18eb});var socket=require(_0xfac8('0x10'))(new Redis(config[_0xfac8('0xe')]));require(_0xfac8('0x11'))['register'](socket);function respondWithRpcPromise(_0x5f590c,_0x3afe4d,_0x361986){return new BPromise(function(_0x343e10,_0x4be757){return client[_0xfac8('0x12')](_0x5f590c,_0x361986)[_0xfac8('0x13')](function(_0x2bc6fc){logger[_0xfac8('0x14')](_0xfac8('0x15'),_0x3afe4d,_0xfac8('0x16'));logger[_0xfac8('0x17')](_0xfac8('0x18'),_0x3afe4d,_0xfac8('0x16'),JSON['stringify'](_0x2bc6fc));if(_0x2bc6fc[_0xfac8('0x19')]){if(_0x2bc6fc['error'][_0xfac8('0x1a')]===0x1f4){logger[_0xfac8('0x19')]('MailInteraction,\x20%s,\x20%s',_0x3afe4d,_0x2bc6fc['error'][_0xfac8('0x1b')]);return _0x4be757(_0x2bc6fc[_0xfac8('0x19')]['message']);}logger[_0xfac8('0x19')](_0xfac8('0x15'),_0x3afe4d,_0x2bc6fc[_0xfac8('0x19')][_0xfac8('0x1b')]);return _0x343e10(_0x2bc6fc[_0xfac8('0x19')][_0xfac8('0x1b')]);}else{logger[_0xfac8('0x14')](_0xfac8('0x15'),_0x3afe4d,_0xfac8('0x16'));_0x343e10(_0x2bc6fc['result'][_0xfac8('0x1b')]);}})[_0xfac8('0x1c')](function(_0x202b49){logger[_0xfac8('0x19')](_0xfac8('0x15'),_0x3afe4d,_0x202b49);_0x4be757(_0x202b49);});});}exports[_0xfac8('0x1d')]=function(_0x2ca3f0){var _0x1eae50=this;return new Promise(function(_0x47da57,_0x17a4f0){return db[_0xfac8('0x1e')][_0xfac8('0x1f')](_0x2ca3f0['body'],{'raw':_0x2ca3f0[_0xfac8('0x20')]?_0x2ca3f0[_0xfac8('0x20')][_0xfac8('0x21')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x2ca3f0[_0xfac8('0x20')]?_0x2ca3f0['options']['where']||null:null,'attributes':_0x2ca3f0[_0xfac8('0x20')]?_0x2ca3f0[_0xfac8('0x20')][_0xfac8('0x22')]||null:null,'limit':_0x2ca3f0['options']?_0x2ca3f0[_0xfac8('0x20')][_0xfac8('0x23')]||null:null})[_0xfac8('0x13')](function(_0x1491c7){logger[_0xfac8('0x14')]('UpdateMailInteraction',_0x2ca3f0);logger[_0xfac8('0x17')](_0xfac8('0x1d'),_0x2ca3f0,JSON[_0xfac8('0x24')](_0x1491c7));_0x47da57(_0x1491c7);})[_0xfac8('0x1c')](function(_0x5206e9){logger[_0xfac8('0x19')](_0xfac8('0x1d'),_0x5206e9[_0xfac8('0x1b')],_0x2ca3f0);_0x17a4f0(_0x1eae50[_0xfac8('0x19')](0x1f4,_0x5206e9[_0xfac8('0x1b')]));});});};exports['AddTagsToMailInteraction']=function(_0x5a2638){return new Promise(function(_0x54c968,_0x154d1b){return db['MailInteraction'][_0xfac8('0x25')]({'where':_0x5a2638[_0xfac8('0x20')]?_0x5a2638[_0xfac8('0x20')][_0xfac8('0x26')]||null:null})[_0xfac8('0x13')](function(_0x18ad24){if(_0x18ad24){return _0x18ad24['addTags'](_0x5a2638[_0xfac8('0x27')]['ids'],_[_0xfac8('0x28')](_0x5a2638['body'],['ids','id'])||{});}})[_0xfac8('0x29')](function(_0xe44f0b){logger[_0xfac8('0x14')]('AddTags',_0x5a2638);logger['debug'](_0xfac8('0x2a'),_0x5a2638,JSON[_0xfac8('0x24')](_0xe44f0b));_0x54c968(_0xe44f0b);})[_0xfac8('0x1c')](function(_0x21b28c){logger[_0xfac8('0x19')](_0xfac8('0x2a'),_0x21b28c[_0xfac8('0x1b')],_0x5a2638);_0x154d1b(_this['error'](0x1f4,_0x21b28c[_0xfac8('0x1b')]));});});};