-'use strict';
-
-var _ = require('lodash');
-var md5 = require('md5');
-var moment = require('moment');
-
-var User = require('../../models').User;
-var ChatRoom = require('../../models').ChatRoom;
-var ChatMessage = require('../../models').ChatMessage;
-var ChatVisitor = require('../../models').ChatVisitor;
-var UserHasChatRoom = require('../../models').UserHasChatRoom;
-
-
-// Get list of chat_rooms
-exports.index = function (req, res) {
- return ChatRoom
- .findAll({
- include: [{
- model: User,
- attributes: ['id', 'name', 'fullname', 'email', 'role', 'internal']
- }, {
- model: ChatMessage
- }, {
- model: ChatVisitor
- }]
- })
- .then(function (chat_rooms) {
- return res.status(200).send(chat_rooms);
- })
- .catch(function (err) {
- return handleError(res, err);
- });
-};
-
-// Get list of my chat_rooms
-exports.me = function (req, res) {
- return User
- .findById(req.user.id)
- .then(function (user) {
- return user
- .getChatRooms({
- include: [{
- model: ChatVisitor,
- attributes: ['id', 'fullname', 'email']
- }, {
- model: User,
- attributes: ['id', 'name', 'fullname', 'email', 'role', 'internal']
- }]
- });
- })
- .then(function (chatRooms) {
- if (!chatRooms) {
- return res.sendStatus(404);
- }
- return res.send(chatRooms);
- })
- .catch(function (err) {
- return handleError(res, err);
- });
-};
-
-// Get a single chatRoom
-exports.show = function (req, res) {
- return ChatRoom
- .findById(req.params.id, {
- include: [{
- model: ChatMessage,
- include: [{
- model: ChatVisitor,
- attributes: ['id', 'email', 'fullname']
- }, {
- model: User,
- attributes: ['id', 'email', 'name', 'fullname']
- }]
- }, {
- model: User,
- attributes: ['id', 'email', 'name', 'fullname']
- }]
- })
- .then(function (chatRoom) {
- if (!chatRoom) {
- return res.sendStatus(404);
- }
- return res.send(chatRoom);
- })
- .catch(function (err) {
- return handleError(res, err);
- });
-};
-
-// Get a single chatRoom by users
-exports.getRoomByUsers = function (req, res, next) {
-
- var _chatRoom;
-
- return ChatRoom
- .findOrCreate({
- where: {
- token: md5(JSON.stringify(req.query.users.sort())).toString('base64')
- },
- defaults: {
- type: 'internal',
- token: md5(JSON.stringify(req.query.users.sort())).toString('base64'),
- status: 'open'
- },
- include: [{
- model: ChatMessage,
- include: [{
- model: ChatVisitor,
- attributes: ['id', 'email', 'fullname']
- }, {
- model: User,
- attributes: ['id', 'name', 'fullname', 'email', 'role', 'internal']
- }]
- }, {
- model: User,
- attributes: ['id', 'name', 'fullname', 'email', 'role', 'internal']
- }]
- })
- .spread(function (chatRoom, created) {
- _chatRoom = chatRoom;
- // _chatRoom.dataValues.ChatMessages = [];
- if (created) {
- return _chatRoom
- .setUsers(req.query.users);
- } else {
- return;
- }
- })
- .then(function () {
- return _chatRoom
- .getUsers();
- })
- .then(function (users) {
- return res.status(200).send(_.merge(_chatRoom.dataValues, {
- Users: users
- }));
- })
- .catch(function (err) {
- return handleError(res, err);
- });
-};
-
-// Get a single chatRoom
-exports.getRoomByType = function (req, res) {
- User
- .findById(req.user.id)
- .then(function (user) {
- user
- .getChatRooms({
- where: {
- type: req.params.type
- },
- include: [{
- model: ChatVisitor,
- attributes: ['id', 'fullname', 'email']
- }]
- })
- .then(function (chatRooms) {
- if (!chatRooms) {
- return res.sendStatus(404);
- }
- return res.send(chatRooms);
- })
- .catch(function (err) {
- return handleError(res, err);
- });
- })
- .catch(function (err) {
- return handleError(res, err);
- });
-};
-
-// Get a single chatRoom
-exports.getRoomGroups = function (req, res) {
- User
- .findById(req.user.id)
- .then(function (user) {
- user
- .getChatRooms({
- include: [{
- model: ChatVisitor,
- attributes: ['id', 'fullname', 'email']
- }, {
- model: User,
- attributes: ['id', 'name', 'fullname', 'email', 'role', 'internal']
- }]
- })
- .then(function (chatRooms) {
- if (!chatRooms) {
- return res.sendStatus(404);
- }
- return res.send(chatRooms);
- })
- .catch(function (err) {
- return handleError(res, err);
- });
- })
- .catch(function (err) {
- return handleError(res, err);
- });
-};
-
-// Creates a new chatRoom in the DB.
-exports.create = function (req, res) {
- // if (req.body.to) {
- //
- // var token;
- // var participants = {
- // users: {
- // ids: []
- // },
- // visitor: {}
- // };
- //
- // switch (req.body.type) {
- // case 'internal':
- //
- // if (!req.body.to.isArray) {
- // req.body.to = [parseInt(req.body.to, 10)];
- // }
- //
- // participants.users.ids = req.body.to;
- //
- // if (!_.contains(req.body.to, req.user.id)) {
- // participants.users.ids.push(req.user.id);
- // }
- //
- // participants.users.ids.sort();
- //
- // token = md5(JSON.stringify(participants)).toString(
- // 'base64');
- //
- // participants.users.fullnames = [];
- //
- // User
- // .findAll({
- // where: {
- // id: {
- // $in: req.body.to
- // }
- // },
- // attributes: ['id', 'fullname']
- // })
- // .then(function(users) {
- //
- // _.sortBy(users, 'id').forEach(function(item, index) {
- // participants.users.fullnames.push(item.fullname);
- // });
- //
- // ChatRoom
- // .findOrCreate({
- // where: {
- // token: token
- // },
- // defaults: _.merge({
- // token: token,
- // participants: JSON.stringify(participants)
- // }, req.body),
- // include: [{
- // model: ChatMessage
- // }]
- // })
- // .spread(function(chatRoom, created) {
- //
- // if (created) {
- // chatRoom
- // .setUsers(participants.users.ids)
- // .then(function() {
- // return res.status(201).send(chatRoom);
- // })
- // .catch(function(err) {
- // return handleError(res, err);
- // });
- // } else {
- // return res.status(201).send(chatRoom);
- // }
- //
- // })
- // .catch(function(err) {
- // return handleError(res, err);
- // });
- // })
- // .catch(function(err) {
- // return handleError(res, err);
- // });
- //
- // break;
- // case 'external':
- //
- // participants.visitor.id = req.body.to;
- // participants.users.ids.push(req.user.id);
- // participants.users.ids.sort();
- //
- // token = md5(JSON.stringify(participants)).toString('base64');
- //
- // participants.users.fullnames = [req.user.fullname];
- //
- // ChatVisitor
- // .findById(req.body.to, {
- // attributes: ['id', 'fullname', 'email', 'referer']
- // })
- // .then(function(chatVisitor) {
- // participants.visitor.fullname = chatVisitor.fullname;
- // participants.visitor.referer = chatVisitor.referer;
- // participants.visitor.email = chatVisitor.email;
- //
- // ChatRoom
- // .findOrCreate({
- // where: {
- // token: token
- // },
- // defaults: _.merge({
- // token: token,
- // participants: JSON.stringify(participants)
- // }, req.body),
- // include: [{
- // model: ChatMessage
- // }, {
- // model: ChatVisitor
- // }, {
- // model: User,
- // }]
- // })
- // .spread(function(chatRoom, created) {
- // if (created) {
- //
- // chatRoom
- // .setUsers(participants.users.ids, {
- // individualHooks: true
- // })
- // .then(function() {
- // chatRoom
- // .setChatVisitor(participants.visitor.id)
- // .then(function() {
- // return res.status(201).send(chatRoom);
- // })
- // .catch(function(err) {
- // return handleError(res, err);
- // });
- // })
- // .catch(function(err) {
- // return handleError(res, err);
- // });
- // } else {
- // return res.status(201).send(chatRoom);
- // }
- //
- // })
- // .catch(function(err) {
- // return handleError(res, err);
- // });
- // })
- // .catch(function(err) {
- // return handleError(res, err);
- // });
- //
- // break;
- // default:
- // }
- // } else {
- // return handleError(res, new Error('field "to" omitted'));
- // }
-};
-
-// Updates an existing chatRoom in the DB.
-exports.update = function (req, res) {
- if (req.body.id) {
- delete req.body.id;
- }
-
- ChatRoom
- .findById(req.params.id)
- .then(function (chatRoom) {
- if (!chatRoom) {
- return res.sendStatus(404);
- }
- var updated = _.merge(chatRoom, req.body);
- updated
- .save()
- .then(function () {
- return res.status(200).send(chatRoom);
- })
- .catch(function (err) {
- return handleError(res, err);
- });
- })
- .catch(function (err) {
- return handleError(res, err);
- });
-};
-
-// Updates an existing chatRoom in the DB.
-exports.updateUsers = function (req, res) {
- var _chatRoom;
-
- if (req.body.id) {
- delete req.body.id;
- }
-
- return ChatRoom
- .findById(req.params.id)
- .then(function (chatRoom) {
- if (!chatRoom || !req.body.users) {
- return res.sendStatus(404);
- }
- return chatRoom;
- })
- .then(function (chatRoom) {
- return chatRoom
- .update({
- token: md5(JSON.stringify(req.body.users.sort())).toString('base64')
- });
- })
- .then(function (chatRoom) {
- _chatRoom = chatRoom;
- return chatRoom
- .setUsers(req.body.users.sort(), {
- individualHooks: true
- });
- })
- .then(function () {
- return _chatRoom
- .getUsers();
- })
- .then(function (users) {
- return res.status(200).send(_.merge(_chatRoom.dataValues, {
- Users: users,
- ChatMessages: []
- }));
- })
- .catch(function (err) {
- return handleError(res, err);
- });
-};
-
-// Deletes a chatRoom from the DB.
-exports.destroy = function (req, res) {
- ChatRoom
- .findById(req.params.id)
- .then(function (chatRoom) {
- if (!chatRoom) {
- return res.sendStatus(404);
- }
-
- chatRoom
- .destroy()
- .then(function () {
- return res.sendStatus(204);
- })
- .catch(function (err) {
- return handleError(res, err);
- });
- })
- .catch(function (err) {
- return handleError(res, err);
- });
-};
-
-function handleError(res, err) {
- return res.status(500).send(err);
-}
+var _0x5861=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x6D\x64\x35","\x6D\x6F\x6D\x65\x6E\x74","\x74\x6F\x2D\x63\x73\x76","\x75\x74\x69\x6C","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x75\x74\x69\x6C","\x55\x73\x65\x72","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x43\x68\x61\x74\x4D\x65\x73\x73\x61\x67\x65","\x43\x68\x61\x74\x57\x65\x62\x73\x69\x74\x65","\x43\x68\x61\x74\x41\x70\x70\x6C\x69\x63\x61\x74\x69\x6F\x6E","\x43\x68\x61\x74\x51\x75\x65\x75\x65","\x43\x68\x61\x74\x56\x69\x73\x69\x74\x6F\x72","\x4C\x69\x73\x74","\x55\x73\x65\x72\x48\x61\x73\x43\x68\x61\x74\x52\x6F\x6F\x6D","\x69\x6E\x64\x65\x78","\x6C\x6F\x67","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x71\x75\x65\x72\x79","\x67\x65\x74\x51\x75\x65\x72\x79","\x69\x64","\x6E\x61\x6D\x65","\x66\x75\x6C\x6C\x6E\x61\x6D\x65","\x65\x6D\x61\x69\x6C","\x72\x6F\x6C\x65","\x69\x6E\x74\x65\x72\x6E\x61\x6C","\x6D\x65\x72\x67\x65","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x64\x65\x73\x63\x72\x69\x62\x65","\x6D\x61\x70","\x67\x65\x74\x4D\x61\x69\x6C\x51\x75\x65\x75\x65\x73\x49\x64\x42\x79\x55\x73\x65\x72","\x66\x69\x6E\x64\x42\x79\x49\x64","\x75\x73\x65\x72","\x75\x6E\x6D\x61\x6E\x61\x67\x65\x64","\x55\x4E\x4D\x41\x4E\x41\x47\x45\x44","\x64\x61\x79","\x73\x74\x61\x72\x74\x4F\x66","\x63\x6F\x75\x6E\x74","\x61\x6C\x6C","\x75\x70\x64\x61\x74\x65\x50\x61\x74\x63\x68","\x74\x61\x67\x73","\x62\x6F\x64\x79","\x2C","\x73\x70\x6C\x69\x74","\x70\x61\x72\x61\x6D\x73","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x75\x70\x64\x61\x74\x65","\x24\x61\x6E\x64","\x69\x73\x41\x72\x72\x61\x79","\x6C\x65\x6E\x67\x74\x68","\x25","\x3B\x25","\x70\x75\x73\x68","\x67\x65\x74\x41\x67\x65\x6E\x74\x73","\x67\x65\x74\x41\x67\x65\x6E\x74\x73\x49\x64\x42\x79\x55\x73\x65\x72","\x73\x63\x6F\x70\x65","\x67\x65\x74\x47\x72\x6F\x75\x70\x73","\x67\x72\x6F\x75\x70","\x61\x67\x65\x6E\x74","\x75\x73\x65\x72\x70\x69\x63","\x66\x69\x6E\x64\x41\x6C\x6C","\x67\x65\x74\x45\x78\x74\x65\x72\x6E\x61\x6C\x73","\x65\x78\x74\x65\x72\x6E\x61\x6C","\x69\x6E\x63\x6C\x75\x64\x65","\x67\x65\x74\x41\x67\x65\x6E\x74","\x67\x65\x74\x4F\x6E\x6C\x69\x6E\x65\x52\x6F\x6F\x6D","\x6F\x6E\x6C\x69\x6E\x65","\x6D\x65","\x65\x72\x72\x6F\x72","\x67\x65\x74\x43\x68\x61\x74\x52\x6F\x6F\x6D\x73","\x73\x68\x6F\x77","\x61\x64\x64\x72\x65\x73\x73","\x67\x65\x74\x52\x6F\x6F\x6D\x42\x79\x55\x73\x65\x72\x73","\x64\x61\x74\x61\x56\x61\x6C\x75\x65\x73","\x67\x65\x74\x55\x73\x65\x72\x73","\x75\x73\x65\x72\x73","\x73\x65\x74\x55\x73\x65\x72\x73","\x73\x70\x72\x65\x61\x64","\x62\x61\x73\x65\x36\x34","\x73\x6F\x72\x74","\x73\x74\x72\x69\x6E\x67\x69\x66\x79","\x4F\x50\x45\x4E","\x66\x69\x6E\x64\x4F\x72\x43\x72\x65\x61\x74\x65","\x63\x72\x65\x61\x74\x65\x4D\x65\x73\x73\x61\x67\x65","\x74\x79\x70\x65","\x63\x72\x65\x61\x74\x65","\x65\x78\x70\x6F\x72\x74","\x20","\x72\x65\x70\x6C\x61\x63\x65","\x63\x72\x65\x61\x74\x65\x64\x41\x74","\x66\x6F\x72\x45\x61\x63\x68","\x43\x68\x61\x74\x4D\x65\x73\x73\x61\x67\x65\x73","\x74\x65\x78\x74\x2F\x63\x73\x76","\x67\x65\x74\x52\x6F\x6F\x6D\x42\x79\x54\x79\x70\x65","\x67\x65\x74\x52\x6F\x6F\x6D\x47\x72\x6F\x75\x70\x73","\x75\x70\x64\x61\x74\x65\x55\x73\x65\x72\x73","\x64\x65\x73\x74\x72\x6F\x79"];_0x5861[0];var _=require(_0x5861[1]);var md5=require(_0x5861[2]);var moment=require(_0x5861[3]);var csv=require(_0x5861[4]);var util=require(_0x5861[5]);var Util=require(_0x5861[6]);var User=require(_0x5861[8])[_0x5861[7]];var Agent=require(_0x5861[8])[_0x5861[7]];var ChatRoom=require(_0x5861[8])[_0x5861[9]];var ChatMessage=require(_0x5861[8])[_0x5861[10]];var ChatWebsite=require(_0x5861[8])[_0x5861[11]];var ChatApplication=require(_0x5861[8])[_0x5861[12]];var ChatQueue=require(_0x5861[8])[_0x5861[13]];var ChatVisitor=require(_0x5861[8])[_0x5861[14]];var List=require(_0x5861[8])[_0x5861[15]];var UserHasChatRoom=require(_0x5861[8])[_0x5861[16]];exports[_0x5861[17]]= function(_0xbfaax11,_0xbfaax12,_0xbfaax13){return ChatRoom[_0x5861[32]](_[_0x5861[31]](Util[_0x5861[24]](_0xbfaax11[_0x5861[23]]),{include:[{model:User,attributes:[_0x5861[25],_0x5861[26],_0x5861[27],_0x5861[28],_0x5861[29],_0x5861[30]]},{model:ChatMessage},{model:ChatVisitor}]}))[_0x5861[22]](function(_0xbfaax15){_0xbfaax12[_0x5861[21]](200)[_0x5861[20]](_0xbfaax15)})[_0x5861[19]](function(_0xbfaax14){console[_0x5861[18]](_0xbfaax14);return handleError(_0xbfaax12,_0xbfaax14)})};exports[_0x5861[33]]= function(_0xbfaax11,_0xbfaax12){return ChatRoom[_0x5861[33]]()[_0x5861[22]](function(_0xbfaax16){return _0xbfaax12[_0x5861[21]](200)[_0x5861[20]](_0xbfaax16)})[_0x5861[19]](function(_0xbfaax14){return handleError(_0xbfaax12,_0xbfaax14)})};function getChatQueues(_0xbfaax18){return function(){switch(_0xbfaax18[_0x5861[29]]){case _0x5861[37]:return User[_0x5861[36]](_0xbfaax18[_0x5861[25]],{attributes:[_0x5861[25]]})[_0x5861[22]](Util[_0x5861[35]]({},{attributes:[_0x5861[25]]}))[_0x5861[22]](function(_0xbfaax19){return {include:{model:ChatWebsite,include:{model:ChatApplication,include:{model:ChatQueue,where:{id:_[_0x5861[34]](_0xbfaax19,_0x5861[25])}}}}}});default:return {}}}}exports[_0x5861[38]]= function(_0xbfaax11,_0xbfaax12){return Promise[_0x5861[43]]([])[_0x5861[22]](getChatQueues(_0xbfaax11[_0x5861[37]]))[_0x5861[22]](function(_0xbfaax1b){return ChatRoom[_0x5861[42]](_[_0x5861[31]](Util[_0x5861[24]](_0xbfaax11[_0x5861[23]],{status:_0x5861[39],updatedAt:{$gte:moment()[_0x5861[41]](_0x5861[40])}}),_0xbfaax1b))})[_0x5861[22]](function(_0xbfaax1a){return _0xbfaax12[_0x5861[21]](200)[_0x5861[20]]({value:_0xbfaax1a})})[_0x5861[19]](function(_0xbfaax14){console[_0x5861[18]](_0xbfaax14);return handleError(_0xbfaax12,_0xbfaax14)})};exports[_0x5861[44]]= function(_0xbfaax11,_0xbfaax12,_0xbfaax13){var _0xbfaax1c={tags:_0xbfaax11[_0x5861[46]][_0x5861[45]]};var _0xbfaax1d={where:{id:_0xbfaax11[_0x5861[49]][_0x5861[25]][_0x5861[48]](_0x5861[47])}};return ChatRoom[_0x5861[51]](_0xbfaax1c,_0xbfaax1d)[_0x5861[22]](function(_0xbfaax1e){if(!_0xbfaax1e){return _0xbfaax12[_0x5861[50]](404)};return _0xbfaax1e})[_0x5861[22]](function(_0xbfaax1e){return _0xbfaax12[_0x5861[50]](200)})[_0x5861[19]](function(_0xbfaax14){return handleError(_0xbfaax12,_0xbfaax14)})};function checkTags(_0xbfaax20){if(_0xbfaax20){if(_0xbfaax20[_0x5861[45]]){_0xbfaax20[_0x5861[52]]= [];if(_[_0x5861[53]](_0xbfaax20[_0x5861[45]])){for(var _0xbfaax21=0;_0xbfaax21< _0xbfaax20[_0x5861[45]][_0x5861[54]];_0xbfaax21++){_0xbfaax20[_0x5861[52]][_0x5861[57]]({tags:{$like:_0x5861[55]+ _0xbfaax20[_0x5861[45]][_0xbfaax21]+ _0x5861[56]}})}}else {_0xbfaax20[_0x5861[52]][_0x5861[57]]({tags:{$like:_0x5861[55]+ _0xbfaax20[_0x5861[45]]+ _0x5861[56]}})};delete _0xbfaax20[_0x5861[45]]}}}exports[_0x5861[58]]= function(_0xbfaax11,_0xbfaax12,_0xbfaax13){switch(_0xbfaax11[_0x5861[37]][_0x5861[29]]){case _0x5861[37]:return User[_0x5861[36]](_0xbfaax11[_0x5861[37]][_0x5861[25]],{attributes:[_0x5861[25]],where:{id:{$ne:_0xbfaax11[_0x5861[37]][_0x5861[25]]},online:true}})[_0x5861[22]](Util[_0x5861[59]](_[_0x5861[31]](_0xbfaax11[_0x5861[23]],{id:{$ne:_0xbfaax11[_0x5861[37]][_0x5861[25]]}})))[_0x5861[22]](function(_0xbfaax15){return _0xbfaax12[_0x5861[21]](200)[_0x5861[20]](_0xbfaax15)})[_0x5861[19]](function(_0xbfaax14){return handleError(_0xbfaax12,_0xbfaax14)});default:return User[_0x5861[60]](_0x5861[43])[_0x5861[32]](_[_0x5861[31]](Util[_0x5861[24]](_0xbfaax11[_0x5861[23]]),{where:{id:{$ne:_0xbfaax11[_0x5861[37]][_0x5861[25]]},online:true}}))[_0x5861[22]](function(_0xbfaax15){return _0xbfaax12[_0x5861[21]](200)[_0x5861[20]](_0xbfaax15)})[_0x5861[19]](function(_0xbfaax14){return handleError(_0xbfaax12,_0xbfaax14)})}};exports[_0x5861[61]]= function(_0xbfaax11,_0xbfaax12,_0xbfaax13){checkTags(_0xbfaax11[_0x5861[23]]);var _0xbfaax22={where:_[_0x5861[31]]({type:_0x5861[62]},_0xbfaax11[_0x5861[23]])};switch(_0xbfaax11[_0x5861[37]][_0x5861[29]]){case _0x5861[63]:_[_0x5861[31]](_0xbfaax22,{include:[{model:User,attributes:[_0x5861[25]],where:{id:_0xbfaax11[_0x5861[37]][_0x5861[25]]}}]});break;default:};return ChatRoom[_0x5861[65]](_0xbfaax22)[_0x5861[22]](function(_0xbfaax1e){return ChatRoom[_0x5861[65]]({where:{id:{$in:_[_0x5861[34]](_0xbfaax1e,_0x5861[25])}},include:[{model:User,attributes:[_0x5861[25],_0x5861[26],_0x5861[27],_0x5861[29],_0x5861[64]]},{model:ChatVisitor}]})})[_0x5861[22]](function(_0xbfaax1e){return _0xbfaax12[_0x5861[21]](200)[_0x5861[20]]({rows:_0xbfaax1e,count:_0xbfaax1e[_0x5861[54]]})})[_0x5861[19]](function(_0xbfaax14){return handleError(_0xbfaax12,_0xbfaax14)})};exports[_0x5861[66]]= function(_0xbfaax11,_0xbfaax12,_0xbfaax13){checkTags(_0xbfaax11[_0x5861[23]]);var _0xbfaax22={where:_[_0x5861[31]]({type:_0x5861[67]},_0xbfaax11[_0x5861[23]]),include:[{model:ChatVisitor,attributes:[_0x5861[25],_0x5861[27]]}]};switch(_0xbfaax11[_0x5861[37]][_0x5861[29]]){case _0x5861[63]:_0xbfaax22[_0x5861[68]][_0x5861[57]]({model:User,attributes:[_0x5861[25]],where:{id:_0xbfaax11[_0x5861[37]][_0x5861[25]]}});break;default:};return ChatRoom[_0x5861[65]](_0xbfaax22)[_0x5861[22]](function(_0xbfaax1e){return _0xbfaax12[_0x5861[21]](200)[_0x5861[20]]({rows:_0xbfaax1e,count:_0xbfaax1e[_0x5861[54]]})})[_0x5861[19]](function(_0xbfaax14){return handleError(_0xbfaax12,_0xbfaax14)})};exports[_0x5861[69]]= function(_0xbfaax11,_0xbfaax12,_0xbfaax13){return User[_0x5861[60]](_0x5861[43])[_0x5861[36]](_0xbfaax11[_0x5861[49]][_0x5861[25]])[_0x5861[22]](function(_0xbfaax15){return _0xbfaax12[_0x5861[21]](200)[_0x5861[20]](_0xbfaax15)})[_0x5861[19]](function(_0xbfaax14){return handleError(_0xbfaax12,_0xbfaax14)})};exports[_0x5861[70]]= function(_0xbfaax11,_0xbfaax12,_0xbfaax13){return ChatRoom[_0x5861[60]](_0x5861[71])[_0x5861[32]](_[_0x5861[31]](Util[_0x5861[24]](_0xbfaax11[_0x5861[23]]),{include:[{model:User,attributes:[_0x5861[25],_0x5861[26],_0x5861[27],_0x5861[28],_0x5861[29],_0x5861[30]]},{model:ChatMessage},{model:ChatVisitor}]}))[_0x5861[22]](function(_0xbfaax15){_0xbfaax12[_0x5861[21]](200)[_0x5861[20]](_0xbfaax15)})[_0x5861[19]](function(_0xbfaax14){console[_0x5861[18]](_0xbfaax14);return handleError(_0xbfaax12,_0xbfaax14)})};exports[_0x5861[72]]= function(_0xbfaax11,_0xbfaax12){return User[_0x5861[36]](_0xbfaax11[_0x5861[37]][_0x5861[25]])[_0x5861[22]](function(_0xbfaax18){return _0xbfaax18[_0x5861[74]]({include:[{model:ChatVisitor,attributes:[_0x5861[25],_0x5861[27],_0x5861[28]]},{model:User,attributes:[_0x5861[25],_0x5861[26],_0x5861[27],_0x5861[28],_0x5861[29],_0x5861[30]]}]})})[_0x5861[22]](function(_0xbfaax1e){if(!_0xbfaax1e){return _0xbfaax12[_0x5861[50]](404)};return _0xbfaax12[_0x5861[20]](_0xbfaax1e)})[_0x5861[19]](function(_0xbfaax14){console[_0x5861[73]](_0xbfaax14);return handleError(_0xbfaax12,_0xbfaax14)})};exports[_0x5861[75]]= function(_0xbfaax11,_0xbfaax12){return ChatRoom[_0x5861[36]](_0xbfaax11[_0x5861[49]][_0x5861[25]],{include:[{model:ChatMessage,include:[{model:ChatVisitor,attributes:[_0x5861[25],_0x5861[28],_0x5861[27]]},{model:User,attributes:[_0x5861[25],_0x5861[28],_0x5861[26],_0x5861[27],_0x5861[64],_0x5861[29],_0x5861[30]]}]},{model:User,attributes:[_0x5861[25],_0x5861[28],_0x5861[26],_0x5861[27],_0x5861[64],_0x5861[29],_0x5861[30]]},{model:ChatVisitor},{model:ChatWebsite,attributes:[_0x5861[25],_0x5861[26],_0x5861[76]],include:[List]}]})[_0x5861[22]](function(_0xbfaax23){if(!_0xbfaax23){return _0xbfaax12[_0x5861[50]](404)};return _0xbfaax12[_0x5861[20]](_0xbfaax23)})[_0x5861[19]](function(_0xbfaax14){return handleError(_0xbfaax12,_0xbfaax14)})};exports[_0x5861[77]]= function(_0xbfaax11,_0xbfaax12,_0xbfaax13){var _0xbfaax24;return ChatRoom[_0x5861[87]]({where:{token:md5(JSON[_0x5861[85]](_0xbfaax11[_0x5861[23]][_0x5861[80]][_0x5861[84]]())).toString(_0x5861[83])},defaults:{type:_0x5861[30],token:md5(JSON[_0x5861[85]](_0xbfaax11[_0x5861[23]][_0x5861[80]][_0x5861[84]]())).toString(_0x5861[83]),status:_0x5861[86]},include:[{model:ChatMessage,include:[{model:ChatVisitor,attributes:[_0x5861[25],_0x5861[28],_0x5861[27]]},{model:User,attributes:[_0x5861[25],_0x5861[26],_0x5861[27],_0x5861[28],_0x5861[29],_0x5861[30]]}]},{model:User,attributes:[_0x5861[25],_0x5861[26],_0x5861[27],_0x5861[28],_0x5861[29],_0x5861[30]]}]})[_0x5861[82]](function(_0xbfaax23,_0xbfaax26){_0xbfaax24= _0xbfaax23;if(_0xbfaax26){return _0xbfaax24[_0x5861[81]](_0xbfaax11[_0x5861[23]][_0x5861[80]])}})[_0x5861[22]](function(){return _0xbfaax24[_0x5861[79]]()})[_0x5861[22]](function(_0xbfaax25){return _0xbfaax12[_0x5861[21]](200)[_0x5861[20]](_[_0x5861[31]](_0xbfaax24[_0x5861[78]],{Users:_0xbfaax25}))})[_0x5861[19]](function(_0xbfaax14){return handleError(_0xbfaax12,_0xbfaax14)})};exports[_0x5861[88]]= function(_0xbfaax11,_0xbfaax12,_0xbfaax13){var _0xbfaax24;return ChatRoom[_0x5861[36]](_0xbfaax11[_0x5861[49]][_0x5861[25]])[_0x5861[22]](function(_0xbfaax23){_0xbfaax24= _0xbfaax23;if(!_0xbfaax24){return _0xbfaax12[_0x5861[50]](404)}})[_0x5861[22]](function(){return ChatMessage[_0x5861[90]](_[_0x5861[31]](_0xbfaax11[_0x5861[46]],{type:_0xbfaax24[_0x5861[89]],ChatRoomId:_0xbfaax11[_0x5861[49]][_0x5861[25]],UserId:_0xbfaax11[_0x5861[37]][_0x5861[25]]}))})[_0x5861[22]](function(_0xbfaax27){return _0xbfaax12[_0x5861[21]](200)[_0x5861[20]](_0xbfaax27)})[_0x5861[19]](function(_0xbfaax14){return handleError(_0xbfaax12,_0xbfaax14)})};exports[_0x5861[91]]= function(_0xbfaax11,_0xbfaax12,_0xbfaax13){return ChatRoom[_0x5861[36]](_0xbfaax11[_0x5861[49]][_0x5861[25]],{include:[{model:ChatMessage,include:[{model:ChatVisitor,attributes:[_0x5861[25],_0x5861[27]]},{model:User,attributes:[_0x5861[25],_0x5861[27]]}]}]})[_0x5861[22]](function(_0xbfaax23){var _0xbfaax28=[];_0xbfaax23[_0x5861[96]][_0x5861[95]](function(_0xbfaax27){_0xbfaax28[_0x5861[57]]({name:_0xbfaax27[_0x5861[7]]?_0xbfaax27[_0x5861[7]][_0x5861[27]]:_0xbfaax27[_0x5861[14]][_0x5861[27]],text:_0xbfaax27[_0x5861[46]][_0x5861[93]](/(\r\n|\n|\r)/gm,_0x5861[92]),date:_0xbfaax27[_0x5861[94]]})});return _0xbfaax12[_0x5861[89]](_0x5861[97])[_0x5861[21]](200)[_0x5861[20]](csv(_0xbfaax28))})[_0x5861[19]](function(_0xbfaax14){return handleError(_0xbfaax12,_0xbfaax14)})};exports[_0x5861[98]]= function(_0xbfaax11,_0xbfaax12){return User[_0x5861[36]](_0xbfaax11[_0x5861[37]][_0x5861[25]])[_0x5861[22]](function(_0xbfaax18){return _0xbfaax18[_0x5861[74]]({where:{type:_0xbfaax11[_0x5861[49]][_0x5861[89]]},include:[{model:ChatVisitor,attributes:[_0x5861[25],_0x5861[27],_0x5861[28]]}]})})[_0x5861[22]](function(_0xbfaax1e){if(!_0xbfaax1e){return _0xbfaax12[_0x5861[50]](404)};return _0xbfaax12[_0x5861[20]](_0xbfaax1e)})[_0x5861[19]](function(_0xbfaax14){return handleError(_0xbfaax12,_0xbfaax14)})};exports[_0x5861[99]]= function(_0xbfaax11,_0xbfaax12){return User[_0x5861[36]](_0xbfaax11[_0x5861[37]][_0x5861[25]])[_0x5861[22]](function(_0xbfaax18){return _0xbfaax18[_0x5861[74]]({include:[{model:ChatVisitor,attributes:[_0x5861[25],_0x5861[27],_0x5861[28]]},{model:User,attributes:[_0x5861[25],_0x5861[26],_0x5861[27],_0x5861[28],_0x5861[29],_0x5861[30]]}]})})[_0x5861[22]](function(_0xbfaax1e){if(!_0xbfaax1e){return _0xbfaax12[_0x5861[50]](404)};return _0xbfaax12[_0x5861[20]](_0xbfaax1e)})[_0x5861[19]](function(_0xbfaax14){return handleError(_0xbfaax12,_0xbfaax14)})};exports[_0x5861[90]]= function(_0xbfaax11,_0xbfaax12){};exports[_0x5861[51]]= function(_0xbfaax11,_0xbfaax12){if(_0xbfaax11[_0x5861[46]][_0x5861[25]]){delete _0xbfaax11[_0x5861[46]][_0x5861[25]]};return ChatRoom[_0x5861[36]](_0xbfaax11[_0x5861[49]][_0x5861[25]])[_0x5861[22]](function(_0xbfaax23){if(!_0xbfaax23){return _0xbfaax12[_0x5861[50]](404)};return _0xbfaax23[_0x5861[51]](_0xbfaax11[_0x5861[46]])})[_0x5861[22]](function(_0xbfaax23){return _0xbfaax12[_0x5861[21]](200)[_0x5861[20]](_0xbfaax23)})[_0x5861[19]](function(_0xbfaax14){return handleError(_0xbfaax12,_0xbfaax14)})};exports[_0x5861[100]]= function(_0xbfaax11,_0xbfaax12){var _0xbfaax24;if(_0xbfaax11[_0x5861[46]][_0x5861[25]]){delete _0xbfaax11[_0x5861[46]][_0x5861[25]]};return ChatRoom[_0x5861[36]](_0xbfaax11[_0x5861[49]][_0x5861[25]])[_0x5861[22]](function(_0xbfaax23){if(!_0xbfaax23|| !_0xbfaax11[_0x5861[46]][_0x5861[80]]){return _0xbfaax12[_0x5861[50]](404)};return _0xbfaax23})[_0x5861[22]](function(_0xbfaax23){return _0xbfaax23[_0x5861[51]]({type:_0x5861[62],token:md5(JSON[_0x5861[85]](_0xbfaax11[_0x5861[46]][_0x5861[80]][_0x5861[84]]())).toString(_0x5861[83])})})[_0x5861[22]](function(_0xbfaax23){_0xbfaax24= _0xbfaax23;return _0xbfaax23[_0x5861[81]](_0xbfaax11[_0x5861[46]][_0x5861[80]][_0x5861[84]](),{individualHooks:true})})[_0x5861[22]](function(){return _0xbfaax24[_0x5861[79]]()})[_0x5861[22]](function(_0xbfaax25){_[_0x5861[31]](_0xbfaax24[_0x5861[78]],{Users:_0xbfaax25});return _0xbfaax12[_0x5861[21]](200)[_0x5861[20]](_0xbfaax24)})[_0x5861[19]](function(_0xbfaax14){return handleError(_0xbfaax12,_0xbfaax14)})};exports[_0x5861[101]]= function(_0xbfaax11,_0xbfaax12){return ChatRoom[_0x5861[36]](_0xbfaax11[_0x5861[49]][_0x5861[25]])[_0x5861[22]](function(_0xbfaax23){if(!_0xbfaax23){return _0xbfaax12[_0x5861[50]](404)};return _0xbfaax23[_0x5861[101]]()})[_0x5861[22]](function(){return _0xbfaax12[_0x5861[50]](204)})[_0x5861[19]](function(_0xbfaax14){return handleError(_0xbfaax12,_0xbfaax14)})};function handleError(_0xbfaax12,_0xbfaax14){console[_0x5861[18]](_0xbfaax14);return _0xbfaax12[_0x5861[21]](500)[_0x5861[20]](_0xbfaax14)}
\ No newline at end of file