Built motion from commit (unavailable).|2.5.17
[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 _0x6bcc=['body','fromString','models','get','direction','toLowerCase','out','secret','findOne','MailInteractionId','then','update','catch','utf8mb4','utf8mb4_unicode_ci','util','../../config/logger','api','request-promise','html-to-text','rimraf','./mailMessage.attributes','define','MailMessage','mail_messages','messageId','plainBody','FULLTEXT'];(function(_0x15c421,_0x6366f7){var _0x5e5ed5=function(_0x206e66){while(--_0x206e66){_0x15c421['push'](_0x15c421['shift']());}};_0x5e5ed5(++_0x6366f7);}(_0x6bcc,0x197));var _0xc6bc=function(_0x1a6cce,_0x2b2712){_0x1a6cce=_0x1a6cce-0x0;var _0xe3b0a2=_0x6bcc[_0x1a6cce];return _0xe3b0a2;};'use strict';var _=require('lodash');var util=require(_0xc6bc('0x0'));var logger=require(_0xc6bc('0x1'))(_0xc6bc('0x2'));var moment=require('moment');var BPromise=require('bluebird');var rp=require(_0xc6bc('0x3'));var htmlToText=require(_0xc6bc('0x4'));var fs=require('fs');var path=require('path');var rimraf=require(_0xc6bc('0x5'));var config=require('../../config/environment');var attributes=require(_0xc6bc('0x6'));module['exports']=function(_0x44a1f0,_0x495b5a){return _0x44a1f0[_0xc6bc('0x7')](_0xc6bc('0x8'),attributes,{'tableName':_0xc6bc('0x9'),'paranoid':![],'indexes':[{'name':_0xc6bc('0xa'),'fields':['messageId']},{'name':'fti_mail_messages','fields':[_0xc6bc('0xb'),'subject'],'type':_0xc6bc('0xc')}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x5ab9f2,_0x43bb93,_0x56bcec){if(_0x5ab9f2[_0xc6bc('0xd')]){_0x5ab9f2[_0xc6bc('0xb')]=htmlToText[_0xc6bc('0xe')](_0x5ab9f2['body'],{'preserveNewlines':!![],'singleNewLineParagraphs':!![],'uppercaseHeadings':![],'noLinkBrackets':!![],'ignoreImage':!![]});}_0x56bcec(null,_0x43bb93);},'afterCreate':function(_0x2f3319,_0x19e52d,_0x3d001c){var _0x261cb9=_0x44a1f0[_0xc6bc('0xf')];var _0xf83e49=_0x2f3319[_0xc6bc('0x10')]({'plain':!![]});if(_0xf83e49[_0xc6bc('0x11')][_0xc6bc('0x12')]()==='in'||_0xf83e49[_0xc6bc('0x11')][_0xc6bc('0x12')]()===_0xc6bc('0x13')&&!_0xf83e49[_0xc6bc('0x14')]&&!_['isNil'](_0xf83e49['UserId'])){_0x261cb9['MailInteraction'][_0xc6bc('0x15')]({'where':{'id':_0xf83e49[_0xc6bc('0x16')]}})[_0xc6bc('0x17')](function(_0x448e7c){if(_0x448e7c){_0x448e7c[_0xc6bc('0x18')]({'lastMsgAt':_0xf83e49['createdAt'],'lastMsgDirection':_0xf83e49[_0xc6bc('0x11')][_0xc6bc('0x12')](),'lastMsgBody':_0xf83e49[_0xc6bc('0xd')]});}})[_0xc6bc('0x19')](function(_0x5b3a64){console['error'](_0x5b3a64);});}_0x3d001c();}},'charset':_0xc6bc('0x1a'),'collate':_0xc6bc('0x1b')});};