Built motion from commit (unavailable).|2.5.9
[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 _0x92b5=['jayson/promise','client','http','request','then','info','Attachment,\x20%s,\x20%s','request\x20sent','debug','Attachment,\x20%s,\x20%s,\x20%s','stringify','error','code','message','result','catch','Attachment','create','options','raw','CreateAttachment','lodash','bluebird','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment'];(function(_0x948a74,_0x47e51a){var _0x1ab681=function(_0x46053e){while(--_0x46053e){_0x948a74['push'](_0x948a74['shift']());}};_0x1ab681(++_0x47e51a);}(_0x92b5,0x12d));var _0x592b=function(_0x618414,_0x1a7a60){_0x618414=_0x618414-0x0;var _0x21c19a=_0x92b5[_0x618414];return _0x21c19a;};'use strict';var _=require(_0x592b('0x0'));var util=require('util');var moment=require('moment');var BPromise=require(_0x592b('0x1'));var rs=require('randomstring');var fs=require('fs');var Redis=require(_0x592b('0x2'));var db=require(_0x592b('0x3'))['db'];var utils=require('../../config/utils');var logger=require(_0x592b('0x4'))(_0x592b('0x5'));var config=require(_0x592b('0x6'));var jayson=require(_0x592b('0x7'));var client=jayson[_0x592b('0x8')][_0x592b('0x9')]({'port':0x232a});function respondWithRpcPromise(_0x1569c6,_0x563e48,_0x457896){return new BPromise(function(_0x45b09b,_0x85fc2e){return client[_0x592b('0xa')](_0x1569c6,_0x457896)[_0x592b('0xb')](function(_0x1221ea){logger[_0x592b('0xc')](_0x592b('0xd'),_0x563e48,_0x592b('0xe'));logger[_0x592b('0xf')](_0x592b('0x10'),_0x563e48,'request\x20sent',JSON[_0x592b('0x11')](_0x1221ea));if(_0x1221ea[_0x592b('0x12')]){if(_0x1221ea[_0x592b('0x12')][_0x592b('0x13')]===0x1f4){logger[_0x592b('0x12')](_0x592b('0xd'),_0x563e48,_0x1221ea[_0x592b('0x12')][_0x592b('0x14')]);return _0x85fc2e(_0x1221ea[_0x592b('0x12')][_0x592b('0x14')]);}logger['error'](_0x592b('0xd'),_0x563e48,_0x1221ea['error'][_0x592b('0x14')]);return _0x45b09b(_0x1221ea[_0x592b('0x12')][_0x592b('0x14')]);}else{logger['info'](_0x592b('0xd'),_0x563e48,_0x592b('0xe'));_0x45b09b(_0x1221ea[_0x592b('0x15')][_0x592b('0x14')]);}})[_0x592b('0x16')](function(_0x5d481d){logger[_0x592b('0x12')](_0x592b('0xd'),_0x563e48,_0x5d481d);_0x85fc2e(_0x5d481d);});});}exports['CreateAttachment']=function(_0x1f1195){var _0x42812a=this;return new Promise(function(_0x2aac54,_0x158df9){return db[_0x592b('0x17')][_0x592b('0x18')](_0x1f1195['body'],{'raw':_0x1f1195[_0x592b('0x19')]?_0x1f1195[_0x592b('0x19')][_0x592b('0x1a')]===undefined?!![]:![]:!![]})['then'](function(_0x42b7cf){logger[_0x592b('0xc')](_0x592b('0x1b'),_0x1f1195);logger[_0x592b('0xf')](_0x592b('0x1b'),_0x1f1195,JSON[_0x592b('0x11')](_0x42b7cf));_0x2aac54(_0x42b7cf);})[_0x592b('0x16')](function(_0x2d4a1e){logger['error'](_0x592b('0x1b'),_0x2d4a1e[_0x592b('0x14')],_0x1f1195);_0x158df9(_0x42812a['error'](0x1f4,_0x2d4a1e[_0x592b('0x14')]));});});};