Built motion from commit (unavailable).|2.5.26
[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 _0x09dd=['request\x20sent','MailInteraction,\x20%s,\x20%s,\x20%s','stringify','error','message','result','catch','update','options','raw','where','attributes','limit','UpdateMailInteraction','debug','AddTagsToMailInteraction','find','addTags','omit','body','ids','spread','AddTags','lodash','util','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/utils','../../config/logger','../../config/environment','client','redis','register','request','then','info','MailInteraction,\x20%s,\x20%s'];(function(_0x3ec0f3,_0xda8dd){var _0x993a12=function(_0x11175d){while(--_0x11175d){_0x3ec0f3['push'](_0x3ec0f3['shift']());}};_0x993a12(++_0xda8dd);}(_0x09dd,0xb7));var _0xd09d=function(_0x5b2d38,_0x3c461a){_0x5b2d38=_0x5b2d38-0x0;var _0x2f7806=_0x09dd[_0x5b2d38];return _0x2f7806;};'use strict';var _=require(_0xd09d('0x0'));var util=require(_0xd09d('0x1'));var moment=require(_0xd09d('0x2'));var BPromise=require(_0xd09d('0x3'));var rs=require(_0xd09d('0x4'));var fs=require('fs');var Redis=require(_0xd09d('0x5'));var db=require(_0xd09d('0x6'))['db'];var utils=require(_0xd09d('0x7'));var logger=require(_0xd09d('0x8'))('rpc');var config=require(_0xd09d('0x9'));var jayson=require('jayson/promise');var client=jayson[_0xd09d('0xa')]['http']({'port':0x232a});config[_0xd09d('0xb')]=_['defaults'](config['redis'],{'host':'localhost','port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config[_0xd09d('0xb')]));require('./mailInteraction.socket')[_0xd09d('0xc')](socket);function respondWithRpcPromise(_0x2566ce,_0x50692e,_0x5f1a89){return new BPromise(function(_0x5f1205,_0x477658){return client[_0xd09d('0xd')](_0x2566ce,_0x5f1a89)[_0xd09d('0xe')](function(_0x755ea1){logger[_0xd09d('0xf')](_0xd09d('0x10'),_0x50692e,_0xd09d('0x11'));logger['debug'](_0xd09d('0x12'),_0x50692e,_0xd09d('0x11'),JSON[_0xd09d('0x13')](_0x755ea1));if(_0x755ea1[_0xd09d('0x14')]){if(_0x755ea1[_0xd09d('0x14')]['code']===0x1f4){logger[_0xd09d('0x14')](_0xd09d('0x10'),_0x50692e,_0x755ea1[_0xd09d('0x14')][_0xd09d('0x15')]);return _0x477658(_0x755ea1[_0xd09d('0x14')]['message']);}logger[_0xd09d('0x14')](_0xd09d('0x10'),_0x50692e,_0x755ea1['error'][_0xd09d('0x15')]);return _0x5f1205(_0x755ea1[_0xd09d('0x14')][_0xd09d('0x15')]);}else{logger[_0xd09d('0xf')](_0xd09d('0x10'),_0x50692e,_0xd09d('0x11'));_0x5f1205(_0x755ea1[_0xd09d('0x16')][_0xd09d('0x15')]);}})[_0xd09d('0x17')](function(_0x175920){logger['error'](_0xd09d('0x10'),_0x50692e,_0x175920);_0x477658(_0x175920);});});}exports['UpdateMailInteraction']=function(_0x700b25){var _0x243f9b=this;return new Promise(function(_0x43018b,_0xb92975){return db['MailInteraction'][_0xd09d('0x18')](_0x700b25['body'],{'raw':_0x700b25['options']?_0x700b25[_0xd09d('0x19')][_0xd09d('0x1a')]===undefined?!![]:![]:!![],'individualHooks':!![],'where':_0x700b25['options']?_0x700b25[_0xd09d('0x19')][_0xd09d('0x1b')]||null:null,'attributes':_0x700b25[_0xd09d('0x19')]?_0x700b25[_0xd09d('0x19')][_0xd09d('0x1c')]||null:null,'limit':_0x700b25[_0xd09d('0x19')]?_0x700b25[_0xd09d('0x19')][_0xd09d('0x1d')]||null:null})[_0xd09d('0xe')](function(_0x12997c){logger[_0xd09d('0xf')](_0xd09d('0x1e'),_0x700b25);logger[_0xd09d('0x1f')](_0xd09d('0x1e'),_0x700b25,JSON[_0xd09d('0x13')](_0x12997c));_0x43018b(_0x12997c);})['catch'](function(_0x5db559){logger['error']('UpdateMailInteraction',_0x5db559[_0xd09d('0x15')],_0x700b25);_0xb92975(_0x243f9b[_0xd09d('0x14')](0x1f4,_0x5db559[_0xd09d('0x15')]));});});};exports[_0xd09d('0x20')]=function(_0x50b800){return new Promise(function(_0x3ac9ab,_0xdb4063){return db['MailInteraction'][_0xd09d('0x21')]({'where':_0x50b800['options']?_0x50b800[_0xd09d('0x19')][_0xd09d('0x1b')]||null:null})['then'](function(_0x6a5562){if(_0x6a5562){return _0x6a5562[_0xd09d('0x22')](_0x50b800['body']['ids'],_[_0xd09d('0x23')](_0x50b800[_0xd09d('0x24')],[_0xd09d('0x25'),'id'])||{});}})[_0xd09d('0x26')](function(_0x39754c){logger[_0xd09d('0xf')](_0xd09d('0x27'),_0x50b800);logger[_0xd09d('0x1f')](_0xd09d('0x27'),_0x50b800,JSON[_0xd09d('0x13')](_0x39754c));_0x3ac9ab(_0x39754c);})[_0xd09d('0x17')](function(_0x2bba85){logger['error'](_0xd09d('0x27'),_0x2bba85[_0xd09d('0x15')],_0x50b800);_0xdb4063(_this[_0xd09d('0x14')](0x1f4,_0x2bba85[_0xd09d('0x15')]));});});};