Skip to content

Commit

Permalink
Merge branch 'develop' into fix/deleteRoom
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-lehnen-rc committed Jan 26, 2024
2 parents 5fd31bc + a200538 commit b666ffb
Show file tree
Hide file tree
Showing 34 changed files with 158 additions and 99 deletions.
5 changes: 5 additions & 0 deletions .changeset/mighty-shirts-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixed an issue where the webclient didn't properly clear the message caches from memory when a room is deleted. When this happened to basic DMs and the user started a new DM with the same target user, the client would show the old messages in the room history even though they no longer existed in the server.
5 changes: 5 additions & 0 deletions .changeset/spotty-tips-sell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fix multi-instance data formats being lost
24 changes: 12 additions & 12 deletions apps/meteor/.meteor/packages
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,34 @@ rocketchat:streamer
rocketchat:version
rocketchat:user-presence

accounts-base@2.2.8
accounts-base@2.2.9
accounts-facebook@1.3.3
accounts-github@1.5.0
accounts-google@1.4.0
accounts-meteor-developer@1.5.0
accounts-oauth@1.4.2
accounts-password@2.3.4
accounts-oauth@1.4.3
accounts-password@2.4.0
accounts-twitter@1.5.0

pauli:accounts-linkedin
google-oauth@1.4.4
oauth@2.2.0
oauth@2.2.1
oauth2@1.3.2

check@1.3.2
ddp-rate-limiter@1.2.0
ddp-rate-limiter@1.2.1
rate-limit@1.1.1
email@2.2.5
http@2.0.0

meteor-base@1.5.1
ddp-common@1.4.0
webapp@1.13.5
webapp@1.13.6

mongo@1.16.7
mongo@1.16.8

reload@1.3.1
service-configuration@1.3.1
service-configuration@1.3.2
session@1.2.1
shell-server@0.5.0

Expand All @@ -58,15 +58,15 @@ routepolicy@1.1.1
webapp-hashing@1.1.1
facts-base@1.0.1

tracker@1.3.2
tracker@1.3.3
reactive-dict@1.3.1
reactive-var@1.0.12

babel-compiler@7.10.4
babel-compiler@7.10.5
standard-minifier-css@1.9.2
dynamic-import@0.7.3
ecmascript@0.16.7
typescript@4.9.4
ecmascript@0.16.8
typescript@4.9.5

autoupdate@1.8.0

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/.meteor/release
Original file line number Diff line number Diff line change
@@ -1 +1 @@
METEOR@2.13.3
METEOR@2.14
50 changes: 25 additions & 25 deletions apps/meteor/.meteor/versions
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
accounts-base@2.2.8
accounts-base@2.2.9
accounts-facebook@1.3.3
accounts-github@1.5.0
accounts-google@1.4.0
accounts-meteor-developer@1.5.0
accounts-oauth@1.4.2
accounts-password@2.3.4
accounts-oauth@1.4.3
accounts-password@2.4.0
accounts-twitter@1.5.0
allow-deny@1.1.1
autoupdate@1.8.0
babel-compiler@7.10.4
babel-compiler@7.10.5
babel-runtime@1.5.1
base64@1.0.12
binary-heap@1.0.11
boilerplate-generator@1.7.1
boilerplate-generator@1.7.2
caching-compiler@1.2.2
callback-hook@1.5.1
check@1.3.2
Expand All @@ -21,21 +21,21 @@ coffeescript-compiler@2.4.1
ddp@1.4.1
ddp-client@2.6.1
ddp-common@1.4.0
ddp-rate-limiter@1.2.0
ddp-server@2.6.2
ddp-rate-limiter@1.2.1
ddp-server@2.7.0
diff-sequence@1.1.2
dispatch:run-as-user@1.1.1
dynamic-import@0.7.3
ecmascript@0.16.7
ecmascript@0.16.8
ecmascript-runtime@0.8.1
ecmascript-runtime-client@0.12.1
ecmascript-runtime-server@0.11.0
ejson@1.1.3
email@2.2.5
es5-shim@4.8.0
facebook-oauth@1.11.2
facebook-oauth@1.11.3
facts-base@1.0.1
fetch@0.1.3
fetch@0.1.4
geojson-utils@1.0.11
github-oauth@1.4.1
google-oauth@1.4.4
Expand All @@ -45,22 +45,22 @@ id-map@1.1.1
inter-process-messaging@0.1.1
kadira:flow-router@2.12.1
localstorage@1.2.0
logging@1.3.2
meteor@1.11.3
logging@1.3.3
meteor@1.11.4
meteor-base@1.5.1
meteor-developer-oauth@1.3.2
meteorhacks:inject-initial@1.0.5
minifier-css@1.6.4
minimongo@1.9.3
modern-browsers@0.1.9
modules@0.19.0
modern-browsers@0.1.10
modules@0.20.0
modules-runtime@0.13.1
mongo@1.16.7
mongo@1.16.8
mongo-decimal@0.1.3
mongo-dev-server@1.1.0
mongo-id@1.0.8
npm-mongo@4.16.0
oauth@2.2.0
npm-mongo@4.17.2
oauth@2.2.1
oauth1@1.5.1
oauth2@1.3.2
ordered-dict@1.1.0
Expand All @@ -70,7 +70,7 @@ pauli:linkedin-oauth@6.0.0
promise@0.12.2
random@1.2.1
rate-limit@1.1.1
react-fast-refresh@0.2.7
react-fast-refresh@0.2.8
reactive-dict@1.3.1
reactive-var@1.0.12
reload@1.3.1
Expand All @@ -84,19 +84,19 @@ rocketchat:streamer@1.1.0
rocketchat:user-presence@2.6.3
rocketchat:version@1.0.0
routepolicy@1.1.1
service-configuration@1.3.1
service-configuration@1.3.2
session@1.2.1
sha@1.0.9
shell-server@0.5.0
socket-stream-client@0.5.1
socket-stream-client@0.5.2
standard-minifier-css@1.9.2
tracker@1.3.2
tracker@1.3.3
twitter-oauth@1.3.3
typescript@4.9.4
typescript@4.9.5
underscore@1.0.13
url@1.3.2
webapp@1.13.5
webapp@1.13.6
webapp-hashing@1.1.1
zodern:caching-minifier@0.5.0
zodern:standard-minifier-js@5.1.2
zodern:types@1.0.9
zodern:standard-minifier-js@5.3.1
zodern:types@1.0.11
12 changes: 12 additions & 0 deletions apps/meteor/app/2fa/server/definitions/MeteorUser.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
declare module 'meteor/meteor' {
namespace Meteor {
interface UserServices {
totp?: {
enabled: boolean;
hashedBackup: string[];
secret: string;
tempSecret?: string;
};
}
}
}
4 changes: 4 additions & 0 deletions apps/meteor/app/2fa/server/methods/disable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Meteor.methods<ServerMethods>({
});
}

if (!user.services?.totp) {
return false;
}

const verified = await TOTP.verify({
secret: user.services.totp.secret,
token: code,
Expand Down
2 changes: 2 additions & 0 deletions apps/meteor/client/providers/UserProvider/UserProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { afterLogoutCleanUpCallback } from '../../../lib/callbacks/afterLogoutCl
import { useReactiveValue } from '../../hooks/useReactiveValue';
import { createReactiveSubscriptionFactory } from '../../lib/createReactiveSubscriptionFactory';
import { useCreateFontStyleElement } from '../../views/account/accessibility/hooks/useCreateFontStyleElement';
import { useClearRemovedRoomsHistory } from './hooks/useClearRemovedRoomsHistory';
import { useDeleteUser } from './hooks/useDeleteUser';
import { useEmailVerificationWarning } from './hooks/useEmailVerificationWarning';
import { useUpdateAvatar } from './hooks/useUpdateAvatar';
Expand Down Expand Up @@ -51,6 +52,7 @@ const UserProvider = ({ children }: UserProviderProps): ReactElement => {
createFontStyleElement(user?.settings?.preferences?.fontSize);

useEmailVerificationWarning(user ?? undefined);
useClearRemovedRoomsHistory(userId);

useDeleteUser();
useUpdateAvatar();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useStream } from '@rocket.chat/ui-contexts';
import { useEffect } from 'react';

import { RoomHistoryManager } from '../../../../app/ui-utils/client';

export const useClearRemovedRoomsHistory = (userId: string | null) => {
const subscribeToNotifyUser = useStream('notify-user');

useEffect(() => {
if (!userId) {
return;
}

return subscribeToNotifyUser(`${userId}/subscriptions-changed`, (event, data) => {
if (event === 'removed' && data.rid) {
RoomHistoryManager.clear(data.rid);
}
});
}, [userId, subscribeToNotifyUser]);
};
2 changes: 0 additions & 2 deletions apps/meteor/definition/externals/meteor/meteor.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ declare module 'meteor/meteor' {
const server: any;

const runAsUser: <T>(userId: string, scope: () => T) => T;
// https://github.com/meteor/meteor/pull/12274 - Function is there on meteor 2.9, but meteor.d.ts doesn't have it registered
function userAsync(options?: { fields?: Mongo.FieldSpecifier | undefined }): Promise<Meteor.User | null>;

interface MethodThisType {
twoFactorChecked: boolean | undefined;
Expand Down
17 changes: 15 additions & 2 deletions apps/meteor/ee/server/local-services/instance/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import os from 'os';
import { License, ServiceClassInternal } from '@rocket.chat/core-services';
import { InstanceStatus } from '@rocket.chat/instance-status';
import { InstanceStatus as InstanceStatusRaw } from '@rocket.chat/models';
import EJSON from 'ejson';
import type { BrokerNode } from 'moleculer';
import { ServiceBroker, Transporters } from 'moleculer';
import { ServiceBroker, Transporters, Serializers } from 'moleculer';

import { StreamerCentral } from '../../../../server/modules/streamer/streamer.module';
import type { IInstanceService } from '../../sdk/types/IInstanceService';
Expand All @@ -13,6 +14,18 @@ import { getTransporter } from './getTransporter';

const hostIP = process.env.INSTANCE_IP ? String(process.env.INSTANCE_IP).trim() : 'localhost';

const { Base } = Serializers;

class EJSONSerializer extends Base {
serialize(obj: any): Buffer {
return Buffer.from(EJSON.stringify(obj));
}

deserialize(buf: Buffer): any {
return EJSON.parse(buf.toString());
}
}

export class InstanceService extends ServiceClassInternal implements IInstanceService {
protected name = 'instance';

Expand Down Expand Up @@ -83,7 +96,7 @@ export class InstanceService extends ServiceClassInternal implements IInstanceSe
this.broker = new ServiceBroker({
nodeID: InstanceStatus.id(),
transporter: this.transporter,

serializer: new EJSONSerializer(),
...getLogger(process.env),
});

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/ee/server/services/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"jaeger-client": "^3.19.0",
"mem": "^8.1.1",
"moleculer": "^0.14.31",
"mongodb": "^4.17.1",
"mongodb": "^4.17.2",
"nats": "^2.6.1",
"pino": "^8.15.0",
"sodium-native": "^3.3.0",
Expand Down
4 changes: 2 additions & 2 deletions apps/meteor/ee/server/startup/broker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ const {
SERIALIZER = 'EJSON',
MOLECULER_LOG_LEVEL = 'warn',
BALANCE_STRATEGY = 'RoundRobin',
BALANCE_PREFER_LOCAL = 'false',
BALANCE_PREFER_LOCAL = 'true',
RETRY_FACTOR = '2',
RETRY_MAX_DELAY = '1000',
RETRY_DELAY = '100',
RETRY_RETRIES = '5',
RETRY_ENABLED = 'false',
REQUEST_TIMEOUT = '10',
REQUEST_TIMEOUT = '60',
HEARTBEAT_INTERVAL = '10',
HEARTBEAT_TIMEOUT = '30',
BULKHEAD_ENABLED = 'false',
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
"@types/lodash.get": "^4.4.8",
"@types/mailparser": "^3.4.3",
"@types/marked": "^4.0.8",
"@types/meteor": "^2.9.8",
"@types/meteor-collection-hooks": "^0.8.8",
"@types/mkdirp": "^1.0.2",
"@types/mocha": "github:whitecolor/mocha-types",
Expand Down Expand Up @@ -377,7 +378,7 @@
"moment": "^2.29.4",
"moment-timezone": "^0.5.43",
"mongo-message-queue": "^1.0.0",
"mongodb": "^4.17.1",
"mongodb": "^4.17.2",
"nats": "^2.6.1",
"node-abort-controller": "^3.1.1",
"node-dogstatsd": "^0.0.7",
Expand Down
5 changes: 1 addition & 4 deletions apps/meteor/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
"paths": {
/* Support absolute /imports/* with a leading '/' */
"/*": ["*"],
"meteor/*": [
"../../node_modules/@types/meteor/*",
".meteor/local/types/packages.d.ts"
]
"meteor/*": ["./node_modules/@types/meteor/*", ".meteor/local/types/packages.d.ts"]
},
"preserveSymlinks": true

Expand Down
2 changes: 1 addition & 1 deletion ee/apps/account-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"gc-stats": "^1.4.0",
"mem": "^8.1.1",
"moleculer": "^0.14.31",
"mongodb": "^4.17.1",
"mongodb": "^4.17.2",
"nats": "^2.4.0",
"pino": "^8.15.0",
"polka": "^0.5.2",
Expand Down
2 changes: 1 addition & 1 deletion ee/apps/authorization-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"gc-stats": "^1.4.0",
"mem": "^8.1.1",
"moleculer": "^0.14.31",
"mongodb": "^4.17.1",
"mongodb": "^4.17.2",
"nats": "^2.4.0",
"pino": "^8.15.0",
"polka": "^0.5.2"
Expand Down
4 changes: 2 additions & 2 deletions ee/apps/ddp-streamer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"jaeger-client": "^3.19.0",
"mem": "^8.1.1",
"moleculer": "^0.14.31",
"mongodb": "^4.17.1",
"mongodb": "^4.17.2",
"nats": "^2.4.0",
"pino": "^8.15.0",
"polka": "^0.5.2",
Expand All @@ -48,7 +48,7 @@
"@rocket.chat/eslint-config": "workspace:^",
"@types/ejson": "^2.2.1",
"@types/gc-stats": "^1.4.2",
"@types/meteor": "^2.9.5",
"@types/meteor": "^2.9.8",
"@types/node": "^14.18.63",
"@types/polka": "^0.5.6",
"@types/sharp": "^0.30.5",
Expand Down
Loading

0 comments on commit b666ffb

Please sign in to comment.