Skip to content

Commit

Permalink
Merge branch 'develop' into scoped-discussion-permission
Browse files Browse the repository at this point in the history
  • Loading branch information
yash-rajpal committed Oct 3, 2023
2 parents 4dea276 + 1065cd8 commit 3259539
Show file tree
Hide file tree
Showing 353 changed files with 7,401 additions and 3,528 deletions.
5 changes: 5 additions & 0 deletions .changeset/brave-snakes-scream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed an issue where broadcasted events were published twice within the same instance
5 changes: 5 additions & 0 deletions .changeset/fluffy-monkeys-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Changed the name of the administration Logs page to "Records", implemented a tab layout in this page and added a new tab called "Analytic reports" that shows the most recent result of the statistics endpoint.
5 changes: 5 additions & 0 deletions .changeset/kind-books-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

Fixed message disappearing from room after erased even if "Show Deleted Status" is enabled
5 changes: 5 additions & 0 deletions .changeset/large-pandas-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": minor
---

New setting to automatically enable autotranslate when joining rooms
13 changes: 13 additions & 0 deletions .changeset/nice-chairs-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
"@rocket.chat/meteor": minor
"@rocket.chat/core-typings": minor
---

Added `push` statistic, containing three bits. Each bit represents a boolean:
```
1 1 1
| | |
| | +- push enabled = 0b1 = 1
| +--- push gateway enabled = 0b10 = 2
+----- push gateway changed = 0b100 = 4
```
5 changes: 5 additions & 0 deletions .changeset/quiet-phones-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Search users using full name too on share message modal
5 changes: 5 additions & 0 deletions .changeset/thirty-jokes-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rocket.chat/meteor": patch
---

chore: Deprecate un-used meteor method for omnichannel analytics
8 changes: 8 additions & 0 deletions .changeset/thirty-pumpkins-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@rocket.chat/core-typings': minor
'@rocket.chat/rest-typings': minor
'@rocket.chat/tools': minor
'@rocket.chat/meteor': minor
---

Added option to select between two script engine options for the integrations
22 changes: 22 additions & 0 deletions .changeset/twelve-files-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
'@rocket.chat/license': minor
'@rocket.chat/jwt': minor
'@rocket.chat/omnichannel-services': minor
'@rocket.chat/omnichannel-transcript': minor
'@rocket.chat/authorization-service': minor
'@rocket.chat/stream-hub-service': minor
'@rocket.chat/presence-service': minor
'@rocket.chat/account-service': minor
'@rocket.chat/core-services': minor
'@rocket.chat/model-typings': minor
'@rocket.chat/core-typings': minor
'@rocket.chat/rest-typings': minor
'@rocket.chat/ddp-streamer': minor
'@rocket.chat/queue-worker': minor
'@rocket.chat/presence': minor
'@rocket.chat/meteor': minor
---

Implemented the License library, it is used to handle the functionality like expiration date, modules, limits, etc.
Also added a version v3 of the license, which contains an extended list of features.
v2 is still supported, since we convert it to v3 on the fly.
22 changes: 22 additions & 0 deletions .github/workflows/vulnerabilities-jira-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Github vulnerabilities and jira board integration

on:
schedule:
- cron: '0 1 * * *'

jobs:
IntegrateSecurityVulnerabilities:
runs-on: ubuntu-latest
steps:
- name: "Github vulnerabilities and jira board integration"
uses: RocketChat/[email protected]
env:
JIRA_URL: https://rocketchat.atlassian.net/
JIRA_TOKEN: ${{ secrets.JIRA_TOKEN }}
GITHUB_TOKEN: ${{ secrets._GITHUB_TOKEN }}
JIRA_EMAIL: [email protected]
JIRA_PROJECT_ID: GJIT
UID_CUSTOMFIELD_ID: customfield_10059
JIRA_COMPLETE_PHASE_ID: 31
JIRA_START_PHASE_ID: 11

5 changes: 5 additions & 0 deletions apps/meteor/.docker/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ RUN set -x \
&& npm install [email protected] \
&& mv node_modules/sharp npm/node_modules/sharp \
# End hack for sharp
# Start hack for isolated-vm...
&& rm -rf npm/node_modules/isolated-vm \
&& npm install [email protected] \
&& mv node_modules/isolated-vm npm/node_modules/isolated-vm \
# End hack for isolated-vm
&& cd npm \
&& npm rebuild bcrypt --build-from-source \
&& npm cache clear --force \
Expand Down
1 change: 0 additions & 1 deletion apps/meteor/app/api/server/default/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ API.default.addRoute(
{
async get() {
const user = await getLoggedInUser(this.request);

return API.v1.success(await getServerInfo(user?._id));
},
},
Expand Down
52 changes: 52 additions & 0 deletions apps/meteor/app/api/server/lib/getServerInfo.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { expect } from 'chai';
import { describe, it } from 'mocha';
import proxyquire from 'proxyquire';
import sinon from 'sinon';

const hasAllPermissionAsyncMock = sinon.stub();
const getCachedSupportedVersionsTokenMock = sinon.stub();

const { getServerInfo } = proxyquire.noCallThru().load('./getServerInfo', {
'../../../utils/rocketchat.info': {
Info: {
version: '3.0.1',
},
},
'../../../authorization/server/functions/hasPermission': {
hasPermissionAsync: hasAllPermissionAsyncMock,
},
'../../../cloud/server/functions/supportedVersionsToken/supportedVersionsToken': {
getCachedSupportedVersionsToken: getCachedSupportedVersionsTokenMock,
},
'../../../settings/server': {
settings: new Map(),
},
});
describe('#getServerInfo()', () => {
beforeEach(() => {
hasAllPermissionAsyncMock.reset();
getCachedSupportedVersionsTokenMock.reset();
});

it('should return only the version (without the patch info) when the user is not present', async () => {
expect(await getServerInfo(undefined)).to.be.eql({ version: '3.0' });
});

it('should return only the version (without the patch info) when the user present but they dont have permission', async () => {
hasAllPermissionAsyncMock.resolves(false);
expect(await getServerInfo('userId')).to.be.eql({ version: '3.0' });
});

it('should return the info object + the supportedVersions from the cloud when the request to the cloud was a success', async () => {
const signedJwt = 'signedJwt';
hasAllPermissionAsyncMock.resolves(true);
getCachedSupportedVersionsTokenMock.resolves(signedJwt);
expect(await getServerInfo('userId')).to.be.eql({ info: { version: '3.0.1', supportedVersions: signedJwt } });
});

it('should return the info object ONLY from the cloud when the request to the cloud was NOT a success', async () => {
hasAllPermissionAsyncMock.resolves(true);
getCachedSupportedVersionsTokenMock.rejects();
expect(await getServerInfo('userId')).to.be.eql({ info: { version: '3.0.1' } });
});
});
40 changes: 27 additions & 13 deletions apps/meteor/app/api/server/lib/getServerInfo.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
import { Info } from '../../../utils/rocketchat.info';
import {
getCachedSupportedVersionsToken,
wrapPromise,
} from '../../../cloud/server/functions/supportedVersionsToken/supportedVersionsToken';
import { Info, minimumClientVersions } from '../../../utils/rocketchat.info';

type ServerInfo =
| {
info: typeof Info;
}
| {
version: string | undefined;
};
type ServerInfo = {
info?: typeof Info;
supportedVersions?: { signed: string };
minimumClientVersions: typeof minimumClientVersions;
version: string;
};

const removePatchInfo = (version: string): string => version.replace(/(\d+\.\d+).*/, '$1');

export async function getServerInfo(userId?: string): Promise<ServerInfo> {
if (userId && (await hasPermissionAsync(userId, 'get-server-info'))) {
return {
info: Info,
};
}
const hasPermissionToViewStatistics = userId && (await hasPermissionAsync(userId, 'view-statistics'));
const supportedVersionsToken = await wrapPromise(getCachedSupportedVersionsToken());

return {
version: removePatchInfo(Info.version),

...(hasPermissionToViewStatistics && {
info: {
...Info,
},
version: Info.version,
}),

minimumClientVersions,
...(supportedVersionsToken.success &&
supportedVersionsToken.result && {
supportedVersions: { signed: supportedVersionsToken.result },
}),
};
}
5 changes: 2 additions & 3 deletions apps/meteor/app/api/server/v1/channels.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Team } from '@rocket.chat/core-services';
import { Team, Room } from '@rocket.chat/core-services';
import type { IRoom, ISubscription, IUser, RoomType } from '@rocket.chat/core-typings';
import { Integrations, Messages, Rooms, Subscriptions, Uploads, Users } from '@rocket.chat/models';
import {
Expand Down Expand Up @@ -31,7 +31,6 @@ import { saveRoomSettings } from '../../../channel-settings/server/methods/saveR
import { mountIntegrationQueryBasedOnPermissions } from '../../../integrations/server/lib/mountQueriesBasedOnPermission';
import { addUsersToRoomMethod } from '../../../lib/server/methods/addUsersToRoom';
import { createChannelMethod } from '../../../lib/server/methods/createChannel';
import { joinRoomMethod } from '../../../lib/server/methods/joinRoom';
import { leaveRoomMethod } from '../../../lib/server/methods/leaveRoom';
import { settings } from '../../../settings/server';
import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMessagesForUser';
Expand Down Expand Up @@ -209,7 +208,7 @@ API.v1.addRoute(
const { joinCode, ...params } = this.bodyParams;
const findResult = await findChannelByIdOrName({ params });

await joinRoomMethod(this.userId, findResult._id, joinCode);
await Room.join({ room: findResult, user: this.user, joinCode });

return API.v1.success({
channel: await findChannelByIdOrName({ params, userId: this.userId }),
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/app/api/server/v1/federation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Federation, FederationEE } from '@rocket.chat/core-services';
import { License } from '@rocket.chat/license';
import { isFederationVerifyMatrixIdProps } from '@rocket.chat/rest-typings';

import { isEnterprise } from '../../../../ee/app/license/server';
import { API } from '../api';

API.v1.addRoute(
Expand All @@ -14,7 +14,7 @@ API.v1.addRoute(
async get() {
const { matrixIds } = this.queryParams;

const federationService = isEnterprise() ? FederationEE : Federation;
const federationService = License.hasValidLicense() ? FederationEE : Federation;

const results = await federationService.verifyMatrixIds(matrixIds);

Expand Down
2 changes: 0 additions & 2 deletions apps/meteor/app/api/server/v1/voip/omnichannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ API.v1.addRoute(
}

try {
logger.debug(`Setting extension ${extension} for agent with id ${user._id}`);
await Users.setExtension(user._id, extension);
return API.v1.success();
} catch (e) {
Expand Down Expand Up @@ -146,7 +145,6 @@ API.v1.addRoute(
return API.v1.notFound();
}
if (!user.extension) {
logger.debug(`User ${user._id} is not associated with any extension. Skipping`);
return API.v1.success();
}

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/autotranslate/server/msTranslate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class MsAutoTranslate extends AutoTranslate {
if (this.supportedLanguages[target]) {
return this.supportedLanguages[target];
}
const request = await fetch(this.apiEndPointUrl);
const request = await fetch(this.apiGetLanguages);
if (!request.ok) {
throw new Error(request.statusText);
}
Expand Down
Loading

0 comments on commit 3259539

Please sign in to comment.