Built motion from commit (unavailable).|2.5.22
[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 _0x8c0f=['findOne','MailInteractionId','update','catch','utf8mb4','util','../../config/logger','moment','bluebird','request-promise','html-to-text','rimraf','../../config/environment','./mailMessage.attributes','exports','define','MailMessage','messageId','fti_mail_messages','plainBody','subject','FULLTEXT','body','fromString','models','get','direction','toLowerCase','out','secret','isNil','UserId'];(function(_0xe73080,_0x24c56d){var _0x12cbc4=function(_0x1377e2){while(--_0x1377e2){_0xe73080['push'](_0xe73080['shift']());}};_0x12cbc4(++_0x24c56d);}(_0x8c0f,0xa5));var _0xf8c0=function(_0x47a0d3,_0x2398b1){_0x47a0d3=_0x47a0d3-0x0;var _0x20d918=_0x8c0f[_0x47a0d3];return _0x20d918;};'use strict';var _=require('lodash');var util=require(_0xf8c0('0x0'));var logger=require(_0xf8c0('0x1'))('api');var moment=require(_0xf8c0('0x2'));var BPromise=require(_0xf8c0('0x3'));var rp=require(_0xf8c0('0x4'));var htmlToText=require(_0xf8c0('0x5'));var fs=require('fs');var path=require('path');var rimraf=require(_0xf8c0('0x6'));var config=require(_0xf8c0('0x7'));var attributes=require(_0xf8c0('0x8'));module[_0xf8c0('0x9')]=function(_0x3d8419,_0x5d9cf2){return _0x3d8419[_0xf8c0('0xa')](_0xf8c0('0xb'),attributes,{'tableName':'mail_messages','paranoid':![],'indexes':[{'name':_0xf8c0('0xc'),'fields':['messageId']},{'name':_0xf8c0('0xd'),'fields':[_0xf8c0('0xe'),_0xf8c0('0xf')],'type':_0xf8c0('0x10')}],'timestamps':!![],'hooks':{'beforeCreate':function(_0x53ec12,_0x4b34ec,_0x102178){if(_0x53ec12[_0xf8c0('0x11')]){_0x53ec12[_0xf8c0('0xe')]=htmlToText[_0xf8c0('0x12')](_0x53ec12[_0xf8c0('0x11')],{'preserveNewlines':!![],'singleNewLineParagraphs':!![],'uppercaseHeadings':![],'noLinkBrackets':!![],'ignoreImage':!![]});}_0x102178(null,_0x4b34ec);},'afterCreate':function(_0x4c011d,_0x9f73ca,_0x872e3c){var _0x11231f=_0x3d8419[_0xf8c0('0x13')];var _0x2e7395=_0x4c011d[_0xf8c0('0x14')]({'plain':!![]});if(_0x2e7395['direction']['toLowerCase']()==='in'||_0x2e7395[_0xf8c0('0x15')][_0xf8c0('0x16')]()===_0xf8c0('0x17')&&!_0x2e7395[_0xf8c0('0x18')]&&!_[_0xf8c0('0x19')](_0x2e7395[_0xf8c0('0x1a')])){_0x11231f['MailInteraction'][_0xf8c0('0x1b')]({'where':{'id':_0x2e7395[_0xf8c0('0x1c')]}})['then'](function(_0x5c33c2){if(_0x5c33c2){_0x5c33c2[_0xf8c0('0x1d')]({'lastMsgAt':_0x2e7395['createdAt'],'lastMsgDirection':_0x2e7395[_0xf8c0('0x15')][_0xf8c0('0x16')](),'lastMsgBody':_0x2e7395[_0xf8c0('0x11')]});}})[_0xf8c0('0x1e')](function(_0x2492ea){console['error'](_0x2492ea);});}_0x872e3c();}},'charset':_0xf8c0('0x1f'),'collate':'utf8mb4_unicode_ci'});};