Built motion from commit 9d0783e6.|2.6.13
[motion2.git] / server / api / faxMessage / faxMessage.model.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 _0xa258=['secret','UserId','FaxInteraction','findOne','FaxInteractionId','then','update','createdAt','catch','error','utf8mb4','util','../../config/logger','api','moment','request-promise','path','rimraf','exports','define','FaxMessage','fti_fax_messages','models','toLowerCase','direction'];(function(_0x51af00,_0x293964){var _0x25bad7=function(_0x8b078b){while(--_0x8b078b){_0x51af00['push'](_0x51af00['shift']());}};_0x25bad7(++_0x293964);}(_0xa258,0x88));var _0x8a25=function(_0x924aed,_0x3bca33){_0x924aed=_0x924aed-0x0;var _0x4f644e=_0xa258[_0x924aed];return _0x4f644e;};'use strict';var _=require('lodash');var util=require(_0x8a25('0x0'));var logger=require(_0x8a25('0x1'))(_0x8a25('0x2'));var moment=require(_0x8a25('0x3'));var BPromise=require('bluebird');var rp=require(_0x8a25('0x4'));var fs=require('fs');var path=require(_0x8a25('0x5'));var rimraf=require(_0x8a25('0x6'));var config=require('../../config/environment');var attributes=require('./faxMessage.attributes');module[_0x8a25('0x7')]=function(_0x3faf12,_0x30bf24){return _0x3faf12[_0x8a25('0x8')](_0x8a25('0x9'),attributes,{'tableName':'fax_messages','paranoid':![],'indexes':[{'name':_0x8a25('0xa'),'fields':['body'],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'afterCreate':function(_0x168596,_0x9d8c8a,_0x350c1d){var _0x24182c=_0x3faf12[_0x8a25('0xb')];var _0x24959c=_0x168596['get']({'plain':!![]});if(_0x24959c['direction'][_0x8a25('0xc')]()==='in'||_0x24959c[_0x8a25('0xd')][_0x8a25('0xc')]()==='out'&&!_0x24959c[_0x8a25('0xe')]&&!_['isNil'](_0x24959c[_0x8a25('0xf')])){_0x24182c[_0x8a25('0x10')][_0x8a25('0x11')]({'where':{'id':_0x24959c[_0x8a25('0x12')]}})[_0x8a25('0x13')](function(_0x1f47b5){if(_0x1f47b5){_0x1f47b5[_0x8a25('0x14')]({'lastMsgAt':_0x24959c[_0x8a25('0x15')],'lastMsgDirection':_0x24959c[_0x8a25('0xd')]['toLowerCase']()});}})[_0x8a25('0x16')](function(_0x5c4bd2){console[_0x8a25('0x17')](_0x5c4bd2);});}_0x350c1d();}},'charset':_0x8a25('0x18'),'collate':'utf8mb4_unicode_ci'});};