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/app/models/server/raw/LivechatDepartment.js

82 lines
1.7 KiB

import { escapeRegExp } from '@rocket.chat/string-helpers';
import { BaseRaw } from './BaseRaw';
export class LivechatDepartmentRaw extends BaseRaw {
findInIds(departmentsIds, options) {
const query = { _id: { $in: departmentsIds } };
return this.find(query, options);
}
findByNameRegexWithExceptionsAndConditions(searchTerm, exceptions = [], conditions = {}, options = {}) {
if (!Array.isArray(exceptions)) {
exceptions = [exceptions];
}
const nameRegex = new RegExp(`^${ escapeRegExp(searchTerm).trim() }`, 'i');
const query = {
name: nameRegex,
_id: {
$nin: exceptions,
},
...conditions,
};
return this.find(query, options);
}
[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
findByBusinessHourId(businessHourId, options) {
const query = { businessHourId };
return this.find(query, options);
}
findEnabledByBusinessHourId(businessHourId, options) {
const query = { businessHourId, enabled: true };
return this.find(query, options);
}
addBusinessHourToDepartmentsByIds(ids = [], businessHourId) {
[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
const query = {
_id: { $in: ids },
};
const update = {
$set: {
businessHourId,
},
};
return this.col.update(query, update, { multi: true });
}
removeBusinessHourFromDepartmentsByIdsAndBusinessHourId(ids = [], businessHourId) {
const query = {
_id: { $in: ids },
businessHourId,
};
const update = {
$unset: {
businessHourId: 1,
},
};
return this.col.update(query, update, { multi: true });
}
[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
removeBusinessHourFromDepartmentsByBusinessHourId(businessHourId) {
const query = {
businessHourId,
};
const update = {
$unset: {
businessHourId: 1,
},
};
return this.col.update(query, update, { multi: true });
}
}