Built motion from commit 10af8726.|2.6.34
[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 _0x3ff8=['utf8mb4','utf8mb4_unicode_ci','lodash','util','../../config/logger','api','moment','request-promise','html-to-text','path','rimraf','./mailMessage.attributes','exports','define','MailMessage','mail_messages','messageId','fti_mail_messages','plainBody','subject','body','models','get','direction','toLowerCase','out','secret','isNil','UserId','MailInteraction','findOne','MailInteractionId','update','createdAt','catch','error'];(function(_0x4f217f,_0x313163){var _0x3b583a=function(_0x334971){while(--_0x334971){_0x4f217f['push'](_0x4f217f['shift']());}};_0x3b583a(++_0x313163);}(_0x3ff8,0x122));var _0x83ff=function(_0x147003,_0x36e2e3){_0x147003=_0x147003-0x0;var _0x5167b2=_0x3ff8[_0x147003];return _0x5167b2;};'use strict';var _=require(_0x83ff('0x0'));var util=require(_0x83ff('0x1'));var logger=require(_0x83ff('0x2'))(_0x83ff('0x3'));var moment=require(_0x83ff('0x4'));var BPromise=require('bluebird');var rp=require(_0x83ff('0x5'));var htmlToText=require(_0x83ff('0x6'));var fs=require('fs');var path=require(_0x83ff('0x7'));var rimraf=require(_0x83ff('0x8'));var config=require('../../config/environment');var attributes=require(_0x83ff('0x9'));module[_0x83ff('0xa')]=function(_0x632f14,_0x18c821){return _0x632f14[_0x83ff('0xb')](_0x83ff('0xc'),attributes,{'tableName':_0x83ff('0xd'),'paranoid':![],'indexes':[{'name':_0x83ff('0xe'),'fields':[_0x83ff('0xe')]},{'name':_0x83ff('0xf'),'fields':[_0x83ff('0x10'),_0x83ff('0x11')],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x164685,_0x20c7ec,_0x5497c5){if(_0x164685['body']){_0x164685[_0x83ff('0x10')]=htmlToText['fromString'](_0x164685[_0x83ff('0x12')],{'preserveNewlines':!![],'singleNewLineParagraphs':!![],'uppercaseHeadings':![],'noLinkBrackets':!![],'ignoreImage':!![]});}_0x5497c5(null,_0x20c7ec);},'afterCreate':function(_0x2f8445,_0x3665f0,_0x31a496){var _0x4beb85=_0x632f14[_0x83ff('0x13')];var _0x47f001=_0x2f8445[_0x83ff('0x14')]({'plain':!![]});if(_0x47f001[_0x83ff('0x15')][_0x83ff('0x16')]()==='in'||_0x47f001[_0x83ff('0x15')][_0x83ff('0x16')]()===_0x83ff('0x17')&&!_0x47f001[_0x83ff('0x18')]&&!_[_0x83ff('0x19')](_0x47f001[_0x83ff('0x1a')])){_0x4beb85[_0x83ff('0x1b')][_0x83ff('0x1c')]({'where':{'id':_0x47f001[_0x83ff('0x1d')]}})['then'](function(_0x14414d){if(_0x14414d){_0x14414d[_0x83ff('0x1e')]({'lastMsgAt':_0x47f001[_0x83ff('0x1f')],'lastMsgDirection':_0x47f001['direction'][_0x83ff('0x16')]()});}})[_0x83ff('0x20')](function(_0x3bee0d){console[_0x83ff('0x21')](_0x3bee0d);});}_0x31a496();}},'charset':_0x83ff('0x22'),'collate':_0x83ff('0x23')});};