Skip to content

Commit

Permalink
Merge branch 'develop' into chore/rewrite-app-logs
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Oct 15, 2022
2 parents c13278f + b2a3408 commit 10cb2ed
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 23 deletions.
20 changes: 6 additions & 14 deletions apps/meteor/app/lib/server/startup/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1563,20 +1563,12 @@ settingsRegistry.addGroup('Layout', function () {
enterprise: true,
public: true,
});
this.add(
'Layout_Home_Body',
'<p>~~~~ Default html example ~~~~</p>\n<strong>Welcome to (ENTER ORGANIZATION NAME HERE)</strong>\n\n<p>All general communications should be done through #general</p>\n<p>find more information <a href="INSERT LINK" target="_blank" rel="noopener">here</a></p>',
{
type: 'code',
enableQuery: {
_id: 'Layout_Custom_Body',
value: true,
},
code: 'text/html',
multiline: true,
public: true,
},
);
this.add('Layout_Home_Body', '', {
type: 'code',
code: 'text/html',
multiline: true,
public: true,
});
this.add('Layout_Terms_of_Service', 'Terms of Service <br> Go to APP SETTINGS &rarr; Layout to customize this page.', {
type: 'code',
code: 'text/html',
Expand Down
33 changes: 33 additions & 0 deletions apps/meteor/app/livechat/server/hooks/afterUserActions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { IUser } from '@rocket.chat/core-typings';
import { Users } from '@rocket.chat/models';
import type { UsersUpdateParamsPOST } from '@rocket.chat/rest-typings';

import { callbacks } from '../../../../lib/callbacks';

type UserData = UsersUpdateParamsPOST['data'] & { _id: string };

const handleAgentUpdated = async (userData: UserData) => {
if (!userData?.roles?.includes('livechat-agent')) {
await Users.unsetExtension(userData._id);
}
};

const handleDeactivateUser = async (userData: IUser) => {
if (userData?.roles?.includes('livechat-agent')) {
await Users.unsetExtension(userData._id);
}
};

callbacks.add(
'afterSaveUser',
(user: UserData) => Promise.await(handleAgentUpdated(user)),
callbacks.priority.LOW,
'livechat-after-save-user-remove-extension',
);

callbacks.add(
'afterDeactivateUser',
(user: IUser) => Promise.await(handleDeactivateUser(user)),
callbacks.priority.LOW,
'livechat-after-deactivate-user-remove-extension',
);
1 change: 1 addition & 0 deletions apps/meteor/app/livechat/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import './hooks/markRoomNotResponded';
import './hooks/sendTranscriptOnClose';
import './hooks/saveContactLastChat';
import './hooks/saveLastMessageToInquiry';
import './hooks/afterUserActions';
import './methods/addAgent';
import './methods/addManager';
import './methods/changeLivechatStatus';
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/livechat/server/lib/Livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ export const Livechat = {
Users.removeLivechatData(_id);
this.setUserStatusLivechat(_id, 'not-available');
LivechatDepartmentAgents.removeByAgentId(_id);
Promise.await(LivechatVisitors.removeContactManagerByUsername(username));
Promise.await(Promise.all([LivechatVisitors.removeContactManagerByUsername(username), UsersRaw.unsetExtension(_id)]));
return true;
}

Expand Down
6 changes: 1 addition & 5 deletions apps/meteor/client/views/home/CustomHomePageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { useSetting } from '@rocket.chat/ui-contexts';
import React, { ReactElement } from 'react';

const CustomHomePageContent = (): ReactElement | null => {
const body = useSetting('Layout_Home_Body') as string;

if (!body) {
return null;
}
const body = String(useSetting('Layout_Home_Body'));

return <Box withRichContent dangerouslySetInnerHTML={{ __html: body }} />;
};
Expand Down
9 changes: 6 additions & 3 deletions apps/meteor/client/views/home/DefaultHomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const DefaultHomePage = (): ReactElement => {
const canAddUsers = usePermission('view-user-administration');
const canCreateChannel = useAtLeastOnePermission(CREATE_CHANNEL_PERMISSIONS);
const workspaceName = useSetting('Site_Name');
const displayCustomBody = Boolean(useSetting('Layout_Home_Body'));

return (
<Page data-qa='page-home' data-qa-type='default' background='tint'>
Expand Down Expand Up @@ -56,9 +57,11 @@ const DefaultHomePage = (): ReactElement => {
<DocumentationCard />
</HomepageGridItem>
</Grid>
<Box mbs='x16'>
<CustomHomePageContent />
</Box>
{displayCustomBody && (
<Box mbs='x16'>
<CustomHomePageContent />
</Box>
)}
</PageScrollableContent>
</Page>
);
Expand Down

0 comments on commit 10cb2ed

Please sign in to comment.