Built motion from commit 0bd120ac.|2.6.25
[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 _0xef7d=['subject','FULLTEXT','body','fromString','models','get','direction','toLowerCase','out','secret','isNil','UserId','MailInteraction','findOne','MailInteractionId','then','update','createdAt','catch','error','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','moment','bluebird','request-promise','path','rimraf','../../config/environment','./mailMessage.attributes','define','messageId','fti_mail_messages','plainBody'];(function(_0x3dd15e,_0x1f0015){var _0x231fd0=function(_0x4f680a){while(--_0x4f680a){_0x3dd15e['push'](_0x3dd15e['shift']());}};_0x231fd0(++_0x1f0015);}(_0xef7d,0x1e9));var _0xdef7=function(_0x28aea5,_0x3bb12e){_0x28aea5=_0x28aea5-0x0;var _0x6a55f9=_0xef7d[_0x28aea5];return _0x6a55f9;};'use strict';var _=require(_0xdef7('0x0'));var util=require(_0xdef7('0x1'));var logger=require(_0xdef7('0x2'))(_0xdef7('0x3'));var moment=require(_0xdef7('0x4'));var BPromise=require(_0xdef7('0x5'));var rp=require(_0xdef7('0x6'));var htmlToText=require('html-to-text');var fs=require('fs');var path=require(_0xdef7('0x7'));var rimraf=require(_0xdef7('0x8'));var config=require(_0xdef7('0x9'));var attributes=require(_0xdef7('0xa'));module['exports']=function(_0x1fcc2d,_0x3dc1b1){return _0x1fcc2d[_0xdef7('0xb')]('MailMessage',attributes,{'tableName':'mail_messages','paranoid':![],'indexes':[{'name':_0xdef7('0xc'),'fields':[_0xdef7('0xc')]},{'name':_0xdef7('0xd'),'fields':[_0xdef7('0xe'),_0xdef7('0xf')],'type':_0xdef7('0x10')}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x529012,_0x823b19,_0x23d4c1){if(_0x529012[_0xdef7('0x11')]){_0x529012[_0xdef7('0xe')]=htmlToText[_0xdef7('0x12')](_0x529012[_0xdef7('0x11')],{'preserveNewlines':!![],'singleNewLineParagraphs':!![],'uppercaseHeadings':![],'noLinkBrackets':!![],'ignoreImage':!![]});}_0x23d4c1(null,_0x823b19);},'afterCreate':function(_0x5d8c80,_0x3d8d8c,_0x3ca4d5){var _0x347dc9=_0x1fcc2d[_0xdef7('0x13')];var _0x3c8113=_0x5d8c80[_0xdef7('0x14')]({'plain':!![]});if(_0x3c8113[_0xdef7('0x15')]['toLowerCase']()==='in'||_0x3c8113[_0xdef7('0x15')][_0xdef7('0x16')]()===_0xdef7('0x17')&&!_0x3c8113[_0xdef7('0x18')]&&!_[_0xdef7('0x19')](_0x3c8113[_0xdef7('0x1a')])){_0x347dc9[_0xdef7('0x1b')][_0xdef7('0x1c')]({'where':{'id':_0x3c8113[_0xdef7('0x1d')]}})[_0xdef7('0x1e')](function(_0xa9fe93){if(_0xa9fe93){_0xa9fe93[_0xdef7('0x1f')]({'lastMsgAt':_0x3c8113[_0xdef7('0x20')],'lastMsgDirection':_0x3c8113['direction'][_0xdef7('0x16')]()});}})[_0xdef7('0x21')](function(_0x45e0f0){console[_0xdef7('0x22')](_0x45e0f0);});}_0x3ca4d5();}},'charset':'utf8mb4','collate':_0xdef7('0x23')});};