93ea48b95e63b1a271480b20369bb2182a313f88
[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 _0xb8d5=['debug','lodash','moment','bluebird','randomstring','ioredis','../../mysqldb','../../config/logger','rpc','../../config/environment','jayson/promise','http','request','info','Attachment,\x20%s,\x20%s','request\x20sent','Attachment,\x20%s,\x20%s,\x20%s','stringify','code','error','message','result','catch','CreateAttachment','Attachment','body','options'];(function(_0x8e2d4d,_0x310930){var _0x5e3047=function(_0x4665e4){while(--_0x4665e4){_0x8e2d4d['push'](_0x8e2d4d['shift']());}};_0x5e3047(++_0x310930);}(_0xb8d5,0x6d));var _0x5b8d=function(_0x2f301c,_0x2b6558){_0x2f301c=_0x2f301c-0x0;var _0x541357=_0xb8d5[_0x2f301c];return _0x541357;};'use strict';var _=require(_0x5b8d('0x0'));var util=require('util');var moment=require(_0x5b8d('0x1'));var BPromise=require(_0x5b8d('0x2'));var rs=require(_0x5b8d('0x3'));var fs=require('fs');var Redis=require(_0x5b8d('0x4'));var db=require(_0x5b8d('0x5'))['db'];var utils=require('../../config/utils');var logger=require(_0x5b8d('0x6'))(_0x5b8d('0x7'));var config=require(_0x5b8d('0x8'));var jayson=require(_0x5b8d('0x9'));var client=jayson['client'][_0x5b8d('0xa')]({'port':0x232a});function respondWithRpcPromise(_0x1164f2,_0x2eab7d,_0xa777b1){return new BPromise(function(_0xe22e99,_0x4b5b19){return client[_0x5b8d('0xb')](_0x1164f2,_0xa777b1)['then'](function(_0x1cc4fa){logger[_0x5b8d('0xc')](_0x5b8d('0xd'),_0x2eab7d,_0x5b8d('0xe'));logger['debug'](_0x5b8d('0xf'),_0x2eab7d,_0x5b8d('0xe'),JSON[_0x5b8d('0x10')](_0x1cc4fa));if(_0x1cc4fa['error']){if(_0x1cc4fa['error'][_0x5b8d('0x11')]===0x1f4){logger[_0x5b8d('0x12')](_0x5b8d('0xd'),_0x2eab7d,_0x1cc4fa['error']['message']);return _0x4b5b19(_0x1cc4fa[_0x5b8d('0x12')][_0x5b8d('0x13')]);}logger[_0x5b8d('0x12')](_0x5b8d('0xd'),_0x2eab7d,_0x1cc4fa[_0x5b8d('0x12')]['message']);return _0xe22e99(_0x1cc4fa[_0x5b8d('0x12')][_0x5b8d('0x13')]);}else{logger[_0x5b8d('0xc')](_0x5b8d('0xd'),_0x2eab7d,'request\x20sent');_0xe22e99(_0x1cc4fa[_0x5b8d('0x14')][_0x5b8d('0x13')]);}})[_0x5b8d('0x15')](function(_0x46ae84){logger[_0x5b8d('0x12')]('Attachment,\x20%s,\x20%s',_0x2eab7d,_0x46ae84);_0x4b5b19(_0x46ae84);});});}exports[_0x5b8d('0x16')]=function(_0x492a0c){var _0x4a5d5f=this;return new Promise(function(_0x4c731b,_0x181d34){return db[_0x5b8d('0x17')]['create'](_0x492a0c[_0x5b8d('0x18')],{'raw':_0x492a0c[_0x5b8d('0x19')]?_0x492a0c[_0x5b8d('0x19')]['raw']===undefined?!![]:![]:!![]})['then'](function(_0x4b4b38){logger[_0x5b8d('0xc')](_0x5b8d('0x16'),_0x492a0c);logger[_0x5b8d('0x1a')](_0x5b8d('0x16'),_0x492a0c,JSON['stringify'](_0x4b4b38));_0x4c731b(_0x4b4b38);})[_0x5b8d('0x15')](function(_0x4d9f29){logger[_0x5b8d('0x12')]('CreateAttachment',_0x4d9f29[_0x5b8d('0x13')],_0x492a0c);_0x181d34(_0x4a5d5f[_0x5b8d('0x12')](0x1f4,_0x4d9f29[_0x5b8d('0x13')]));});});};