Built motion from commit 85328c08.|2.5.50
[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 _0x8bfa=['messageId','fti_mail_messages','plainBody','subject','body','models','get','direction','toLowerCase','isNil','UserId','MailInteraction','findOne','MailInteractionId','then','update','createdAt','catch','error','utf8mb4','utf8mb4_unicode_ci','lodash','../../config/logger','moment','bluebird','request-promise','html-to-text','rimraf','../../config/environment','exports','define'];(function(_0x401609,_0x5eb61d){var _0x35fd57=function(_0x5dcddd){while(--_0x5dcddd){_0x401609['push'](_0x401609['shift']());}};_0x35fd57(++_0x5eb61d);}(_0x8bfa,0xee));var _0xa8bf=function(_0x31c5fd,_0x33131f){_0x31c5fd=_0x31c5fd-0x0;var _0x3799ab=_0x8bfa[_0x31c5fd];return _0x3799ab;};'use strict';var _=require(_0xa8bf('0x0'));var util=require('util');var logger=require(_0xa8bf('0x1'))('api');var moment=require(_0xa8bf('0x2'));var BPromise=require(_0xa8bf('0x3'));var rp=require(_0xa8bf('0x4'));var htmlToText=require(_0xa8bf('0x5'));var fs=require('fs');var path=require('path');var rimraf=require(_0xa8bf('0x6'));var config=require(_0xa8bf('0x7'));var attributes=require('./mailMessage.attributes');module[_0xa8bf('0x8')]=function(_0x5b4c92,_0x256902){return _0x5b4c92[_0xa8bf('0x9')]('MailMessage',attributes,{'tableName':'mail_messages','paranoid':![],'indexes':[{'name':_0xa8bf('0xa'),'fields':[_0xa8bf('0xa')]},{'name':_0xa8bf('0xb'),'fields':[_0xa8bf('0xc'),_0xa8bf('0xd')],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x4316ba,_0x85489d,_0x528efc){if(_0x4316ba[_0xa8bf('0xe')]){_0x4316ba[_0xa8bf('0xc')]=htmlToText['fromString'](_0x4316ba['body'],{'preserveNewlines':!![],'singleNewLineParagraphs':!![],'uppercaseHeadings':![],'noLinkBrackets':!![],'ignoreImage':!![]});}_0x528efc(null,_0x85489d);},'afterCreate':function(_0x1ccce0,_0x5a2eaf,_0x2baa0e){var _0x3b9f1c=_0x5b4c92[_0xa8bf('0xf')];var _0x2033e2=_0x1ccce0[_0xa8bf('0x10')]({'plain':!![]});if(_0x2033e2[_0xa8bf('0x11')]['toLowerCase']()==='in'||_0x2033e2[_0xa8bf('0x11')][_0xa8bf('0x12')]()==='out'&&!_0x2033e2['secret']&&!_[_0xa8bf('0x13')](_0x2033e2[_0xa8bf('0x14')])){_0x3b9f1c[_0xa8bf('0x15')][_0xa8bf('0x16')]({'where':{'id':_0x2033e2[_0xa8bf('0x17')]}})[_0xa8bf('0x18')](function(_0x525d06){if(_0x525d06){_0x525d06[_0xa8bf('0x19')]({'lastMsgAt':_0x2033e2[_0xa8bf('0x1a')],'lastMsgDirection':_0x2033e2[_0xa8bf('0x11')][_0xa8bf('0x12')]()});}})[_0xa8bf('0x1b')](function(_0x2e4751){console[_0xa8bf('0x1c')](_0x2e4751);});}_0x2baa0e();}},'charset':_0xa8bf('0x1d'),'collate':_0xa8bf('0x1e')});};