Built motion from commit (unavailable).|2.2.3
[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 _0xf500=['define','FaxMessage','fax_messages','direction','toLowerCase','secret','isNil','UserId','findOne','FaxInteractionId','then','update','createdAt','error','utf8mb4_unicode_ci','util','bluebird','request-promise','./faxMessage.attributes','exports'];(function(_0x575f37,_0x3821ca){var _0xe7215b=function(_0x5cb764){while(--_0x5cb764){_0x575f37['push'](_0x575f37['shift']());}};_0xe7215b(++_0x3821ca);}(_0xf500,0x163));var _0x0f50=function(_0x2080a3,_0x48acfa){_0x2080a3=_0x2080a3-0x0;var _0x8d7d17=_0xf500[_0x2080a3];return _0x8d7d17;};'use strict';var _=require('lodash');var util=require(_0x0f50('0x0'));var logger=require('../../config/logger')('api');var moment=require('moment');var BPromise=require(_0x0f50('0x1'));var rp=require(_0x0f50('0x2'));var attributes=require(_0x0f50('0x3'));module[_0x0f50('0x4')]=function(_0x5d3c93,_0x22ec47){return _0x5d3c93[_0x0f50('0x5')](_0x0f50('0x6'),attributes,{'tableName':_0x0f50('0x7'),'paranoid':![],'indexes':[],'timestamps':!![],'hooks':{'afterCreate':function(_0x5dc8d2,_0x251d08,_0x32c097){var _0x17538d=_0x5d3c93['models'];var _0x29205f=_0x5dc8d2['get']({'plain':!![]});if(_0x29205f[_0x0f50('0x8')][_0x0f50('0x9')]()==='in'||_0x29205f[_0x0f50('0x8')][_0x0f50('0x9')]()==='out'&&!_0x29205f[_0x0f50('0xa')]&&!_[_0x0f50('0xb')](_0x29205f[_0x0f50('0xc')])){_0x17538d['FaxInteraction'][_0x0f50('0xd')]({'where':{'id':_0x29205f[_0x0f50('0xe')]}})[_0x0f50('0xf')](function(_0x38933f){if(_0x38933f){_0x38933f[_0x0f50('0x10')]({'lastMsgAt':_0x29205f[_0x0f50('0x11')],'lastMsgDirection':_0x29205f[_0x0f50('0x8')][_0x0f50('0x9')](),'lastMsgBody':_0x29205f['body']});}})['catch'](function(_0x1934c0){console[_0x0f50('0x12')](_0x1934c0);});}_0x32c097();}},'charset':'utf8mb4','collate':_0x0f50('0x13')});};