Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 4.8.1 #25814

Merged
merged 6 commits into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17,349 changes: 17,348 additions & 1 deletion .github/history.json

Large diffs are not rendered by default.

33 changes: 33 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,37 @@

# 4.8.1
`2022-06-08 · 4 🐛 · 5 👩‍💻👨‍💻`

### Engine versions
- Node: `14.18.3`
- NPM: `6.14.15`
- MongoDB: `3.6, 4.0, 4.2, 4.4, 5.0`

### 🐛 Bug fixes


- AccountBox checks for condition ([#25708](https://github.com/RocketChat/Rocket.Chat/pull/25708))

- Bump meteor-node-stubs to version 1.2.3 ([#25669](https://github.com/RocketChat/Rocket.Chat/pull/25669) by [@Sh0uld](https://github.com/Sh0uld))

With meteor-node-stubs version 1.2.3 a bug was fixed, which occured in issue #25460 and probably #25513 (last one not tested).
For the issue in meteor see: https://github.com/meteor/meteor/issues/11974

- Fix prom-client new promise usage ([#25781](https://github.com/RocketChat/Rocket.Chat/pull/25781))

- Wrong argument name preventing Omnichannel Chat Forward to User ([#25723](https://github.com/RocketChat/Rocket.Chat/pull/25723))

### 👩‍💻👨‍💻 Contributors 😍

- [@Sh0uld](https://github.com/Sh0uld)

### 👩‍💻👨‍💻 Core Team 🤓

- [@KevLehman](https://github.com/KevLehman)
- [@dudanogueira](https://github.com/dudanogueira)
- [@ggazzo](https://github.com/ggazzo)
- [@tiagoevanp](https://github.com/tiagoevanp)

# 4.8.0
`2022-05-31 · 16 🎉 · 13 🚀 · 55 🐛 · 151 🔍 · 52 👩‍💻👨‍💻`

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/.docker/Dockerfile.rhel
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM registry.access.redhat.com/ubi8/nodejs-12

ENV RC_VERSION 4.8.0
ENV RC_VERSION 4.8.1

MAINTAINER buildmaster@rocket.chat

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/.snapcraft/resources/prepareRocketChat
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

curl -SLf "https://releases.rocket.chat/4.8.0/download/" -o rocket.chat.tgz
curl -SLf "https://releases.rocket.chat/4.8.1/download/" -o rocket.chat.tgz

tar xf rocket.chat.tgz --strip 1

Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/.snapcraft/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# 5. `snapcraft snap`

name: rocketchat-server
version: 4.8.0
version: 4.8.1
summary: Rocket.Chat server
description: Have your own Slack like online chat, built with Meteor. https://rocket.chat/
confinement: strict
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,23 @@ import { SystemLogger } from '../../../../server/lib/logger/system';
import { metrics } from './metrics';
import { getAppsStatistics } from '../../../statistics/server/lib/getAppsStatistics';

Facts.incrementServerFact = function (pkg, fact, increment) {
Facts.incrementServerFact = function (pkg: 'pkg' | 'fact', fact: string | number, increment: number): void {
metrics.meteorFacts.inc({ pkg, fact }, increment);
};

const setPrometheusData = async () => {
const setPrometheusData = async (): Promise<void> => {
metrics.info.set(
{
version: Info.version,
unique_id: settings.get('uniqueID'),
site_url: settings.get('Site_Url'),
// eslint-disable-next-line @typescript-eslint/camelcase
unique_id: settings.get<string>('uniqueID'),
// eslint-disable-next-line @typescript-eslint/camelcase
site_url: settings.get<string>('Site_Url'),
},
1,
);

const sessions = Array.from(Meteor.server.sessions.values());
const sessions = Array.from<{ userId: string }>(Meteor.server.sessions.values());
const authenticatedSessions = sessions.filter((s) => s.userId);
metrics.ddpSessions.set(Meteor.server.sessions.size);
metrics.ddpAuthenticatedSessions.set(authenticatedSessions.length);
Expand All @@ -53,7 +55,7 @@ const setPrometheusData = async () => {
metrics.version.set({ version: statistics.version }, 1);
metrics.migration.set(getControl().version);
metrics.instanceCount.set(statistics.instanceCount);
metrics.oplogEnabled.set({ enabled: statistics.oplogEnabled }, 1);
metrics.oplogEnabled.set({ enabled: `${statistics.oplogEnabled}` }, 1);

// User statistics
metrics.totalUsers.set(statistics.totalUsers);
Expand Down Expand Up @@ -85,17 +87,17 @@ const app = connect();
// const compression = require('compression');
// app.use(compression());

app.use('/metrics', (req, res) => {
app.use('/metrics', (_req, res) => {
res.setHeader('Content-Type', 'text/plain');
const data = client.register.metrics();
client.register.metrics().then((data) => {
metrics.metricsRequests.inc();
metrics.metricsSize.set(data.length);

metrics.metricsRequests.inc();
metrics.metricsSize.set(data.length);

res.end(data);
res.end(data);
});
});

app.use('/', (req, res) => {
app.use('/', (_req, res) => {
const html = `<html>
<head>
<title>Rocket.Chat Prometheus Exporter</title>
Expand All @@ -112,8 +114,8 @@ app.use('/', (req, res) => {

const server = http.createServer(app);

let timer;
let resetTimer;
let timer: number;
let resetTimer: number;
let defaultMetricsInitiated = false;
let gcStatsInitiated = false;
const was = {
Expand All @@ -122,19 +124,19 @@ const was = {
resetInterval: 0,
collectGC: false,
};
const updatePrometheusConfig = async () => {
const updatePrometheusConfig = async (): Promise<void> => {
const is = {
port: process.env.PROMETHEUS_PORT || settings.get('Prometheus_Port'),
enabled: settings.get('Prometheus_Enabled'),
resetInterval: settings.get('Prometheus_Reset_Interval'),
collectGC: settings.get('Prometheus_Garbage_Collector'),
enabled: settings.get<boolean>('Prometheus_Enabled'),
resetInterval: settings.get<number>('Prometheus_Reset_Interval'),
collectGC: settings.get<boolean>('Prometheus_Garbage_Collector'),
};

if (Object.values(is).some((s) => s == null)) {
return;
}

if (Object.entries(is).every(([k, v]) => v === was[k])) {
if (Object.entries(is).every(([k, v]) => v === was[k as keyof typeof was])) {
return;
}

Expand Down Expand Up @@ -162,8 +164,11 @@ const updatePrometheusConfig = async () => {
Meteor.clearInterval(resetTimer);
if (is.resetInterval) {
resetTimer = Meteor.setInterval(() => {
client.register.getMetricsAsArray().forEach((metric) => {
metric.hashMap = {};
client.register.getMetricsAsArray().then((metrics) => {
metrics.forEach((metric) => {
// @ts-expect-error
metric.hashMap = {};
});
});
}, is.resetInterval);
}
Expand All @@ -177,7 +182,7 @@ const updatePrometheusConfig = async () => {
}
if (is.collectGC && gcStatsInitiated === false) {
gcStatsInitiated = true;
gcStats()();
gcStats(client.register)();
}
} catch (error) {
SystemLogger.error(error);
Expand Down
36 changes: 26 additions & 10 deletions apps/meteor/app/ui-utils/client/lib/AccountBox.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IUActionButtonWhen, IUIActionButton } from '@rocket.chat/apps-engine/definition/ui/IUIActionButtonDescriptor';
import { IUIActionButton, IUActionButtonWhen } from '@rocket.chat/apps-engine/definition/ui/IUIActionButtonDescriptor';
import { ReactiveVar } from 'meteor/reactive-var';
import { Tracker } from 'meteor/tracker';
import { Meteor } from 'meteor/meteor';
Expand All @@ -9,18 +9,28 @@ import { SideNav } from './SideNav';
import { appLayout } from '../../../../client/lib/appLayout';
import { applyDropdownActionButtonFilters } from '../../../ui-message/client/actionButtons/lib/applyButtonFilters';

export interface IAccountBoxItem extends Omit<IUIActionButton, 'when'> {
export interface IAppAccountBoxItem extends IUIActionButton {
name: string;
icon?: string;
href?: string;
sideNav?: string;
isAppButtonItem?: boolean;
subItems?: [IAccountBoxItem];
subItems?: [IAppAccountBoxItem];
when?: Omit<IUActionButtonWhen, 'roomTypes' | 'messageActionContext'>;
}

type AccountBoxItem = {
name: string;
icon: string;
href: string;
sideNav?: string;
condition: () => boolean;
};

export const isAppAccountBoxItem = (item: IAppAccountBoxItem | AccountBoxItem): item is IAppAccountBoxItem => 'isAppButtonItem' in item;

export class AccountBoxBase {
private items = new ReactiveVar([]);
private items = new ReactiveVar<IAppAccountBoxItem[]>([]);

private status = 0;

Expand Down Expand Up @@ -51,25 +61,31 @@ export class AccountBoxBase {
this.status = 0;
}

public async addItem(newItem: IAccountBoxItem): Promise<void> {
public async addItem(newItem: IAppAccountBoxItem): Promise<void> {
Tracker.nonreactive(() => {
const actual = this.items.get();
actual.push(newItem as never);
actual.push(newItem);
this.items.set(actual);
});
}

public async deleteItem(item: IAccountBoxItem): Promise<void> {
public async deleteItem(item: IAppAccountBoxItem): Promise<void> {
Tracker.nonreactive(() => {
const actual = this.items.get();
const itemIndex = actual.findIndex((actualItem: IAccountBoxItem) => actualItem.appId === item.appId);
const itemIndex = actual.findIndex((actualItem: IAppAccountBoxItem) => actualItem.appId === item.appId);
actual.splice(itemIndex, 1);
this.items.set(actual);
});
}

public getItems(): IAccountBoxItem[] {
return this.items.get().filter((item: IAccountBoxItem) => applyDropdownActionButtonFilters(item));
public getItems(): (IAppAccountBoxItem | AccountBoxItem)[] {
return this.items.get().filter((item: IAppAccountBoxItem | AccountBoxItem) => {
if ('condition' in item) {
return item.condition();
}

return applyDropdownActionButtonFilters(item);
});
}

public addRoute(newRoute: any, router: any, wait = async (): Promise<null> => null): Router {
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/utils/rocketchat.info
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"version": "4.8.0"
"version": "4.8.1"
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const ForwardChatModal = ({
let uid;

if (username) {
const { user } = await getUserData({ userName: username });
const { user } = await getUserData({ username });
uid = user?._id;
}

Expand Down
6 changes: 3 additions & 3 deletions apps/meteor/client/sidebar/header/UserDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, { ReactElement } from 'react';

import { triggerActionButtonAction } from '../../../app/ui-message/client/ActionManager';
import { AccountBox, SideNav } from '../../../app/ui-utils/client';
import { IAccountBoxItem } from '../../../app/ui-utils/client/lib/AccountBox';
import { IAppAccountBoxItem, isAppAccountBoxItem } from '../../../app/ui-utils/client/lib/AccountBox';
import { userStatus } from '../../../app/user-status/client';
import { callbacks } from '../../../lib/callbacks';
import MarkdownText from '../../components/MarkdownText';
Expand Down Expand Up @@ -105,7 +105,7 @@ const UserDropdown = ({ user, onClose }: UserDropdownProps): ReactElement => {

const accountBoxItems = useReactiveValue(getItems);

const appBoxItems = (): IAccountBoxItem[] => accountBoxItems.filter((item) => item.isAppButtonItem);
const appBoxItems = (): IAppAccountBoxItem[] => accountBoxItems.filter((item): item is IAppAccountBoxItem => isAppAccountBoxItem(item));

return (
<Box display='flex' flexDirection='column' w={!isMobile ? '244px' : undefined}>
Expand Down Expand Up @@ -176,7 +176,7 @@ const UserDropdown = ({ user, onClose }: UserDropdownProps): ReactElement => {
<Option.Divider />
{showAdmin && <Option icon={'customize'} label={t('Administration')} onClick={handleAdmin}></Option>}
{accountBoxItems
.filter((item) => !item.isAppButtonItem)
.filter((item) => !isAppAccountBoxItem(item))
.map((item, i) => {
const action = (): void => {
if (item.href) {
Expand Down
5 changes: 5 additions & 0 deletions apps/meteor/definition/externals/meteor/facts-base.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module 'meteor/facts-base' {
namespace Facts {
function incrementServerFact(pkg: 'pkg' | 'fact', fact: string | number, increment: number): void;
}
}
1 change: 1 addition & 0 deletions apps/meteor/definition/externals/meteor/mongo.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ declare module 'meteor/mongo' {
onSkippedEntries(callback: Function): void;
waitUntilCaughtUp(): void;
_defineTooFarBehind(value: number): void;
_entryQueue?: unknown[];
}

interface MongoConnection {
Expand Down
5 changes: 3 additions & 2 deletions apps/meteor/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@rocket.chat/meteor",
"description": "The Ultimate Open Source WebChat Platform",
"version": "4.8.0",
"version": "4.8.1",
"private": true,
"author": {
"name": "Rocket.Chat",
Expand Down Expand Up @@ -119,6 +119,7 @@
"@types/nodemailer": "^6.4.4",
"@types/parseurl": "^1.3.1",
"@types/photoswipe": "^4.1.2",
"@types/prometheus-gc-stats": "^0.6.2",
"@types/psl": "^1.1.0",
"@types/react": "~17.0.42",
"@types/react-dom": "~17.0.14",
Expand Down Expand Up @@ -293,7 +294,7 @@
"mailparser": "^3.4.0",
"marked": "^0.7.0",
"mem": "^8.1.1",
"meteor-node-stubs": "^1.2.1",
"meteor-node-stubs": "^1.2.3",
"mime-db": "^1.52.0",
"mime-type": "^4.0.0",
"mkdirp": "^1.0.4",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rocket.chat",
"version": "4.8.0",
"version": "4.8.1",
"description": "Rocket.Chat Monorepo",
"main": "index.js",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/rest-typings/src/v1/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { ITeam, IUser } from '@rocket.chat/core-typings';

export type UsersEndpoints = {
'users.info': {
GET: (params: { userId?: IUser['_id']; userName?: IUser['username'] }) => {
GET: (params: { userId?: IUser['_id']; username?: IUser['username'] }) => {
user: IUser;
};
};
Expand Down
12 changes: 10 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4853,6 +4853,7 @@ __metadata:
"@types/nodemailer": ^6.4.4
"@types/parseurl": ^1.3.1
"@types/photoswipe": ^4.1.2
"@types/prometheus-gc-stats": ^0.6.2
"@types/proxy-from-env": ^1.0.1
"@types/psl": ^1.1.0
"@types/react": ~17.0.42
Expand Down Expand Up @@ -4970,7 +4971,7 @@ __metadata:
mailparser: ^3.4.0
marked: ^0.7.0
mem: ^8.1.1
meteor-node-stubs: ^1.2.1
meteor-node-stubs: ^1.2.3
mime-db: ^1.52.0
mime-type: ^4.0.0
mkdirp: ^1.0.4
Expand Down Expand Up @@ -7665,6 +7666,13 @@ __metadata:
languageName: node
linkType: hard

"@types/prometheus-gc-stats@npm:^0.6.2":
version: 0.6.2
resolution: "@types/prometheus-gc-stats@npm:0.6.2"
checksum: 403b3dbd792b83e592376e2002260cf57fb18f98c8b8528a24dc65e545cb8d0e9bf9941dc28edfa397b670b9a7336913da991005ef0278611209dde9b51406db
languageName: node
linkType: hard

"@types/prop-types@npm:*":
version: 15.7.4
resolution: "@types/prop-types@npm:15.7.4"
Expand Down Expand Up @@ -23301,7 +23309,7 @@ __metadata:
languageName: node
linkType: hard

"meteor-node-stubs@npm:^1.2.1":
"meteor-node-stubs@npm:^1.2.3":
version: 1.2.3
resolution: "meteor-node-stubs@npm:1.2.3"
dependencies:
Expand Down