Built motion from commit (unavailable).|2.4.18
[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 _0xb986=['fti_mail_messages','plainBody','subject','body','models','get','direction','toLowerCase','out','isNil','UserId','MailInteraction','MailInteractionId','then','catch','error','utf8mb4','utf8mb4_unicode_ci','lodash','util','bluebird','request-promise','html-to-text','path','rimraf','../../config/environment','./mailMessage.attributes','exports','define','messageId'];(function(_0x4d5e66,_0x337ad9){var _0xe68a39=function(_0x3187cf){while(--_0x3187cf){_0x4d5e66['push'](_0x4d5e66['shift']());}};_0xe68a39(++_0x337ad9);}(_0xb986,0x8a));var _0x6b98=function(_0xa4f363,_0x577275){_0xa4f363=_0xa4f363-0x0;var _0x38327f=_0xb986[_0xa4f363];return _0x38327f;};'use strict';var _=require(_0x6b98('0x0'));var util=require(_0x6b98('0x1'));var logger=require('../../config/logger')('api');var moment=require('moment');var BPromise=require(_0x6b98('0x2'));var rp=require(_0x6b98('0x3'));var htmlToText=require(_0x6b98('0x4'));var fs=require('fs');var path=require(_0x6b98('0x5'));var rimraf=require(_0x6b98('0x6'));var config=require(_0x6b98('0x7'));var attributes=require(_0x6b98('0x8'));module[_0x6b98('0x9')]=function(_0x5bcdce,_0x5502a2){return _0x5bcdce[_0x6b98('0xa')]('MailMessage',attributes,{'tableName':'mail_messages','paranoid':![],'indexes':[{'name':_0x6b98('0xb'),'fields':[_0x6b98('0xb')]},{'name':_0x6b98('0xc'),'fields':[_0x6b98('0xd'),_0x6b98('0xe')],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x2409d7,_0x15af49,_0x49e4bf){if(_0x2409d7[_0x6b98('0xf')]){_0x2409d7['plainBody']=htmlToText['fromString'](_0x2409d7[_0x6b98('0xf')],{'preserveNewlines':!![],'singleNewLineParagraphs':!![],'uppercaseHeadings':![],'noLinkBrackets':!![],'ignoreImage':!![]});}_0x49e4bf(null,_0x15af49);},'afterCreate':function(_0x3990ba,_0x115c1a,_0x47035f){var _0x2826bb=_0x5bcdce[_0x6b98('0x10')];var _0x433ab1=_0x3990ba[_0x6b98('0x11')]({'plain':!![]});if(_0x433ab1[_0x6b98('0x12')][_0x6b98('0x13')]()==='in'||_0x433ab1['direction']['toLowerCase']()===_0x6b98('0x14')&&!_0x433ab1['secret']&&!_[_0x6b98('0x15')](_0x433ab1[_0x6b98('0x16')])){_0x2826bb[_0x6b98('0x17')]['findOne']({'where':{'id':_0x433ab1[_0x6b98('0x18')]}})[_0x6b98('0x19')](function(_0x39febc){if(_0x39febc){_0x39febc['update']({'lastMsgAt':_0x433ab1['createdAt'],'lastMsgDirection':_0x433ab1[_0x6b98('0x12')][_0x6b98('0x13')](),'lastMsgBody':_0x433ab1[_0x6b98('0xf')]});}})[_0x6b98('0x1a')](function(_0x5f3d26){console[_0x6b98('0x1b')](_0x5f3d26);});}_0x47035f();}},'charset':_0x6b98('0x1c'),'collate':_0x6b98('0x1d')});};