Skip to content

Commit

Permalink
Merge branch 'develop' into fix/bh-manual-offline-not-available
Browse files Browse the repository at this point in the history
  • Loading branch information
murtaza98 authored Jun 22, 2023
2 parents 6d86cf4 + f38211a commit 4726200
Show file tree
Hide file tree
Showing 82 changed files with 723 additions and 392 deletions.
5 changes: 5 additions & 0 deletions .changeset/cool-roses-melt.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": minor
---

feat: Save deprecation usage on prometheus
5 changes: 5 additions & 0 deletions .changeset/early-bikes-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": minor
---

feat: Quick reactions on message toolbox
5 changes: 5 additions & 0 deletions .changeset/five-clouds-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fix: Wrong IP usage on monolith TCP transporter configuration
5 changes: 5 additions & 0 deletions .changeset/friendly-terms-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fix: self dm is not found with `im.messages`
5 changes: 5 additions & 0 deletions .changeset/kind-experts-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

fixed a bug where sometimes a room would not load part of its messages.
5 changes: 5 additions & 0 deletions .changeset/kind-insects-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Avoid invalid time ranges when adding/editing a Business Hour
5 changes: 5 additions & 0 deletions .changeset/light-toys-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixed Omnichannel making an excessive amount of requests to room.info
6 changes: 6 additions & 0 deletions .changeset/little-ligers-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": patch
"@rocket.chat/model-typings": patch
---

fix: Dept w/o any BH config do not adhere to the default BH rules.
5 changes: 5 additions & 0 deletions .changeset/pink-carrots-matter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixed ENOTFOUND error in k8s deployments
5 changes: 5 additions & 0 deletions .changeset/rare-goats-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': minor
---

Fix dates translations
2 changes: 1 addition & 1 deletion .github/workflows/new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
- uses: dtinth/setup-github-actions-caching-for-turbo@v1

- name: Build
run: yarn build
run: yarn build [email protected]/release-action

- name: Start next release
if: ${{ github.event.inputs.name == 'next' }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- uses: dtinth/setup-github-actions-caching-for-turbo@v1

- name: Build
run: yarn build
run: yarn build [email protected]/release-action

- name: Publish final release
uses: ./packages/release-action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ export const getRoomByNameOrIdWithOptionToJoin = async ({
});
}

const rid = isObject(roomUser) ? [user._id, roomUser._id].sort().join('') : nameOrId;
room = await Rooms.findOneById(rid);
room = isObject(roomUser)
? await Rooms.findOneDirectRoomContainingAllUserIDs([...new Set([user._id, roomUser._id])])
: await Rooms.findOneById(nameOrId);

// If the room hasn't been found yet, let's try some more
if (!isObject(room)) {
Expand All @@ -55,7 +56,7 @@ export const getRoomByNameOrIdWithOptionToJoin = async ({
}
}

await createDirectMessage([roomUser.username], user._id);
const { rid } = await createDirectMessage([roomUser.username], user._id);

return Rooms.findOneById(rid);
}
Expand Down
13 changes: 13 additions & 0 deletions apps/meteor/app/lib/server/lib/deprecationWarningLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Response } from 'meteor/rocketchat:restivus';
import semver from 'semver';

import { Logger } from '../../../logger/server';
import { metrics } from '../../../metrics/server';

const deprecationLogger = new Logger('DeprecationWarning');

Expand Down Expand Up @@ -32,6 +33,8 @@ export const apiDeprecationLogger = ((logger) => {

writeDeprecationHeader(res, 'endpoint-deprecation', message, version);

metrics.deprecations.inc({ type: 'deprecation', kind: 'endpoint', name: endpoint });

logger.warn(message);
},
parameter: (
Expand All @@ -49,6 +52,8 @@ export const apiDeprecationLogger = ((logger) => {
}) ?? `The parameter "${parameter}" in the endpoint "${endpoint}" is deprecated and will be removed on version ${version}`;
compareVersions(version, message);

metrics.deprecations.inc({ type: 'parameter-deprecation', kind: 'endpoint', name: endpoint, params: parameter });

writeDeprecationHeader(res, 'parameter-deprecation', message, version);

logger.warn(message);
Expand All @@ -71,6 +76,8 @@ export const apiDeprecationLogger = ((logger) => {
}) ?? `The usage of the endpoint "${endpoint}" is deprecated and will be removed on version ${version}`;
compareVersions(version, message);

metrics.deprecations.inc({ type: 'invalid-usage', kind: 'endpoint', name: endpoint, params: parameter });

writeDeprecationHeader(res, 'invalid-usage', message, version);

logger.warn(message);
Expand All @@ -83,10 +90,14 @@ export const methodDeprecationLogger = ((logger) => {
method: (method: string, version: string, info = '') => {
const message = `The method "${method}" is deprecated and will be removed on version ${version}${info ? ` (${info})` : ''}`;
compareVersions(version, message);
metrics.deprecations.inc({ type: 'deprecation', name: method, kind: 'method' });
logger.warn(message);
},
parameter: (method: string, parameter: string, version: string) => {
const message = `The parameter "${parameter}" in the method "${method}" is deprecated and will be removed on version ${version}`;

metrics.deprecations.inc({ type: 'parameter-deprecation', name: method, params: parameter });

compareVersions(version, message);
logger.warn(message);
},
Expand All @@ -106,6 +117,8 @@ export const methodDeprecationLogger = ((logger) => {
}) ?? `The usage of the method "${method}" is deprecated and will be removed on version ${version}`;
compareVersions(version, message);

metrics.deprecations.inc({ type: 'invalid-usage', name: method, params: parameter, kind: 'method' });

logger.warn(message);
},
/** @deprecated */
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/livechat/client/lib/stream/queueManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const events = {
}

LivechatInquiry.upsert({ _id: inquiry._id }, { ...inquiry, alert: true, _updatedAt: new Date(inquiry._updatedAt) });
await queryClient.invalidateQueries({ queryKey: ['rooms', inquiry.rid], exact: true });
await queryClient.invalidateQueries(['/v1/rooms.info', inquiry.rid]);
},
removed: (inquiry: ILivechatInquiryRecord) => LivechatInquiry.remove(inquiry._id),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,19 @@ export abstract class AbstractBusinessHourType {
}

private convertWorkHours(businessHourData: ILivechatBusinessHour): ILivechatBusinessHour {
console.log('convertWorkHours', businessHourData);
businessHourData.workHours.forEach((hour: any) => {
const startUtc = moment.tz(`${hour.day}:${hour.start}`, 'dddd:HH:mm', businessHourData.timezone.name).utc();
const finishUtc = moment.tz(`${hour.day}:${hour.finish}`, 'dddd:HH:mm', businessHourData.timezone.name).utc();

if (hour.open && finishUtc.isBefore(startUtc)) {
throw new Error('error-business-hour-finish-time-before-start-time');
}

if (hour.open && startUtc.isSame(finishUtc)) {
throw new Error('error-business-hour-finish-time-equals-start-time');
}

hour.start = {
time: hour.start,
utc: {
Expand Down
5 changes: 5 additions & 0 deletions apps/meteor/app/metrics/server/lib/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ import client from 'prom-client';
const percentiles = [0.01, 0.1, 0.9, 0.99];

export const metrics = {
deprecations: new client.Counter({
name: 'rocketchat_deprecations',
labelNames: ['type', 'kind', 'name', 'params'],
help: 'cumulated number of deprecations being used',
}),
metricsRequests: new client.Counter({
name: 'rocketchat_metrics_requests',
labelNames: ['notification_type'],
Expand Down
1 change: 0 additions & 1 deletion apps/meteor/app/slashcommands-inviteall/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ function inviteAll<T extends string>(type: T): SlashCommand<T>['callback'] {
void api.broadcast('notify.ephemeralMessage', userId, message.rid, {
msg: i18n.t('Users_added', { lng }),
});
return;
} catch (e: any) {
const msg = e.error === 'cant-invite-for-direct-room' ? 'Cannot_invite_users_to_direct_rooms' : e.error;
void api.broadcast('notify.ephemeralMessage', userId, message.rid, {
Expand Down
8 changes: 4 additions & 4 deletions apps/meteor/app/threads/client/flextab/threadlist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { BadgeProps } from '@rocket.chat/fuselage';
import type { IRoom, ISubscription } from '@rocket.chat/core-typings';
import { isRoomFederated } from '@rocket.chat/core-typings';
import { useSetting } from '@rocket.chat/ui-contexts';
import { Header } from '@rocket.chat/ui-client';
import { HeaderToolboxAction, HeaderToolboxActionBadge } from '@rocket.chat/ui-client';

import { addAction } from '../../../../client/views/room/lib/Toolbox';

Expand Down Expand Up @@ -45,9 +45,9 @@ addAction('thread', (options) => {
const unread = tunread > 99 ? '99+' : tunread;
const variant = getVariant(tunreadUser, tunreadGroup);
return (
<Header.ToolBox.Action {...props}>
{!!unread && <Header.ToolBox.ActionBadge variant={variant}>{unread}</Header.ToolBox.ActionBadge>}
</Header.ToolBox.Action>
<HeaderToolboxAction {...props}>
{!!unread && <HeaderToolboxActionBadge variant={variant}>{unread}</HeaderToolboxActionBadge>}
</HeaderToolboxAction>
);
},
order: 2,
Expand Down
19 changes: 7 additions & 12 deletions apps/meteor/app/ui-utils/client/lib/RoomHistoryManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class RoomHistoryManagerClass extends Emitter {
unreadNotLoaded: ReactiveVar<number>;
firstUnread: ReactiveVar<IMessage | undefined>;
loaded: number | undefined;
oldestTs?: Date;
}
> = {};

Expand Down Expand Up @@ -122,7 +123,6 @@ class RoomHistoryManagerClass extends Emitter {
}

public async getMore(rid: IRoom['_id'], limit = defaultLimit): Promise<void> {
let ts;
const room = this.getRoom(rid);

if (Tracker.nonreactive(() => room.hasMore.get()) !== true) {
Expand All @@ -133,24 +133,14 @@ class RoomHistoryManagerClass extends Emitter {

await this.queue();

// ScrollListener.setLoader true
const lastMessage = ChatMessage.findOne({ rid, _hidden: { $ne: true } }, { sort: { ts: 1 } });
// lastMessage ?= ChatMessage.findOne({rid: rid}, {sort: {ts: 1}})

if (lastMessage) {
({ ts } = lastMessage);
} else {
ts = undefined;
}

let ls = undefined;

const subscription = ChatSubscription.findOne({ rid });
if (subscription) {
({ ls } = subscription);
}

const result = await callWithErrorHandling('loadHistory', rid, ts, limit, ls ? String(ls) : undefined, false);
const result = await callWithErrorHandling('loadHistory', rid, room.oldestTs, limit, ls ? String(ls) : undefined, false);

if (!result) {
throw new Error('loadHistory returned nothing');
Expand All @@ -164,6 +154,10 @@ class RoomHistoryManagerClass extends Emitter {
room.unreadNotLoaded.set(result.unreadNotLoaded);
room.firstUnread.set(result.firstUnread);

if (messages.length > 0) {
room.oldestTs = messages[messages.length - 1].ts;
}

const wrapper = await waitForElement('.messages-box .wrapper .rc-scrollbars-view');

if (wrapper) {
Expand Down Expand Up @@ -268,6 +262,7 @@ class RoomHistoryManagerClass extends Emitter {
room.isLoading.set(true);
room.hasMore.set(true);
room.hasMoreNext.set(false);
room.oldestTs = undefined;
room.loaded = undefined;
}

Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/client/components/Page/PageHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, IconButton } from '@rocket.chat/fuselage';
import { Header as TemplateHeader } from '@rocket.chat/ui-client';
import { HeaderToolbox } from '@rocket.chat/ui-client';
import { useLayout, useTranslation } from '@rocket.chat/ui-contexts';
import type { FC, ComponentProps, ReactNode } from 'react';
import React, { useContext } from 'react';
Expand Down Expand Up @@ -37,9 +37,9 @@ const PageHeader: FC<PageHeaderProps> = ({ children = undefined, title, onClickB
{...props}
>
{isMobile && (
<TemplateHeader.ToolBox>
<HeaderToolbox>
<BurgerMenu />
</TemplateHeader.ToolBox>
</HeaderToolbox>
)}
{onClickBack && <IconButton small mie='x8' icon='arrow-back' onClick={onClickBack} title={t('Back')} />}
<Box is='h1' fontScale='h2' flexGrow={1} id='PageHeader-title' data-qa-type='PageHeader-title'>
Expand Down
15 changes: 15 additions & 0 deletions apps/meteor/client/components/message/toolbox/Toolbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import React, { memo, useMemo } from 'react';

import type { MessageActionContext } from '../../../../app/ui-utils/client/lib/MessageAction';
import { MessageAction } from '../../../../app/ui-utils/client/lib/MessageAction';
import { sdk } from '../../../../app/utils/client/lib/SDKClient';
import { useEmojiPickerData } from '../../../contexts/EmojiPickerContext';
import EmojiElement from '../../../views/composer/EmojiPicker/EmojiElement';
import { useIsSelecting } from '../../../views/room/MessageList/contexts/SelectedMessagesContext';
import { useAutoTranslate } from '../../../views/room/MessageList/hooks/useAutoTranslate';
import { useChat } from '../../../views/room/contexts/ChatContext';
Expand Down Expand Up @@ -52,6 +55,7 @@ const Toolbox = ({ message, messageContext, room, subscription }: ToolboxProps):
const mapSettings = useMemo(() => Object.fromEntries(settings.map((setting) => [setting._id, setting.value])), [settings]);

const chat = useChat();
const { addRecentEmoji, emojiListByCategory } = useEmojiPickerData();

const actionsQueryResult = useQuery(['rooms', room._id, 'messages', message._id, 'actions'] as const, async () => {
const messageActions = await MessageAction.getButtons(
Expand All @@ -78,8 +82,19 @@ const Toolbox = ({ message, messageContext, room, subscription }: ToolboxProps):
return null;
}

const handleSetReaction = (emoji: string) => {
sdk.call('setReaction', `:${emoji}:`, message._id);
addRecentEmoji(emoji);
};

const recentList = emojiListByCategory.filter(({ key }) => key === 'recent')[0].emojis.list;

return (
<MessageToolbox>
{recentList.length > 0 &&
recentList.slice(0, 3).map(({ emoji, image }) => {
return <EmojiElement small key={emoji} title={emoji} emoji={emoji} image={image} onClick={() => handleSetReaction(emoji)} />;
})}
{actionsQueryResult.data?.message.map((action) => (
<MessageToolboxItem
onClick={(e): void => action.action(e, { message, tabbar: toolbox, room, chat, autoTranslateOptions })}
Expand Down
25 changes: 25 additions & 0 deletions apps/meteor/client/contexts/EmojiPickerContext.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import { createContext, useContext } from 'react';

import type { EmojiByCategory } from '../../app/emoji/client';

type EmojiPickerContextValue = {
open: (ref: Element, callback: (emoji: string) => void) => void;
isOpen: boolean;
close: () => void;
emojiToPreview: { emoji: string; name: string } | null;
handlePreview: (emoji: string, name: string) => void;
handleRemovePreview: () => void;
addRecentEmoji: (emoji: string) => void;
emojiListByCategory: EmojiByCategory[];
recentEmojis: string[];
setRecentEmojis: (emoji: string[]) => void;
actualTone: number;
currentCategory: string;
setCurrentCategory: (category: string) => void;
customItemsLimit: number;
setCustomItemsLimit: (limit: number) => void;
setActualTone: (tone: number) => void;
};

export const EmojiPickerContext = createContext<EmojiPickerContextValue | undefined>(undefined);
Expand All @@ -30,3 +42,16 @@ export const usePreviewEmoji = () => ({
handlePreview: useEmojiPickerContext().handlePreview,
handleRemovePreview: useEmojiPickerContext().handleRemovePreview,
});

export const useEmojiPickerData = () => ({
addRecentEmoji: useEmojiPickerContext().addRecentEmoji,
emojiListByCategory: useEmojiPickerContext().emojiListByCategory,
recentEmojis: useEmojiPickerContext().recentEmojis,
setRecentEmojis: useEmojiPickerContext().setRecentEmojis,
actualTone: useEmojiPickerContext().actualTone,
currentCategory: useEmojiPickerContext().currentCategory,
setCurrentCategory: useEmojiPickerContext().setCurrentCategory,
customItemsLimit: useEmojiPickerContext().customItemsLimit,
setCustomItemsLimit: useEmojiPickerContext().setCustomItemsLimit,
setActualTone: useEmojiPickerContext().setActualTone,
});
Loading

0 comments on commit 4726200

Please sign in to comment.