Built motion from commit (unavailable).|2.0.75
[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 _0x8994=['secret','isNil','UserId','findOne','FaxInteractionId','then','update','body','error','utf8mb4','lodash','util','api','bluebird','./faxMessage.attributes','exports','define','FaxMessage','fax_messages','models','get','direction','toLowerCase','out'];(function(_0x4bb581,_0x6f7037){var _0x316bf5=function(_0x1f6ed0){while(--_0x1f6ed0){_0x4bb581['push'](_0x4bb581['shift']());}};_0x316bf5(++_0x6f7037);}(_0x8994,0x112));var _0x4899=function(_0x409353,_0xe9f04d){_0x409353=_0x409353-0x0;var _0x4f4b59=_0x8994[_0x409353];return _0x4f4b59;};'use strict';var _=require(_0x4899('0x0'));var util=require(_0x4899('0x1'));var logger=require('../../config/logger')(_0x4899('0x2'));var moment=require('moment');var BPromise=require(_0x4899('0x3'));var rp=require('request-promise');var attributes=require(_0x4899('0x4'));module[_0x4899('0x5')]=function(_0x404c2c,_0x4635d2){return _0x404c2c[_0x4899('0x6')](_0x4899('0x7'),attributes,{'tableName':_0x4899('0x8'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x21897d,_0x397ce2,_0x14cb80){var _0x348879=_0x404c2c[_0x4899('0x9')];var _0x353870=_0x21897d[_0x4899('0xa')]({'plain':!![]});if(_0x353870[_0x4899('0xb')][_0x4899('0xc')]()==='in'||_0x353870['direction']['toLowerCase']()===_0x4899('0xd')&&!_0x353870[_0x4899('0xe')]&&!_[_0x4899('0xf')](_0x353870[_0x4899('0x10')])){_0x348879['FaxInteraction'][_0x4899('0x11')]({'where':{'id':_0x353870[_0x4899('0x12')]}})[_0x4899('0x13')](function(_0x318498){if(_0x318498){_0x318498[_0x4899('0x14')]({'lastMsgAt':_0x353870['createdAt'],'lastMsgDirection':_0x353870[_0x4899('0xb')]['toLowerCase'](),'lastMsgBody':_0x353870[_0x4899('0x15')]});}})['catch'](function(_0x1b32d3){console[_0x4899('0x16')](_0x1b32d3);});}_0x14cb80();}},'charset':_0x4899('0x17'),'collate':'utf8mb4_unicode_ci'});};