Skip to content

Commit

Permalink
Merge branch 'develop' into change-official-docker-to-alpine
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo authored Oct 18, 2024
2 parents aadd007 + 15582b1 commit 89cdce9
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .changeset/tame-dolls-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixes message toolbar showing in End-to-end encrypted room when messages are not decrypted
18 changes: 12 additions & 6 deletions apps/meteor/app/api/server/v1/groups.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Team, isMeteorError } from '@rocket.chat/core-services';
import type { IIntegration, IUser, IRoom, RoomType } from '@rocket.chat/core-typings';
import { Integrations, Messages, Rooms, Subscriptions, Uploads, Users } from '@rocket.chat/models';
import { isGroupsOnlineProps } from '@rocket.chat/rest-typings';
import { check, Match } from 'meteor/check';
import { Meteor } from 'meteor/meteor';
import type { Filter } from 'mongodb';
Expand Down Expand Up @@ -779,23 +780,28 @@ API.v1.addRoute(
// TODO: CACHE: same as channels.online
API.v1.addRoute(
'groups.online',
{ authRequired: true },
{ authRequired: true, validateParams: isGroupsOnlineProps },
{
async get() {
const { query } = await this.parseJsonQuery();
if (!query || Object.keys(query).length === 0) {
const { _id } = this.queryParams;

if ((!query || Object.keys(query).length === 0) && !_id) {
return API.v1.failure('Invalid query');
}

const ourQuery = Object.assign({}, query, { t: 'p' });

const room = await Rooms.findOne(ourQuery as Record<string, any>);
const filter = {
...query,
...(_id ? { _id } : {}),
t: 'p',
};

const room = await Rooms.findOne(filter as Record<string, any>);
if (!room) {
return API.v1.failure('Group does not exists');
}
const user = await getLoggedInUser(this.request);

const user = await getLoggedInUser(this.request);
if (!user) {
return API.v1.failure('User does not exists');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ const RoomMessage = ({
<RoomMessageContent message={message} unread={unread} mention={mention} all={all} searchText={searchText} />
)}
</MessageContainer>
{!message.private && <MessageToolbarHolder message={message} context={context} />}
{!message.private && message?.e2e !== 'pending' && <MessageToolbarHolder message={message} context={context} />}
</Message>
);
};
Expand Down
3 changes: 3 additions & 0 deletions apps/meteor/tests/e2e/e2e-encryption.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@ test.describe.serial('e2e-encryption', () => {
'This message is end-to-end encrypted. To view it, you must enter your encryption key in your account settings.',
);
await expect(poHomeChannel.content.lastUserMessage.locator('.rcx-icon--name-key')).toBeVisible();

await poHomeChannel.content.lastUserMessage.hover();
await expect(page.locator('[role=toolbar][aria-label="Message actions"]')).not.toBeVisible();
});

test('expect placeholder text in place of encrypted file description, when E2EE is not setup and non-encrypted files upload in disabled e2ee room', async ({
Expand Down
12 changes: 9 additions & 3 deletions apps/meteor/tests/end-to-end/api/groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,9 @@ describe('[Groups]', () => {
it('should return an array with online members', async () => {
const { testUser, testUserCredentials, room } = await createUserAndChannel();

const response = await request.get(api('groups.online')).set(testUserCredentials).query(`query={"_id": "${room._id}"}`);
const response = await request.get(api('groups.online')).set(testUserCredentials).query({
_id: room._id,
});

const { body } = response;

Expand All @@ -1134,7 +1136,9 @@ describe('[Groups]', () => {
it('should return an empty array if members are offline', async () => {
const { testUserCredentials, room } = await createUserAndChannel(false);

const response = await request.get(api('groups.online')).set(testUserCredentials).query(`query={"_id": "${room._id}"}`);
const response = await request.get(api('groups.online')).set(testUserCredentials).query({
_id: room._id,
});

const { body } = response;

Expand All @@ -1150,7 +1154,9 @@ describe('[Groups]', () => {
await request
.get(api('groups.online'))
.set(outsiderCredentials)
.query(`query={"_id": "${room._id}"}`)
.query({
_id: room._id,
})
.expect(400)
.expect((res) => {
expect(res.body).to.have.property('success', false);
Expand Down
12 changes: 9 additions & 3 deletions packages/rest-typings/src/v1/groups/GroupsOnlineProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ const ajv = new Ajv({
coerceTypes: true,
});

export type GroupsOnlineProps = { query?: Record<string, any> };
const groupsOnlyPropsSchema = {
export type GroupsOnlineProps = { _id?: string; query?: Record<string, any> };

const groupsOnlinePropsSchema = {
type: 'object',
properties: {
_id: {
type: 'string',
nullable: true,
},
query: {
type: 'string',
nullable: true,
Expand All @@ -16,4 +21,5 @@ const groupsOnlyPropsSchema = {
required: [],
additionalProperties: false,
};
export const isGroupsOnlineProps = ajv.compile<GroupsOnlineProps>(groupsOnlyPropsSchema);

export const isGroupsOnlineProps = ajv.compile<GroupsOnlineProps>(groupsOnlinePropsSchema);

0 comments on commit 89cdce9

Please sign in to comment.