Built motion from commit c116dc8b.|2.6.30
[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 _0x30cb=['MailInteraction,\x20%s,\x20%s','message','info','result','catch','UpdateMailInteraction','MailInteraction','update','body','options','raw','where','attributes','limit','AddTagsToMailInteraction','addTags','ids','omit','spread','AddTags','lodash','util','moment','randomstring','ioredis','../../mysqldb','../../config/utils','rpc','jayson/promise','client','redis','localhost','register','request','then','request\x20sent','debug','MailInteraction,\x20%s,\x20%s,\x20%s','stringify','error','code'];(function(_0x29d8ee,_0x874717){var _0x47cdb2=function(_0xec7833){while(--_0xec7833){_0x29d8ee['push'](_0x29d8ee['shift']());}};_0x47cdb2(++_0x874717);}(_0x30cb,0xb8));var _0xb30c=function(_0x193dad,_0x38d83d){_0x193dad=_0x193dad-0x0;var _0x5eafa4=_0x30cb[_0x193dad];return _0x5eafa4;};'use strict';var _=require(_0xb30c('0x0'));var util=require(_0xb30c('0x1'));var moment=require(_0xb30c('0x2'));var BPromise=require('bluebird');var rs=require(_0xb30c('0x3'));var fs=require('fs');var Redis=require(_0xb30c('0x4'));var db=require(_0xb30c('0x5'))['db'];var utils=require(_0xb30c('0x6'));var logger=require('../../config/logger')(_0xb30c('0x7'));var config=require('../../config/environment');var jayson=require(_0xb30c('0x8'));var client=jayson[_0xb30c('0x9')]['http']({'port':0x232a});config[_0xb30c('0xa')]=_['defaults'](config[_0xb30c('0xa')],{'host':_0xb30c('0xb'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xb30c('0xa')]));require('./mailInteraction.socket')[_0xb30c('0xc')](socket);function respondWithRpcPromise(_0x2ac821,_0x10036d,_0x1ac748){return new BPromise(function(_0x5170f0,_0x3449f1){return client[_0xb30c('0xd')](_0x2ac821,_0x1ac748)[_0xb30c('0xe')](function(_0x2089ef){logger['info']('MailInteraction,\x20%s,\x20%s',_0x10036d,_0xb30c('0xf'));logger[_0xb30c('0x10')](_0xb30c('0x11'),_0x10036d,'request\x20sent',JSON[_0xb30c('0x12')](_0x2089ef));if(_0x2089ef[_0xb30c('0x13')]){if(_0x2089ef[_0xb30c('0x13')][_0xb30c('0x14')]===0x1f4){logger[_0xb30c('0x13')](_0xb30c('0x15'),_0x10036d,_0x2089ef['error'][_0xb30c('0x16')]);return _0x3449f1(_0x2089ef[_0xb30c('0x13')][_0xb30c('0x16')]);}logger[_0xb30c('0x13')](_0xb30c('0x15'),_0x10036d,_0x2089ef[_0xb30c('0x13')]['message']);return _0x5170f0(_0x2089ef[_0xb30c('0x13')][_0xb30c('0x16')]);}else{logger[_0xb30c('0x17')](_0xb30c('0x15'),_0x10036d,_0xb30c('0xf'));_0x5170f0(_0x2089ef[_0xb30c('0x18')][_0xb30c('0x16')]);}})[_0xb30c('0x19')](function(_0x3f6a09){logger[_0xb30c('0x13')](_0xb30c('0x15'),_0x10036d,_0x3f6a09);_0x3449f1(_0x3f6a09);});});}exports[_0xb30c('0x1a')]=function(_0x112d4c){var _0xa733fb=this;return new Promise(function(_0xa2a6ee,_0x3477cd){return db[_0xb30c('0x1b')][_0xb30c('0x1c')](_0x112d4c[_0xb30c('0x1d')],{'raw':_0x112d4c[_0xb30c('0x1e')]?_0x112d4c[_0xb30c('0x1e')][_0xb30c('0x1f')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x112d4c[_0xb30c('0x1e')]?_0x112d4c['options'][_0xb30c('0x20')]||null:null,'attributes':_0x112d4c['options']?_0x112d4c[_0xb30c('0x1e')][_0xb30c('0x21')]||null:null,'limit':_0x112d4c[_0xb30c('0x1e')]?_0x112d4c[_0xb30c('0x1e')][_0xb30c('0x22')]||null:null})[_0xb30c('0xe')](function(_0x45668f){logger[_0xb30c('0x17')](_0xb30c('0x1a'),_0x112d4c);logger[_0xb30c('0x10')]('UpdateMailInteraction',_0x112d4c,JSON[_0xb30c('0x12')](_0x45668f));_0xa2a6ee(_0x45668f);})['catch'](function(_0x13def5){logger['error']('UpdateMailInteraction',_0x13def5[_0xb30c('0x16')],_0x112d4c);_0x3477cd(_0xa733fb[_0xb30c('0x13')](0x1f4,_0x13def5['message']));});});};exports[_0xb30c('0x23')]=function(_0x2c11c1){return new Promise(function(_0x34946b,_0x48683e){return db[_0xb30c('0x1b')]['find']({'where':_0x2c11c1['options']?_0x2c11c1['options'][_0xb30c('0x20')]||null:null})[_0xb30c('0xe')](function(_0x4b81e2){if(_0x4b81e2){return _0x4b81e2[_0xb30c('0x24')](_0x2c11c1['body'][_0xb30c('0x25')],_[_0xb30c('0x26')](_0x2c11c1['body'],[_0xb30c('0x25'),'id'])||{});}})[_0xb30c('0x27')](function(_0x265f26){logger[_0xb30c('0x17')](_0xb30c('0x28'),_0x2c11c1);logger[_0xb30c('0x10')](_0xb30c('0x28'),_0x2c11c1,JSON[_0xb30c('0x12')](_0x265f26));_0x34946b(_0x265f26);})[_0xb30c('0x19')](function(_0x24a3b6){logger[_0xb30c('0x13')](_0xb30c('0x28'),_0x24a3b6['message'],_0x2c11c1);_0x48683e(_this[_0xb30c('0x13')](0x1f4,_0x24a3b6['message']));});});};