Built motion from commit (unavailable).|2.5.30
[motion2.git] / server / api / mailMessage / mailMessage.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 _0xd2ed=['FULLTEXT','fromString','body','models','direction','toLowerCase','out','isNil','findOne','MailInteractionId','update','createdAt','catch','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','moment','bluebird','request-promise','html-to-text','rimraf','./mailMessage.attributes','exports','MailMessage','mail_messages','messageId','plainBody'];(function(_0x3720a3,_0xabd170){var _0x2ae4bd=function(_0x1b59cd){while(--_0x1b59cd){_0x3720a3['push'](_0x3720a3['shift']());}};_0x2ae4bd(++_0xabd170);}(_0xd2ed,0x14d));var _0xdd2e=function(_0x477611,_0x133172){_0x477611=_0x477611-0x0;var _0x4c1287=_0xd2ed[_0x477611];return _0x4c1287;};'use strict';var _=require(_0xdd2e('0x0'));var util=require(_0xdd2e('0x1'));var logger=require(_0xdd2e('0x2'))(_0xdd2e('0x3'));var moment=require(_0xdd2e('0x4'));var BPromise=require(_0xdd2e('0x5'));var rp=require(_0xdd2e('0x6'));var htmlToText=require(_0xdd2e('0x7'));var fs=require('fs');var path=require('path');var rimraf=require(_0xdd2e('0x8'));var config=require('../../config/environment');var attributes=require(_0xdd2e('0x9'));module[_0xdd2e('0xa')]=function(_0x416f39,_0x2a85ab){return _0x416f39['define'](_0xdd2e('0xb'),attributes,{'tableName':_0xdd2e('0xc'),'paranoid':![],'indexes':[{'name':_0xdd2e('0xd'),'fields':['messageId']},{'name':'fti_mail_messages','fields':[_0xdd2e('0xe'),'subject'],'type':_0xdd2e('0xf')}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x1e5b8c,_0x49bc21,_0x25f0f7){if(_0x1e5b8c['body']){_0x1e5b8c[_0xdd2e('0xe')]=htmlToText[_0xdd2e('0x10')](_0x1e5b8c[_0xdd2e('0x11')],{'preserveNewlines':!![],'singleNewLineParagraphs':!![],'uppercaseHeadings':![],'noLinkBrackets':!![],'ignoreImage':!![]});}_0x25f0f7(null,_0x49bc21);},'afterCreate':function(_0x5a3a65,_0x89bf87,_0x45ae8f){var _0x391a8d=_0x416f39[_0xdd2e('0x12')];var _0x433f42=_0x5a3a65['get']({'plain':!![]});if(_0x433f42[_0xdd2e('0x13')][_0xdd2e('0x14')]()==='in'||_0x433f42[_0xdd2e('0x13')][_0xdd2e('0x14')]()===_0xdd2e('0x15')&&!_0x433f42['secret']&&!_[_0xdd2e('0x16')](_0x433f42['UserId'])){_0x391a8d['MailInteraction'][_0xdd2e('0x17')]({'where':{'id':_0x433f42[_0xdd2e('0x18')]}})['then'](function(_0x41aef6){if(_0x41aef6){_0x41aef6[_0xdd2e('0x19')]({'lastMsgAt':_0x433f42[_0xdd2e('0x1a')],'lastMsgDirection':_0x433f42[_0xdd2e('0x13')][_0xdd2e('0x14')]()});}})[_0xdd2e('0x1b')](function(_0x1020af){console['error'](_0x1020af);});}_0x45ae8f();}},'charset':'utf8mb4','collate':_0xdd2e('0x1c')});};