The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/server/startup/migrations/v196.js

36 lines
819 B

import { addMigration } from '../../lib/migrations';
[NEW][ENTERPRISE] Omnichannel multiple business hours (#17947) * Change omnichannel office hours data structure * Rename omnichannel office hours templates * Renaming things from office hour to business hour * Partially remove LivechatOfficeHour model * remove obsolete setting * Remove settings from the template * Add support to cron jobs on omnichannel business hours * Add dynamic template to omnichannel business hours * Open and close business hours * Remove references to LivechatOfficeHours * Open and close business hour automatically on startup and setting changes * Improve open and close business hours process * Removing separated interfaces * Apply suggestions from review * Basic configuration to support multiple business hours * Basic business hour insert and update operations * Remove business hour * Open multiple business hours automatically when the server starts * Fix leak of business logic * Open multiple business hours * Close multiple business hour * Changing pt-br term * General improvements on business hour layout * UI improvements * Apply suggestions from review * Add departments conditions * Close business hours when remove department * Remove online verification * Refactor business hour to new data structure * Change data structure * Ignore if collection does not exist * Fix businessHourManager startup. * Remove console log. * Fix Multiple business hours * open/close business hours when removing/adding agent to department. * Improve code * Fix error on creating department. * Add set to default when it is the last department * Fix wrong condition Co-authored-by: Renato Becker <renato.augusto.becker@gmail.com>
5 years ago
import { LivechatDepartmentAgents } from '../../../app/models/server';
const removeOrphanDepartmentAgents = async () => {
const orphanAgentIds = (
await LivechatDepartmentAgents.model
.rawCollection()
.aggregate([
{
$lookup: {
from: 'rocketchat_livechat_department',
localField: 'departmentId',
foreignField: '_id',
as: 'departments',
},
},
{
$unwind: {
path: '$departments',
preserveNullAndEmptyArrays: true,
},
},
{ $match: { departments: { $exists: false } } },
])
.toArray()
).map((dept) => dept._id);
[NEW][ENTERPRISE] Omnichannel multiple business hours (#17947) * Change omnichannel office hours data structure * Rename omnichannel office hours templates * Renaming things from office hour to business hour * Partially remove LivechatOfficeHour model * remove obsolete setting * Remove settings from the template * Add support to cron jobs on omnichannel business hours * Add dynamic template to omnichannel business hours * Open and close business hours * Remove references to LivechatOfficeHours * Open and close business hour automatically on startup and setting changes * Improve open and close business hours process * Removing separated interfaces * Apply suggestions from review * Basic configuration to support multiple business hours * Basic business hour insert and update operations * Remove business hour * Open multiple business hours automatically when the server starts * Fix leak of business logic * Open multiple business hours * Close multiple business hour * Changing pt-br term * General improvements on business hour layout * UI improvements * Apply suggestions from review * Add departments conditions * Close business hours when remove department * Remove online verification * Refactor business hour to new data structure * Change data structure * Ignore if collection does not exist * Fix businessHourManager startup. * Remove console log. * Fix Multiple business hours * open/close business hours when removing/adding agent to department. * Improve code * Fix error on creating department. * Add set to default when it is the last department * Fix wrong condition Co-authored-by: Renato Becker <renato.augusto.becker@gmail.com>
5 years ago
LivechatDepartmentAgents.remove({ _id: { $in: orphanAgentIds } });
};
addMigration({
[NEW][ENTERPRISE] Omnichannel multiple business hours (#17947) * Change omnichannel office hours data structure * Rename omnichannel office hours templates * Renaming things from office hour to business hour * Partially remove LivechatOfficeHour model * remove obsolete setting * Remove settings from the template * Add support to cron jobs on omnichannel business hours * Add dynamic template to omnichannel business hours * Open and close business hours * Remove references to LivechatOfficeHours * Open and close business hour automatically on startup and setting changes * Improve open and close business hours process * Removing separated interfaces * Apply suggestions from review * Basic configuration to support multiple business hours * Basic business hour insert and update operations * Remove business hour * Open multiple business hours automatically when the server starts * Fix leak of business logic * Open multiple business hours * Close multiple business hour * Changing pt-br term * General improvements on business hour layout * UI improvements * Apply suggestions from review * Add departments conditions * Close business hours when remove department * Remove online verification * Refactor business hour to new data structure * Change data structure * Ignore if collection does not exist * Fix businessHourManager startup. * Remove console log. * Fix Multiple business hours * open/close business hours when removing/adding agent to department. * Improve code * Fix error on creating department. * Add set to default when it is the last department * Fix wrong condition Co-authored-by: Renato Becker <renato.augusto.becker@gmail.com>
5 years ago
version: 196,
up() {
Promise.await(removeOrphanDepartmentAgents());
},
});