Built motion from commit (unavailable).|2.2.0
[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 _0x4f34=['../../mysqldb','../../config/utils','rpc','../../config/environment','jayson/promise','client','http','request','then','info','Attachment,\x20%s,\x20%s','request\x20sent','debug','error','message','result','catch','CreateAttachment','Attachment','create','body','options','raw','stringify','lodash','util','moment','bluebird','randomstring','ioredis'];(function(_0x20ae36,_0x5424d2){var _0x594d21=function(_0x1a1c30){while(--_0x1a1c30){_0x20ae36['push'](_0x20ae36['shift']());}};_0x594d21(++_0x5424d2);}(_0x4f34,0xae));var _0x44f3=function(_0x40cbd7,_0x35ee47){_0x40cbd7=_0x40cbd7-0x0;var _0x3caf4f=_0x4f34[_0x40cbd7];return _0x3caf4f;};'use strict';var _=require(_0x44f3('0x0'));var util=require(_0x44f3('0x1'));var moment=require(_0x44f3('0x2'));var BPromise=require(_0x44f3('0x3'));var rs=require(_0x44f3('0x4'));var fs=require('fs');var Redis=require(_0x44f3('0x5'));var db=require(_0x44f3('0x6'))['db'];var utils=require(_0x44f3('0x7'));var logger=require('../../config/logger')(_0x44f3('0x8'));var config=require(_0x44f3('0x9'));var jayson=require(_0x44f3('0xa'));var client=jayson[_0x44f3('0xb')][_0x44f3('0xc')]({'port':0x232a});function respondWithRpcPromise(_0xc9527e,_0x5ddf10,_0x3e28f4){return new BPromise(function(_0x5bcf28,_0xb6798b){return client[_0x44f3('0xd')](_0xc9527e,_0x3e28f4)[_0x44f3('0xe')](function(_0x1179f1){logger[_0x44f3('0xf')](_0x44f3('0x10'),_0x5ddf10,_0x44f3('0x11'));logger[_0x44f3('0x12')]('Attachment,\x20%s,\x20%s,\x20%s',_0x5ddf10,'request\x20sent',JSON['stringify'](_0x1179f1));if(_0x1179f1[_0x44f3('0x13')]){if(_0x1179f1[_0x44f3('0x13')]['code']===0x1f4){logger[_0x44f3('0x13')](_0x44f3('0x10'),_0x5ddf10,_0x1179f1[_0x44f3('0x13')][_0x44f3('0x14')]);return _0xb6798b(_0x1179f1[_0x44f3('0x13')][_0x44f3('0x14')]);}logger[_0x44f3('0x13')]('Attachment,\x20%s,\x20%s',_0x5ddf10,_0x1179f1[_0x44f3('0x13')][_0x44f3('0x14')]);return _0x5bcf28(_0x1179f1['error'][_0x44f3('0x14')]);}else{logger[_0x44f3('0xf')](_0x44f3('0x10'),_0x5ddf10,_0x44f3('0x11'));_0x5bcf28(_0x1179f1[_0x44f3('0x15')]['message']);}})[_0x44f3('0x16')](function(_0x1299d3){logger[_0x44f3('0x13')](_0x44f3('0x10'),_0x5ddf10,_0x1299d3);_0xb6798b(_0x1299d3);});});}exports[_0x44f3('0x17')]=function(_0x5e11fa){var _0x147495=this;return new Promise(function(_0x2e1a53,_0x34bfb9){return db[_0x44f3('0x18')][_0x44f3('0x19')](_0x5e11fa[_0x44f3('0x1a')],{'raw':_0x5e11fa[_0x44f3('0x1b')]?_0x5e11fa['options'][_0x44f3('0x1c')]===undefined?!![]:![]:!![]})[_0x44f3('0xe')](function(_0x52d04c){logger[_0x44f3('0xf')](_0x44f3('0x17'),_0x5e11fa);logger[_0x44f3('0x12')]('CreateAttachment',_0x5e11fa,JSON[_0x44f3('0x1d')](_0x52d04c));_0x2e1a53(_0x52d04c);})[_0x44f3('0x16')](function(_0x222a06){logger[_0x44f3('0x13')](_0x44f3('0x17'),_0x222a06[_0x44f3('0x14')],_0x5e11fa);_0x34bfb9(_0x147495[_0x44f3('0x13')](0x1f4,_0x222a06[_0x44f3('0x14')]));});});};