Skip to content

Commit

Permalink
Merge branch 'develop' into fix/e2ee-file-upload
Browse files Browse the repository at this point in the history
  • Loading branch information
yash-rajpal committed Aug 21, 2024
2 parents 1b207e0 + 2b13061 commit 3269ed3
Show file tree
Hide file tree
Showing 132 changed files with 1,821 additions and 421 deletions.
5 changes: 5 additions & 0 deletions .changeset/bright-humans-cross.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': minor
---

Federation actions like sending message in a federated DM, reacting in a federated chat, etc, will no longer work if the configuration is invalid.
5 changes: 5 additions & 0 deletions .changeset/kind-drinks-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixed issue with asterisk-wrapped text not becoming bold when user enters profile custom status.
5 changes: 5 additions & 0 deletions .changeset/rooms-table-ts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': minor
---

Add "Created at" column to admin rooms table
5 changes: 5 additions & 0 deletions .changeset/six-beers-fry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': minor
---

New button added to validate Matrix Federation configuration. A new field inside admin settings will reflect the configuration status being either 'Valid' or 'Invalid'.
6 changes: 6 additions & 0 deletions .changeset/spicy-kings-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@rocket.chat/meteor": patch
---

Fixes multiple problems with the `processRoomAbandonment` hook. This hook is in charge of calculating the time a room has been abandoned (this means, the time that elapsed since a room was last answered by an agent until it was closed). However, when business hours were enabled and the user didn't open on one day, if an abandoned room happened to be abandoned _over_ the day there was no business hour configuration, then the process will error out.
Additionally, the values the code was calculating were not right. When business hours are enabled, this code should only count the abandonment time _while a business hour was open_. When rooms were left abandoned for days or weeks, this will also throw an error or output an invalid count.
4 changes: 4 additions & 0 deletions .github/actions/build-docker/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ inputs:
required: false
description: 'Setup node.js'
default: 'true'
NPM_TOKEN:
required: false
description: 'NPM token'

runs:
using: composite
Expand Down Expand Up @@ -65,6 +68,7 @@ runs:
node-version: ${{ inputs.node-version }}
cache-modules: true
install: true
NPM_TOKEN: ${{ inputs.NPM_TOKEN }}

- run: yarn build
if: inputs.setup == 'true'
Expand Down
4 changes: 4 additions & 0 deletions .github/actions/meteor-build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ inputs:
required: true
description: 'Node version'
type: string
NPM_TOKEN:
required: false
description: 'NPM token'

runs:
using: composite
Expand All @@ -29,6 +32,7 @@ runs:
node-version: ${{ inputs.node-version }}
cache-modules: true
install: true
NPM_TOKEN: ${{ inputs.NPM_TOKEN }}

# - name: Free disk space
# run: |
Expand Down
20 changes: 16 additions & 4 deletions .github/actions/setup-node/action.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
name: 'Setup Node'
description: 'Setup NodeJS'

inputs:
node-version:
required: true
type: string
description: 'Node version'
cache-modules:
required: false
type: boolean
description: 'Cache node_modules'
install:
required: false
type: boolean
description: 'Install dependencies'
deno-dir:
required: false
type: string
description: 'Deno directory'
default: ~/.deno-cache
NPM_TOKEN:
required: false
description: 'NPM token'

outputs:
node-version:
description: 'Node version'
value: ${{ steps.node-version.outputs.node-version }}

runs:
Expand Down Expand Up @@ -49,6 +54,13 @@ runs:
node-version: ${{ inputs.node-version }}
cache: 'yarn'

- name: yarn login
shell: bash
if: inputs.NPM_TOKEN
run: |
echo "//registry.npmjs.org/:_authToken=${{ inputs.NPM_TOKEN }}" > ~/.npmrc
- name: yarn install
if: inputs.install
shell: bash
run: yarn
1 change: 1 addition & 0 deletions .github/workflows/ci-code-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
node-version: ${{ inputs.node-version }}
cache-modules: true
install: true
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

# - name: Free disk space
# run: |
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci-test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ jobs:
node-version: ${{ inputs.node-version }}
cache-modules: true
install: true
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- uses: rharkor/[email protected]

- run: yarn build
Expand All @@ -145,6 +147,7 @@ jobs:
# the same reason we need to rebuild the docker image at this point is the reason we dont want to publish it
publish-image: false
setup: false
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Start httpbin container and wait for it to be ready
if: inputs.type == 'api'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-test-unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
node-version: ${{ inputs.node-version }}
cache-modules: true
install: true
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- uses: rharkor/[email protected]

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ jobs:
node-version: ${{ needs.release-versions.outputs.node-version }}
cache-modules: true
install: true
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Cache vite
uses: actions/cache@v3
Expand Down Expand Up @@ -253,6 +254,7 @@ jobs:
node-version: ${{ needs.release-versions.outputs.node-version }}
platform: ${{ matrix.platform }}
build-containers: ${{ matrix.platform == 'alpine' && 'authorization-service account-service ddp-streamer-service presence-service stream-hub-service queue-worker-service omnichannel-transcript-service' || '' }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

build-gh-docker:
name: 🚢 Build Docker Images for Production
Expand Down Expand Up @@ -280,6 +282,7 @@ jobs:
node-version: ${{ needs.release-versions.outputs.node-version }}
platform: ${{ matrix.platform }}
build-containers: ${{ matrix.platform == 'alpine' && 'authorization-service account-service ddp-streamer-service presence-service stream-hub-service queue-worker-service omnichannel-transcript-service' || '' }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Rename official Docker tag to GitHub Container Registry
if: matrix.platform == 'official'
Expand Down Expand Up @@ -560,6 +563,7 @@ jobs:
release: preview
username: ${{ secrets.CR_USER }}
password: ${{ secrets.CR_PAT }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

docker-image-publish:
name: 🚀 Publish Docker Image (main)
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/new-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ jobs:
node-version: 14.21.3
cache-modules: true
install: true
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- uses: rharkor/[email protected]

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/pr-update-description.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
node-version: 14.21.3
cache-modules: true
install: true
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- uses: rharkor/[email protected]

Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
node-version: 14.21.3
cache-modules: true
install: true
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- uses: rharkor/[email protected]

Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,6 @@ yarn-error.log*
*.sublime-workspace

**/.vim/

data/
registration.yaml
18 changes: 18 additions & 0 deletions apps/meteor/app/api/server/v1/federation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,21 @@ API.v1.addRoute(
},
},
);

API.v1.addRoute(
'federation/configuration.verify',
{ authRequired: true, permissionsRequired: ['view-privileged-setting'] },
{
async get() {
const service = License.hasValidLicense() ? FederationEE : Federation;

const status = await service.configurationStatus();

if (!status.externalReachability.ok || !status.appservice.ok) {
return API.v1.failure(status);
}

return API.v1.success(status);
},
},
);
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Message } from '@rocket.chat/core-services';
import { Message, Room } from '@rocket.chat/core-services';
import type { IUser } from '@rocket.chat/core-typings';
import { isRoomFederated } from '@rocket.chat/core-typings';
import { Integrations, Rooms, Subscriptions } from '@rocket.chat/models';
Expand Down Expand Up @@ -48,6 +48,9 @@ export async function saveRoomName(
function: 'RocketChat.saveRoomdisplayName',
});
}

await Room.beforeNameChange(room);

if (displayName === room.name) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Message } from '@rocket.chat/core-services';
import { Message, Room } from '@rocket.chat/core-services';
import { Rooms } from '@rocket.chat/models';
import { Match } from 'meteor/check';
import { Meteor } from 'meteor/meteor';
Expand All @@ -20,6 +20,10 @@ export const saveRoomTopic = async function (
});
}

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

View workflow job for this annotation

GitHub Actions / 🔎 Code Check / Code Lint

Forbidden non-null assertion

const update = await Rooms.setTopicById(rid, roomTopic);
if (update && sendMessage) {
await Message.saveSystemMessage('room_changed_topic', rid, roomTopic || '', user);
Expand Down
11 changes: 8 additions & 3 deletions apps/meteor/app/lib/server/functions/createRoom.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable complexity */
import { AppEvents, Apps } from '@rocket.chat/apps';
import { AppsEngineException } from '@rocket.chat/apps-engine/definition/exceptions';
import { Message, Team } from '@rocket.chat/core-services';
import { Federation, FederationEE, License, Message, Team } from '@rocket.chat/core-services';
import type { ICreateRoomParams, ISubscriptionExtraData } from '@rocket.chat/core-services';
import type { ICreatedRoom, IUser, IRoom, RoomType } from '@rocket.chat/core-typings';
import { Rooms, Subscriptions, Users } from '@rocket.chat/models';
Expand Down Expand Up @@ -224,6 +224,13 @@ export const createRoom = async <T extends RoomType>(
Object.assign(roomProps, eventResult);
}

const shouldBeHandledByFederation = roomProps.federated === true || owner.username.includes(':');

if (shouldBeHandledByFederation) {
const federation = (await License.hasValidLicense()) ? FederationEE : Federation;
await federation.beforeCreateRoom(roomProps);
}

if (type === 'c') {
await callbacks.run('beforeCreateChannel', owner, roomProps);
}
Expand All @@ -232,8 +239,6 @@ export const createRoom = async <T extends RoomType>(

void notifyOnRoomChanged(room, 'inserted');

const shouldBeHandledByFederation = room.federated === true || owner.username.includes(':');

await createUsersSubscriptions({ room, members, now, owner, options, shouldBeHandledByFederation });

if (type === 'c') {
Expand Down
20 changes: 13 additions & 7 deletions apps/meteor/app/lib/server/functions/deleteMessage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppEvents, Apps } from '@rocket.chat/apps';
import { api } from '@rocket.chat/core-services';
import { api, Message } from '@rocket.chat/core-services';
import type { AtLeast, IMessage, IUser } from '@rocket.chat/core-typings';
import { Messages, Rooms, Uploads, Users, ReadReceipts } from '@rocket.chat/models';
import { Meteor } from 'meteor/meteor';
Expand Down Expand Up @@ -35,10 +35,18 @@ export async function deleteMessage(message: IMessage, user: IUser): Promise<voi
const showDeletedStatus = settings.get('Message_ShowDeletedStatus') || isThread;
const bridges = Apps.self?.isLoaded() && Apps.getBridges();

if (deletedMsg && bridges) {
const prevent = await bridges.getListenerBridge().messageEvent(AppEvents.IPreMessageDeletePrevent, deletedMsg);
if (prevent) {
throw new Meteor.Error('error-app-prevented-deleting', 'A Rocket.Chat App prevented the message deleting.');
const room = await Rooms.findOneById(message.rid, { projection: { lastMessage: 1, prid: 1, mid: 1, federated: 1 } });

if (deletedMsg) {
if (bridges) {
const prevent = await bridges.getListenerBridge().messageEvent(AppEvents.IPreMessageDeletePrevent, deletedMsg);
if (prevent) {
throw new Meteor.Error('error-app-prevented-deleting', 'A Rocket.Chat App prevented the message deleting.');
}
}

if (room) {
await Message.beforeDelete(deletedMsg, room);
}
}

Expand Down Expand Up @@ -76,8 +84,6 @@ export async function deleteMessage(message: IMessage, user: IUser): Promise<voi
void api.broadcast('notify.deleteMessage', message.rid, { _id: message._id });
}

const room = await Rooms.findOneById(message.rid, { projection: { lastMessage: 1, prid: 1, mid: 1, federated: 1 } });

// update last message
if (settings.get('Store_Last_Message') && (!room?.lastMessage || room.lastMessage._id === message._id)) {
const lastMessageNotDeleted = await Messages.getLastVisibleUserMessageSentByRoomId(message.rid);
Expand Down
5 changes: 4 additions & 1 deletion apps/meteor/app/lib/server/functions/removeUserFromRoom.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Apps, AppEvents } from '@rocket.chat/apps';
import { AppsEngineException } from '@rocket.chat/apps-engine/definition/exceptions';
import { Message, Team } from '@rocket.chat/core-services';
import { Message, Team, Room } from '@rocket.chat/core-services';
import type { IUser } from '@rocket.chat/core-typings';
import { Subscriptions, Rooms } from '@rocket.chat/models';
import { Meteor } from 'meteor/meteor';
Expand All @@ -27,6 +27,9 @@ export const removeUserFromRoom = async function (rid: string, user: IUser, opti
throw error;
}

await Room.beforeLeave(room);

// TODO: move before callbacks to service
await beforeLeaveRoomCallback.run(user, room);

const subscription = await Subscriptions.findOneByRoomIdAndUserId(rid, user._id, {
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/app/lib/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ import './methods/unarchiveRoom';
import './methods/unblockUser';
import './methods/updateMessage';
import './methods/saveCustomFields';
import './methods/checkFederationConfiguration';

export * from './lib';
Loading

0 comments on commit 3269ed3

Please sign in to comment.