Built motion from commit (unavailable).|2.5.21
[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 _0x54c7=['isNil','UserId','findOne','createdAt','catch','error','lodash','util','../../config/logger','api','moment','bluebird','request-promise','html-to-text','path','rimraf','../../config/environment','./mailMessage.attributes','define','MailMessage','mail_messages','messageId','fti_mail_messages','plainBody','subject','body','fromString','models','get','direction','toLowerCase','out','secret'];(function(_0x28f675,_0x17bb9c){var _0x5f2f12=function(_0x497563){while(--_0x497563){_0x28f675['push'](_0x28f675['shift']());}};_0x5f2f12(++_0x17bb9c);}(_0x54c7,0x1d4));var _0x754c=function(_0x1d5e5c,_0x405a91){_0x1d5e5c=_0x1d5e5c-0x0;var _0x466020=_0x54c7[_0x1d5e5c];return _0x466020;};'use strict';var _=require(_0x754c('0x0'));var util=require(_0x754c('0x1'));var logger=require(_0x754c('0x2'))(_0x754c('0x3'));var moment=require(_0x754c('0x4'));var BPromise=require(_0x754c('0x5'));var rp=require(_0x754c('0x6'));var htmlToText=require(_0x754c('0x7'));var fs=require('fs');var path=require(_0x754c('0x8'));var rimraf=require(_0x754c('0x9'));var config=require(_0x754c('0xa'));var attributes=require(_0x754c('0xb'));module['exports']=function(_0x573527,_0x1a5697){return _0x573527[_0x754c('0xc')](_0x754c('0xd'),attributes,{'tableName':_0x754c('0xe'),'paranoid':![],'indexes':[{'name':'messageId','fields':[_0x754c('0xf')]},{'name':_0x754c('0x10'),'fields':[_0x754c('0x11'),_0x754c('0x12')],'type':'FULLTEXT'}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x5e8556,_0x3896b7,_0x2563ee){if(_0x5e8556[_0x754c('0x13')]){_0x5e8556[_0x754c('0x11')]=htmlToText[_0x754c('0x14')](_0x5e8556[_0x754c('0x13')],{'preserveNewlines':!![],'singleNewLineParagraphs':!![],'uppercaseHeadings':![],'noLinkBrackets':!![],'ignoreImage':!![]});}_0x2563ee(null,_0x3896b7);},'afterCreate':function(_0x41e141,_0x2f3754,_0xe76af2){var _0x36d9b8=_0x573527[_0x754c('0x15')];var _0x38d89c=_0x41e141[_0x754c('0x16')]({'plain':!![]});if(_0x38d89c[_0x754c('0x17')][_0x754c('0x18')]()==='in'||_0x38d89c[_0x754c('0x17')][_0x754c('0x18')]()===_0x754c('0x19')&&!_0x38d89c[_0x754c('0x1a')]&&!_[_0x754c('0x1b')](_0x38d89c[_0x754c('0x1c')])){_0x36d9b8['MailInteraction'][_0x754c('0x1d')]({'where':{'id':_0x38d89c['MailInteractionId']}})['then'](function(_0x518862){if(_0x518862){_0x518862['update']({'lastMsgAt':_0x38d89c[_0x754c('0x1e')],'lastMsgDirection':_0x38d89c[_0x754c('0x17')]['toLowerCase'](),'lastMsgBody':_0x38d89c[_0x754c('0x13')]});}})[_0x754c('0x1f')](function(_0x39ff94){console[_0x754c('0x20')](_0x39ff94);});}_0xe76af2();}},'charset':'utf8mb4','collate':'utf8mb4_unicode_ci'});};