Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2c2e02c
chore: adds a deprecation warning for livechat:saveBusinessHour
lucas-a-pelegrino Dec 3, 2025
0f1cc99
feat: implements a new endpoint to handle business hours saving
lucas-a-pelegrino Dec 4, 2025
55719ab
feat: implements a new endpoint to handle business hours saving
lucas-a-pelegrino Dec 4, 2025
85bc094
tests: replace business hour e2e tests to use the new endpoint
lucas-a-pelegrino Dec 5, 2025
e2b7687
tests: adds minor fixes to test data handling
lucas-a-pelegrino Dec 5, 2025
f5c3c3b
tests: adds minor improvement to business hours helper functions
lucas-a-pelegrino Dec 5, 2025
b3a0a21
tests: adds minor changes to helper functions to adhere to endpoint i…
lucas-a-pelegrino Dec 8, 2025
7b32374
tests: adds logging to check response in ci
lucas-a-pelegrino Dec 8, 2025
d11300c
docs: adds .changeset
lucas-a-pelegrino Dec 8, 2025
78e734e
tests: fixes and minor improvements
lucas-a-pelegrino Dec 8, 2025
98f3683
tests: fixes to helper functions object structures
lucas-a-pelegrino Dec 8, 2025
91064c1
tests: adds more adjustments to helper functions objects
lucas-a-pelegrino Dec 9, 2025
4d4dfb6
tests: adds a minor fix to createBusinessHour helper func for the UI …
lucas-a-pelegrino Dec 9, 2025
8e2856b
Merge branch 'chore/CORE-1550' of github.com:RocketChat/Rocket.Chat i…
lucas-a-pelegrino Dec 9, 2025
9d4cc14
chore: adds deprecation warning to livechat:removeBusinessHour meteor…
lucas-a-pelegrino Dec 10, 2025
a0acc3e
chore: implements new endpoint to replace legacy method
lucas-a-pelegrino Dec 10, 2025
c808d8b
chore: updates client to use new endpoint
lucas-a-pelegrino Dec 10, 2025
7fe955a
tests: updates tests to use new endpoint
lucas-a-pelegrino Dec 10, 2025
07e3ffe
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into chor…
lucas-a-pelegrino Dec 10, 2025
a874e47
docs: adds .changeset
lucas-a-pelegrino Dec 10, 2025
6456b7f
fix: bad identation
lucas-a-pelegrino Dec 10, 2025
6ece6b9
Merge remote-tracking branch 'origin/chore/CORE-1413' into chore/CORE…
lucas-a-pelegrino Dec 10, 2025
84c3441
Merge branch 'develop' into chore/CORE-1413
kodiakhq[bot] Dec 11, 2025
b2995f2
Merge branch 'develop' into chore/CORE-1413
kodiakhq[bot] Dec 11, 2025
745ee1c
Merge branch 'develop' into chore/CORE-1413
kodiakhq[bot] Dec 11, 2025
f276a21
Merge branch 'develop' into chore/CORE-1413
kodiakhq[bot] Dec 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/weak-frogs-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": patch
"@rocket.chat/rest-typings": patch
---

Adds deprecation warning for `livechat:removeBusinessHour` and new endpoint to replace it; `livechat/business-hours.remove`
56 changes: 39 additions & 17 deletions apps/meteor/app/livechat/imports/server/rest/businessHours.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import type { ILivechatBusinessHour } from '@rocket.chat/core-typings';
import {
isGETBusinessHourParams,
isPOSTLivechatBusinessHoursSaveParams,
isPOSTLivechatBusinessHoursRemoveParams,
POSTLivechatBusinessHoursRemoveSuccessResponse,
POSTLivechatBusinessHoursSaveSuccessResponse,
validateBadRequestErrorResponse,
validateUnauthorizedErrorResponse,
Expand All @@ -26,26 +28,46 @@ API.v1.addRoute(
},
);

const livechatBusinessHoursEndpoints = API.v1.post(
'livechat/business-hours.save',
{
response: {
200: POSTLivechatBusinessHoursSaveSuccessResponse,
400: validateBadRequestErrorResponse,
401: validateUnauthorizedErrorResponse,
const livechatBusinessHoursEndpoints = API.v1
.post(
'livechat/business-hours.save',
{
response: {
200: POSTLivechatBusinessHoursSaveSuccessResponse,
400: validateBadRequestErrorResponse,
401: validateUnauthorizedErrorResponse,
},
authRequired: true,
body: isPOSTLivechatBusinessHoursSaveParams,
},
authRequired: true,
body: isPOSTLivechatBusinessHoursSaveParams,
},
async function action() {
const params = this.bodyParams;
async function action() {
const params = this.bodyParams;

// TODO: Remove typecasting after refactoring saveBusinessHour logic with proper type logic. See: CORE-1552
const result = await businessHourManager.saveBusinessHour(params as unknown as ILivechatBusinessHour);
// TODO: Remove typecasting after refactoring saveBusinessHour logic with proper type logic. See: CORE-1552
const result = await businessHourManager.saveBusinessHour(params as unknown as ILivechatBusinessHour);

return API.v1.success(result);
}
);
return API.v1.success(result);
}
)
.post(
'livechat/business-hours.remove',
{
response: {
200: POSTLivechatBusinessHoursRemoveSuccessResponse,
400: validateBadRequestErrorResponse,
401: validateUnauthorizedErrorResponse,
},
authRequired: true,
body: isPOSTLivechatBusinessHoursRemoveParams,
},
async function action() {
const { _id, type } = this.bodyParams;

await businessHourManager.removeBusinessHourByIdAndType(_id, type);

return API.v1.success();
}
);

type LivechatBusinessHoursEndpoints = ExtractRoutesFromAPI<typeof livechatBusinessHoursEndpoints>;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { useEffectEvent } from '@rocket.chat/fuselage-hooks';
import { GenericModal } from '@rocket.chat/ui-client';
import { useSetModal, useToastMessageDispatch, useMethod } from '@rocket.chat/ui-contexts';
import { useSetModal, useToastMessageDispatch, useEndpoint } from '@rocket.chat/ui-contexts';
import { useQueryClient } from '@tanstack/react-query';
import { useTranslation } from 'react-i18next';

export const useRemoveBusinessHour = () => {
const { t } = useTranslation();
const setModal = useSetModal();
const dispatchToastMessage = useToastMessageDispatch();
const removeBusinessHour = useMethod('livechat:removeBusinessHour');
const removeBusinessHour = useEndpoint('POST', '/v1/livechat/business-hours.remove');
const queryClient = useQueryClient();

const handleRemove = useEffectEvent((_id: string, type: string) => {
const onDeleteBusinessHour = async () => {
try {
await removeBusinessHour(_id, type);
await removeBusinessHour({ _id, type });
dispatchToastMessage({ type: 'success', message: t('Business_Hour_Removed') });
queryClient.invalidateQueries({
queryKey: ['livechat-getBusinessHours'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { ServerMethods } from '@rocket.chat/ddp-client';
import { Meteor } from 'meteor/meteor';

import { hasPermissionAsync } from '../../../../../app/authorization/server/functions/hasPermission';
import { methodDeprecationLogger } from '../../../../../app/lib/server/lib/deprecationWarningLogger';
import { businessHourManager } from '../../../../../app/livechat/server/business-hour';

declare module '@rocket.chat/ddp-client' {
Expand All @@ -13,6 +14,7 @@ declare module '@rocket.chat/ddp-client' {

Meteor.methods<ServerMethods>({
async 'livechat:removeBusinessHour'(id: string, type: string) {
methodDeprecationLogger.method('livechat:removeBusinessHour', '8.0.0', '/v1/livechat/business-hours.remove');
const userId = Meteor.userId();

if (!userId || !(await hasPermissionAsync(userId, 'view-livechat-business-hours'))) {
Expand Down
15 changes: 4 additions & 11 deletions apps/meteor/tests/data/livechat/businessHours.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { LivechatBusinessHourTypes } from '@rocket.chat/core-typings';
import type { POSTLivechatBusinessHoursSaveParams } from '@rocket.chat/rest-typings';
import moment from 'moment';

import { api, credentials, methodCall, request } from '../api-data';
import { api, credentials, request } from '../api-data';
import { updateEESetting, updateSetting } from '../permissions.helper';

type ISaveBhApiWorkHour = Omit<ILivechatBusinessHour, '_id' | 'ts' | 'timezone'> & {
Expand Down Expand Up @@ -132,17 +132,10 @@ export const disableDefaultBusinessHour = async () => {
};

const removeCustomBusinessHour = async (businessHourId: string) => {
await request
.post(methodCall('livechat:removeBusinessHour'))
return request
.post(api('livechat/business-hours.remove'))
.set(credentials)
.send({
message: JSON.stringify({
params: [businessHourId, LivechatBusinessHourTypes.CUSTOM],
msg: 'method',
method: 'livechat:removeBusinessHour',
id: '101',
}),
})
.send({ _id: businessHourId, type: LivechatBusinessHourTypes.CUSTOM })
.expect(200);
};

Expand Down
37 changes: 37 additions & 0 deletions packages/rest-typings/src/v1/omnichannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3411,6 +3411,43 @@ export const POSTLivechatBusinessHoursSaveSuccessSchema = {

export const POSTLivechatBusinessHoursSaveSuccessResponse = ajv.compile<void>(POSTLivechatBusinessHoursSaveSuccessSchema);

type POSTLivechatBusinessHoursRemoveParams = {
_id: string;
type: string;
};

const POSTLivechatBusinessHoursRemoveParamsSchema = {
type: 'object',
properties: {
_id: {
type: 'string',
},
type: {
type: 'string',
},
},
required: ['_id', 'type'],
additionalProperties: false,
};

export const isPOSTLivechatBusinessHoursRemoveParams = ajv.compile<POSTLivechatBusinessHoursRemoveParams>(
POSTLivechatBusinessHoursRemoveParamsSchema,
);

export const POSTLivechatBusinessHoursRemoveSuccessSchema = {
type: 'object',
properties: {
success: {
type: 'boolean',
enum: [true],
},
},
required: ['success'],
additionalProperties: false,
};

export const POSTLivechatBusinessHoursRemoveSuccessResponse = ajv.compile<void>(POSTLivechatBusinessHoursRemoveSuccessSchema);

export const isGETLivechatTriggersParams = ajv.compile<GETLivechatTriggersParams>(GETLivechatTriggersParamsSchema);

export type GETLivechatRoomsParams = PaginatedRequest<{
Expand Down
Loading