Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove meteor startup from livechat-enterprise #34995

Merged
merged 3 commits into from
Feb 3, 2025
Merged
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion apps/meteor/app/livechat-enterprise/client/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { hasLicense } from '../../license/client';
import './startup';

void hasLicense('livechat-enterprise').then((enabled) => {
if (!enabled) {
22 changes: 0 additions & 22 deletions apps/meteor/app/livechat-enterprise/client/startup.ts

This file was deleted.

24 changes: 24 additions & 0 deletions apps/meteor/app/livechat-enterprise/hooks/useLivechatEnterprise.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { useSetting } from '@rocket.chat/ui-contexts';
import { useEffect } from 'react';

import { useHasLicenseModule } from '../../../client/hooks/useHasLicenseModule';
import { businessHourManager } from '../../livechat/client/views/app/business-hours/BusinessHours';
import type { IBusinessHourBehavior } from '../../livechat/client/views/app/business-hours/IBusinessHourBehavior';
import { SingleBusinessHourBehavior } from '../../livechat/client/views/app/business-hours/Single';
import { MultipleBusinessHoursBehavior } from '../client/views/business-hours/Multiple';

const businessHours: Record<string, IBusinessHourBehavior> = {
multiple: new MultipleBusinessHoursBehavior(),
single: new SingleBusinessHourBehavior(),
};

export const useLivechatEnterprise = () => {
const businessHourType = useSetting('Livechat_business_hour_type') as string;
const hasLicense = useHasLicenseModule('livechat-enterprise');

useEffect(() => {
if (businessHourType && hasLicense) {
businessHourManager.registerBusinessHourBehavior(businessHours[businessHourType.toLowerCase()]);
}
}, [businessHourType, hasLicense]);
};
2 changes: 2 additions & 0 deletions apps/meteor/client/views/root/AppLayout.tsx
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import { useEscapeKeyStroke } from './hooks/useEscapeKeyStroke';
import { useGoogleTagManager } from './hooks/useGoogleTagManager';
import { useMessageLinkClicks } from './hooks/useMessageLinkClicks';
import { useAnalytics } from '../../../app/analytics/client/loadScript';
import { useLivechatEnterprise } from '../../../app/livechat-enterprise/hooks/useLivechatEnterprise';
import { useNextcloud } from '../../../app/nextcloud/client/useNextcloud';
import { useAnalyticsEventTracking } from '../../hooks/useAnalyticsEventTracking';
import { useLoadRoomForAllowedAnonymousRead } from '../../hooks/useLoadRoomForAllowedAnonymousRead';
@@ -29,6 +30,7 @@ const AppLayout = () => {
useLoadRoomForAllowedAnonymousRead();
useNotifyUser();

useLivechatEnterprise();
useNextcloud();

const layout = useSyncExternalStore(appLayout.subscribe, appLayout.getSnapshot);

Unchanged files with check annotations Beta

const api = this;
(operations[method as keyof Operations<TPathPattern, TOptions>] as Record<string, any>).action =
async function _internalRouteActionHandler() {
this.requestIp = getRequestIP(this.request)!;

Check warning on line 565 in apps/meteor/app/api/server/api.ts

GitHub Actions / 🔎 Code Check / Code Lint

Forbidden non-null assertion
if (options.authRequired || options.authOrAnonRequired) {
const user = await api.authenticatedRoute(this.request);
this.user = user!;

Check warning on line 569 in apps/meteor/app/api/server/api.ts

GitHub Actions / 🔎 Code Check / Code Lint

Forbidden non-null assertion
this.userId = String(this.request.headers['x-user-id']);
this.token = (this.request.headers['x-auth-token'] &&

Check warning on line 571 in apps/meteor/app/api/server/api.ts

GitHub Actions / 🔎 Code Check / Code Lint

Forbidden non-null assertion
Accounts._hashLoginToken(String(this.request.headers['x-auth-token'])))!;
}
connection,
};
Accounts._setAccountData(connection.id, 'loginToken', this.token!);

Check warning on line 648 in apps/meteor/app/api/server/api.ts

GitHub Actions / 🔎 Code Check / Code Lint

Forbidden non-null assertion
this.userId &&
(await api.processTwoFactor({
const { modifiedCount } = await updateAuditedByUser({
_id: this.userId,
username: this.user.username!,

Check warning on line 42 in apps/meteor/app/api/server/v1/assets.ts

GitHub Actions / 🔎 Code Check / Code Lint

Forbidden non-null assertion
ip: this.requestIp,
useragent: this.request.headers['user-agent'] || '',
})(Settings.updateValueById, key, value);
const { modifiedCount } = await updateAuditedByUser({
_id: this.userId,
username: this.user.username!,

Check warning on line 79 in apps/meteor/app/api/server/v1/assets.ts

GitHub Actions / 🔎 Code Check / Code Lint

Forbidden non-null assertion
ip: this.requestIp,
useragent: this.request.headers['user-agent'] || '',
})(Settings.updateValueById, key, value);
const auditSettingOperation = updateAuditedByUser({
_id: this.userId,
username: this.user.username!,

Check warning on line 689 in apps/meteor/app/api/server/v1/misc.ts

GitHub Actions / 🔎 Code Check / Code Lint

Forbidden non-null assertion
ip: this.requestIp,
useragent: this.request.headers['user-agent'] || '',
});
return resetAuditedSettingByUser({
_id: this.userId,
username: this.user.username!,

Check warning on line 709 in apps/meteor/app/api/server/v1/misc.ts

GitHub Actions / 🔎 Code Check / Code Lint

Forbidden non-null assertion
ip: this.requestIp,
useragent: this.request.headers['user-agent'] || '',
})(Settings.resetValueById, settingId);
const auditSettingOperation = updateAuditedByUser({
_id: this.userId,
username: this.user.username!,

Check warning on line 213 in apps/meteor/app/api/server/v1/settings.ts

GitHub Actions / 🔎 Code Check / Code Lint

Forbidden non-null assertion
ip: this.requestIp,
useragent: this.request.headers['user-agent'] || '',
});
const room = await Rooms.findOneById(rid);
await Room.beforeTopicChange(room!);

Check warning on line 25 in apps/meteor/app/channel-settings/server/functions/saveRoomTopic.ts

GitHub Actions / 🔎 Code Check / Code Lint

Forbidden non-null assertion
const update = await Rooms.setTopicById(rid, roomTopic);
if (update && sendMessage) {