f7eb424198cb78b16ddce6e01823ce57e695967d
[motion2.git] / server / api / chatMessage / chatMessage.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 _0xc5da=['toLowerCase','out','secret','isNil','UserId','ChatInteraction','findOne','ChatInteractionId','then','update','createdAt','catch','utf8mb4','utf8mb4_unicode_ci','lodash','../../config/logger','moment','bluebird','request-promise','path','../../config/environment','exports','define','ChatMessage','body','FULLTEXT','models','direction'];(function(_0x30e469,_0x5de53c){var _0xf75061=function(_0x16a336){while(--_0x16a336){_0x30e469['push'](_0x30e469['shift']());}};_0xf75061(++_0x5de53c);}(_0xc5da,0x1b2));var _0xac5d=function(_0x4f606d,_0x4acb05){_0x4f606d=_0x4f606d-0x0;var _0x3e7d17=_0xc5da[_0x4f606d];return _0x3e7d17;};'use strict';var _=require(_0xac5d('0x0'));var util=require('util');var logger=require(_0xac5d('0x1'))('api');var moment=require(_0xac5d('0x2'));var BPromise=require(_0xac5d('0x3'));var rp=require(_0xac5d('0x4'));var fs=require('fs');var path=require(_0xac5d('0x5'));var rimraf=require('rimraf');var config=require(_0xac5d('0x6'));var attributes=require('./chatMessage.attributes');module[_0xac5d('0x7')]=function(_0x3b0203,_0xc57a4){return _0x3b0203[_0xac5d('0x8')](_0xac5d('0x9'),attributes,{'tableName':'chat_messages','paranoid':![],'indexes':[{'name':'fti_chat_messages','fields':[_0xac5d('0xa')],'type':_0xac5d('0xb')}],'timestamps':!![],'hooks':{'afterCreate':function(_0x1be9ac,_0x559aea,_0x1fb4f9){var _0xf533ec=_0x3b0203[_0xac5d('0xc')];var _0x457de4=_0x1be9ac['get']({'plain':!![]});if(_0x457de4[_0xac5d('0xd')][_0xac5d('0xe')]()==='in'||_0x457de4['direction'][_0xac5d('0xe')]()===_0xac5d('0xf')&&!_0x457de4[_0xac5d('0x10')]&&!_[_0xac5d('0x11')](_0x457de4[_0xac5d('0x12')])){_0xf533ec[_0xac5d('0x13')][_0xac5d('0x14')]({'where':{'id':_0x457de4[_0xac5d('0x15')]}})[_0xac5d('0x16')](function(_0x559c5a){if(_0x559c5a){_0x559c5a[_0xac5d('0x17')]({'lastMsgAt':_0x457de4[_0xac5d('0x18')],'lastMsgDirection':_0x457de4[_0xac5d('0xd')][_0xac5d('0xe')]()});}})[_0xac5d('0x19')](function(_0x22e514){console['error'](_0x22e514);});}_0x1fb4f9();}},'charset':_0xac5d('0x1a'),'collate':_0xac5d('0x1b')});};