Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:RocketChat/Rocket.Chat into remo…
Browse files Browse the repository at this point in the history
…veNull

* 'develop' of github.com:RocketChat/Rocket.Chat: (21 commits)
  Regression: Use exact Node version on micro services Docker images (#25287)
  Chore: Add root package.json to houston files (#25286)
  Chore: Minor dependency updates (#25269)
  Chore: Add yarn plugin to check node and yarn version (#25224)
  Chore: Remove package-lock.json from houston files (#25280)
  feat: remove 'Company' email label on setup wiz (#25260)
  Chore: Fix return type warnings (#25275)
  [NEW] Expand Apps Engine's environment variable allowed list (#23870)
  Regression: Fix federation Matrix bridge startup (#25273)
  [FIX] Message preview not available for queued chats (#25092)
  [NEW] Alpha Matrix Federation (#23688)
  Chore: Bump Fuselage packages (#25259)
  [FIX] Incorrect websocket url in livechat widget (#25261)
  [FIX] Showing Blank Message Inside Report (#25007)
  [FIX] Add select message to system message, thread preview and allow select on legacy template (#25251)
  [FIX] Add katex render to new message react template (#25239)
  Chore: Update Livechat to the last version (#25257)
  [FIX] Custom sound error toast messages (#24515)
  Regression: Avatar not loading on first direct message (#25211)
  Bump version to 4.6.3
  ...
  • Loading branch information
gabriellsh committed Apr 25, 2022
2 parents 07e2e01 + 463d1ca commit e4bcdda
Show file tree
Hide file tree
Showing 98 changed files with 2,985 additions and 685 deletions.
23 changes: 23 additions & 0 deletions .github/history.json
Original file line number Diff line number Diff line change
Expand Up @@ -73236,6 +73236,29 @@
]
}
]
},
"4.6.3": {
"node_version": "14.18.3",
"npm_version": "6.14.15",
"apps_engine_version": "1.31.0",
"mongo_versions": [
"3.6",
"4.0",
"4.2",
"4.4",
"5.0"
],
"pull_requests": [
{
"pr": "25220",
"title": "[FIX] Desktop notification on multi-instance environments",
"userLogin": "sampaiodiego",
"milestone": "4.6.3",
"contributors": [
"sampaiodiego"
]
}
]
}
}
}
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict = true
9 changes: 9 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-engines.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* eslint-disable */
//prettier-ignore
module.exports = {
name: "@yarnpkg/plugin-engines",
factory: function (require) {
var plugin=(()=>{var l=Object.create,c=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var y=e=>c(e,"__esModule",{value:!0});var t=e=>{if(typeof require!="undefined")return require(e);throw new Error('Dynamic require of "'+e+'" is not supported')};var g=(e,o)=>{for(var r in o)c(e,r,{get:o[r],enumerable:!0})},P=(e,o,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of u(o))!h.call(e,s)&&s!=="default"&&c(e,s,{get:()=>o[s],enumerable:!(r=v(o,s))||r.enumerable});return e},i=e=>P(y(c(e!=null?l(m(e)):{},"default",e&&e.__esModule&&"default"in e?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e);var k={};g(k,{default:()=>$});var n=i(t("@yarnpkg/core")),p=i(t("@yarnpkg/fslib")),d=i(t("fs")),f=i(t("path")),a=i(t("semver")),N={hooks:{validateProject:e=>{let o=(0,d.readFileSync)((0,f.resolve)(p.npath.fromPortablePath(e.cwd),"package.json"),"utf-8"),{engines:r={}}=JSON.parse(o);if(r.node!=null&&!(0,a.satisfies)(process.version,r.node))throw new n.ReportError(n.MessageName.UNNAMED,`The current Node version ${process.version} does not satisfy the required version ${r.node}.`);if(r.yarn!=null&&!(0,a.satisfies)(n.YarnVersion,r.yarn))throw new n.ReportError(n.MessageName.UNNAMED,`The current Yarn version v${n.YarnVersion} does not satisfy the required version ${r.yarn}.`)},setupScriptEnvironment:async e=>{let o=(0,d.readFileSync)((0,f.resolve)(p.npath.fromPortablePath(e.cwd),"package.json"),"utf-8"),{engines:r={}}=JSON.parse(o);r.node!=null&&!(0,a.satisfies)(process.version,r.node)&&(console.error(`The current Node version ${process.version} does not satisfy the required version ${r.node}.`),process.exit(1)),r.yarn!=null&&!(0,a.satisfies)(n.YarnVersion,r.yarn)&&(console.error(`The current Yarn version v${n.YarnVersion} does not satisfy the required version ${r.yarn}.`),process.exit(1))}}},$=N;return k;})();
return plugin;
}
};
546 changes: 546 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-typescript.cjs

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,11 @@ nodeLinker: node-modules
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
spec: "@yarnpkg/plugin-workspace-tools"
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"
- path: .yarn/plugins/@yarnpkg/plugin-engines.cjs
spec: "https://raw.githubusercontent.com/devoto13/yarn-plugin-engines/main/bundles/%40yarnpkg/plugin-engines.js"
- path: .yarn/plugins/@yarnpkg/plugin-typescript.cjs
spec: "@yarnpkg/plugin-typescript"

yarnPath: .yarn/releases/yarn-3.2.0.cjs
2 changes: 1 addition & 1 deletion apps/meteor/.eslintrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": ["@rocket.chat/eslint-config", "plugin:prettier/recommended"],
"extends": ["@rocket.chat/eslint-config", "plugin:prettier/recommended", "plugin:import/typescript"],
"parser": "babel-eslint",
"globals": {
"__meteor_bootstrap__": false,
Expand Down
18 changes: 18 additions & 0 deletions apps/meteor/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@

# 4.6.3
`2022-04-19 · 1 🐛 · 1 👩‍💻👨‍💻`

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

### 🐛 Bug fixes


- Desktop notification on multi-instance environments ([#25220](https://github.com/RocketChat/Rocket.Chat/pull/25220))

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

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

# 4.6.2
`2022-04-14 · 2 🐛 · 2 👩‍💻👨‍💻`

Expand Down
13 changes: 7 additions & 6 deletions apps/meteor/app/api/server/lib/getUploadFormData.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import Busboy from 'busboy';
import busboy from 'busboy';

export const getUploadFormData = async ({ request }) =>
new Promise((resolve, reject) => {
const busboy = new Busboy({ headers: request.headers });
const bb = busboy({ headers: request.headers });

const fields = {};

busboy.on('file', (fieldname, file, filename, encoding, mimetype) => {
bb.on('file', (fieldname, file, { filename, encoding, mimeType: mimetype }) => {
const fileData = [];

console.log(file);
file.on('data', (data) => fileData.push(data));

file.on('end', () => {
Expand All @@ -26,11 +27,11 @@ export const getUploadFormData = async ({ request }) =>
});
});

busboy.on('field', (fieldname, value) => {
bb.on('field', (fieldname, value) => {
fields[fieldname] = value;
});

busboy.on('finish', () => resolve(fields));
bb.on('finish', () => resolve(fields));

request.pipe(busboy);
request.pipe(bb);
});
10 changes: 9 additions & 1 deletion apps/meteor/app/apps/server/bridges/environmental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,15 @@ export class AppEnvironmentalVariableBridge extends EnvironmentalVariableBridge
protected async isReadable(envVarName: string, appId: string): Promise<boolean> {
this.orch.debugLog(`The App ${appId} is checking if the environmental variable is readable ${envVarName}.`);

return this.allowed.includes(envVarName.toUpperCase());
return this.allowed.includes(envVarName.toUpperCase()) || this.isAppsOwnVariable(envVarName, appId);
}

protected isAppsOwnVariable(envVarName: string, appId: string): boolean {
/**
* Replace the letter `-` with `_` since environment variable name doesn't support it
*/
const appVariablePrefix = `RC_APPS_${appId.toUpperCase().replace(/-/g, '_')}`;
return envVarName.toUpperCase().startsWith(appVariablePrefix);
}

protected async isSet(envVarName: string, appId: string): Promise<boolean> {
Expand Down
26 changes: 13 additions & 13 deletions apps/meteor/app/apps/server/converters/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,24 +120,24 @@ export class AppMessagesConverter {

const newMessage = {
_id: message.id || Random.id(),
tmid: message.threadId,
...('threadId' in message && { tmid: message.threadId }),
rid: room._id,
u,
msg: message.text,
ts: message.createdAt || new Date(),
_updatedAt: message.updatedAt || new Date(),
editedBy,
editedAt: message.editedAt,
emoji: message.emoji,
avatar: message.avatarUrl,
alias: message.alias,
customFields: message.customFields,
groupable: message.groupable,
attachments,
reactions: message.reactions,
parseUrls: message.parseUrls,
blocks: message.blocks,
token: message.token,
...(editedBy && { editedBy }),
...('editedAt' in message && { editedAt: message.editedAt }),
...('emoji' in message && { emoji: message.emoji }),
...('avatarUrl' in message && { avatar: message.avatarUrl }),
...('alias' in message && { alias: message.alias }),
...('customFields' in message && { customFields: message.customFields }),
...('groupable' in message && { groupable: message.groupable }),
...(attachments && { attachments }),
...('reactions' in message && { reactions: message.reactions }),
...('parseUrls' in message && { parseUrls: message.parseUrls }),
...('blocks' in message && { blocks: message.blocks }),
...('token' in message && { token: message.token }),
};

return Object.assign(newMessage, message._unmappedProperties_);
Expand Down
28 changes: 28 additions & 0 deletions apps/meteor/app/federation-v2/server/bridge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Bridge, AppServiceRegistration } from 'matrix-appservice-bridge';

import { settings } from '../../settings/server';
import { IMatrixEvent } from './definitions/IMatrixEvent';
import { MatrixEventType } from './definitions/MatrixEventType';
import { addToQueue } from './queue';
import { getRegistrationInfo } from './config';

export const matrixBridge = new Bridge({
homeserverUrl: settings.get('Federation_Matrix_homeserver_url'),
domain: settings.get('Federation_Matrix_homeserver_domain'),
registration: AppServiceRegistration.fromObject(getRegistrationInfo()),
disableStores: true,
controller: {
onAliasQuery: (alias, matrixRoomId): void => {
console.log('onAliasQuery', alias, matrixRoomId);
},
onEvent: async (request /* , context*/): Promise<void> => {
// Get the event
const event = request.getData() as unknown as IMatrixEvent<MatrixEventType>;

addToQueue(event);
},
onLog: async (line, isError): Promise<void> => {
console.log(line, isError);
},
},
});
43 changes: 43 additions & 0 deletions apps/meteor/app/federation-v2/server/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { AppServiceOutput } from 'matrix-appservice-bridge';

import { settings } from '../../settings/server';

export type bridgeUrlTuple = [string, string, number];

export function getRegistrationInfo(): AppServiceOutput {
/* eslint-disable @typescript-eslint/camelcase */
return {
id: settings.get('Federation_Matrix_id'),
hs_token: settings.get('Federation_Matrix_hs_token'),
as_token: settings.get('Federation_Matrix_as_token'),
url: settings.get<string>('Federation_Matrix_bridge_url'),
sender_localpart: settings.get('Federation_Matrix_bridge_localpart'),
namespaces: {
users: [
{
exclusive: false,
// Reserve these MXID's (usernames)
regex: `.*`,
},
],
aliases: [
{
exclusive: false,
// Reserve these room aliases
regex: `.*`,
},
],
rooms: [
{
exclusive: false,
// This regex is used to define which rooms we listen to with the bridge.
// This does not reserve the rooms like the other namespaces.
regex: '.*',
},
],
},
rate_limited: false,
protocols: null,
};
/* eslint-enable @typescript-eslint/camelcase */
}
9 changes: 9 additions & 0 deletions apps/meteor/app/federation-v2/server/data-interface/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as message from './message';
import * as room from './room';
import * as user from './user';

export const dataInterface = {
message: message.normalize,
room: room.normalize,
user: user.normalize,
};
17 changes: 17 additions & 0 deletions apps/meteor/app/federation-v2/server/data-interface/message.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { IMessage, IUser } from '@rocket.chat/core-typings';

import { dataInterface } from '.';

interface INormalizedMessage extends IMessage {
u: Required<Pick<IUser, '_id' | 'username' | 'name'>>;
}

export const normalize = async (message: IMessage): Promise<INormalizedMessage> => {
// TODO: normalize the entire payload (if needed)
const normalizedMessage: INormalizedMessage = message as INormalizedMessage;

// Normalize the user
normalizedMessage.u = (await dataInterface.user(message.u._id)) as Required<Pick<IUser, '_id' | 'username' | 'name'>>;

return normalizedMessage;
};
8 changes: 8 additions & 0 deletions apps/meteor/app/federation-v2/server/data-interface/room.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { IRoom } from '@rocket.chat/core-typings';

import { Rooms } from '../../../models/server';

export const normalize = async (roomId: string): Promise<IRoom> => {
// Normalize the user
return Rooms.findOneById(roomId);
};
8 changes: 8 additions & 0 deletions apps/meteor/app/federation-v2/server/data-interface/user.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { IUser } from '@rocket.chat/core-typings';

import { Users } from '../../../models/server';

export const normalize = async (userId: string): Promise<IUser> => {
// Normalize the user
return Users.findOneById(userId);
};
16 changes: 16 additions & 0 deletions apps/meteor/app/federation-v2/server/definitions/IMatrixEvent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { MatrixEventType } from './MatrixEventType';
import { EventContent } from './IMatrixEventContent';

export interface IMatrixEvent<T extends MatrixEventType> {
age: number;
content: EventContent[T];
invite_room_state?: IMatrixEvent<MatrixEventType>[];
event_id: string;
origin_server_ts: number;
room_id: string;
sender: string;
state_key: string;
type: T;
unsigned: { age: number };
user_id: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export enum AddMemberToRoomMembership {
JOIN = 'join',
INVITE = 'invite',
LEAVE = 'leave',
}

export interface IMatrixEventContentAddMemberToRoom {
displayname: string;
membership: AddMemberToRoomMembership;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface IMatrixEventContentCreateRoom {
creator: string;
room_version: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export enum MatrixSendMessageType {
'm.text',
}

export interface IMatrixEventContentSendMessage {
body: string;
msgtype: MatrixSendMessageType;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export enum SetRoomJoinRules {
JOIN = 'public',
INVITE = 'invite',
}

export interface IMatrixEventContentSetRoomJoinRules {
join_rule: SetRoomJoinRules;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface IMatrixEventContentSetRoomName {
name: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface IMatrixEventContentSetRoomTopic {
topic: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { MatrixEventType } from '../MatrixEventType';
import { IMatrixEventContentCreateRoom } from './IMatrixEventContentCreateRoom';
import { IMatrixEventContentAddMemberToRoom } from './IMatrixEventContentAddMemberToRoom';
import { IMatrixEventContentSendMessage } from './IMatrixEventContentSendMessage';
import { IMatrixEventContentSetRoomJoinRules } from './IMatrixEventContentSetRoomJoinRules';
import { IMatrixEventContentSetRoomName } from './IMatrixEventContentSetRoomName';
import { IMatrixEventContentSetRoomTopic } from './IMatrixEventContentSetRoomTopic';

export type EventContent = {
[MatrixEventType.CREATE_ROOM]: IMatrixEventContentCreateRoom;
[MatrixEventType.ROOM_MEMBERSHIP]: IMatrixEventContentAddMemberToRoom;
[MatrixEventType.SET_ROOM_JOIN_RULES]: IMatrixEventContentSetRoomJoinRules;
[MatrixEventType.SET_ROOM_NAME]: IMatrixEventContentSetRoomName;
[MatrixEventType.SET_ROOM_TOPIC]: IMatrixEventContentSetRoomTopic;
[MatrixEventType.SEND_MESSAGE]: IMatrixEventContentSendMessage;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export enum MatrixEventType {
CREATE_ROOM = 'm.room.create',
ROOM_MEMBERSHIP = 'm.room.member',
// SET_ROOM_POWER_LEVELS = 'm.room.power_levels',
// SET_ROOM_CANONICAL_ALIAS = 'm.room.canonical_alias',
SET_ROOM_JOIN_RULES = 'm.room.join_rules',
// SET_ROOM_HISTORY_VISIBILITY = 'm.room.history_visibility',
// SET_ROOM_GUEST_ACCESS = 'm.room.guest_access',
SET_ROOM_NAME = 'm.room.name',
SET_ROOM_TOPIC = 'm.room.topic',
SEND_MESSAGE = 'm.room.message',
}
Loading

0 comments on commit e4bcdda

Please sign in to comment.