Built motion from commit (unavailable).|2.5.21
[motion2.git] / server / api / attachment / attachment.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 _0x7b6f=['jayson/promise','http','request','then','info','Attachment,\x20%s,\x20%s','request\x20sent','Attachment,\x20%s,\x20%s,\x20%s','error','code','message','result','catch','CreateAttachment','Attachment','create','body','options','raw','debug','stringify','bluebird','../../config/utils','rpc','../../config/environment'];(function(_0x110150,_0xc355d1){var _0x59b30b=function(_0x2167b2){while(--_0x2167b2){_0x110150['push'](_0x110150['shift']());}};_0x59b30b(++_0xc355d1);}(_0x7b6f,0x18c));var _0xf7b6=function(_0x4548d5,_0x50239a){_0x4548d5=_0x4548d5-0x0;var _0x10fb5b=_0x7b6f[_0x4548d5];return _0x10fb5b;};'use strict';var _=require('lodash');var util=require('util');var moment=require('moment');var BPromise=require(_0xf7b6('0x0'));var rs=require('randomstring');var fs=require('fs');var Redis=require('ioredis');var db=require('../../mysqldb')['db'];var utils=require(_0xf7b6('0x1'));var logger=require('../../config/logger')(_0xf7b6('0x2'));var config=require(_0xf7b6('0x3'));var jayson=require(_0xf7b6('0x4'));var client=jayson['client'][_0xf7b6('0x5')]({'port':0x232a});function respondWithRpcPromise(_0x16bcb0,_0x5c1c73,_0x14ec4c){return new BPromise(function(_0x1fcecc,_0xf11497){return client[_0xf7b6('0x6')](_0x16bcb0,_0x14ec4c)[_0xf7b6('0x7')](function(_0x24b707){logger[_0xf7b6('0x8')](_0xf7b6('0x9'),_0x5c1c73,_0xf7b6('0xa'));logger['debug'](_0xf7b6('0xb'),_0x5c1c73,_0xf7b6('0xa'),JSON['stringify'](_0x24b707));if(_0x24b707[_0xf7b6('0xc')]){if(_0x24b707[_0xf7b6('0xc')][_0xf7b6('0xd')]===0x1f4){logger[_0xf7b6('0xc')]('Attachment,\x20%s,\x20%s',_0x5c1c73,_0x24b707[_0xf7b6('0xc')][_0xf7b6('0xe')]);return _0xf11497(_0x24b707[_0xf7b6('0xc')][_0xf7b6('0xe')]);}logger[_0xf7b6('0xc')](_0xf7b6('0x9'),_0x5c1c73,_0x24b707[_0xf7b6('0xc')][_0xf7b6('0xe')]);return _0x1fcecc(_0x24b707[_0xf7b6('0xc')][_0xf7b6('0xe')]);}else{logger[_0xf7b6('0x8')](_0xf7b6('0x9'),_0x5c1c73,_0xf7b6('0xa'));_0x1fcecc(_0x24b707[_0xf7b6('0xf')][_0xf7b6('0xe')]);}})[_0xf7b6('0x10')](function(_0x3e8cd9){logger[_0xf7b6('0xc')](_0xf7b6('0x9'),_0x5c1c73,_0x3e8cd9);_0xf11497(_0x3e8cd9);});});}exports[_0xf7b6('0x11')]=function(_0x3fb2da){var _0x4e90c4=this;return new Promise(function(_0x2544de,_0x535bed){return db[_0xf7b6('0x12')][_0xf7b6('0x13')](_0x3fb2da[_0xf7b6('0x14')],{'raw':_0x3fb2da['options']?_0x3fb2da[_0xf7b6('0x15')][_0xf7b6('0x16')]===undefined?!![]:![]:!![]})[_0xf7b6('0x7')](function(_0x3b68c7){logger[_0xf7b6('0x8')](_0xf7b6('0x11'),_0x3fb2da);logger[_0xf7b6('0x17')]('CreateAttachment',_0x3fb2da,JSON[_0xf7b6('0x18')](_0x3b68c7));_0x2544de(_0x3b68c7);})[_0xf7b6('0x10')](function(_0x25ce18){logger[_0xf7b6('0xc')](_0xf7b6('0x11'),_0x25ce18[_0xf7b6('0xe')],_0x3fb2da);_0x535bed(_0x4e90c4[_0xf7b6('0xc')](0x1f4,_0x25ce18['message']));});});};