Skip to content

Commit

Permalink
Merge branch 'develop' into improve/remove-omnichannel-queue-col
Browse files Browse the repository at this point in the history
  • Loading branch information
KevLehman committed Jun 16, 2022
2 parents 271d94c + 750f0ef commit 707eff5
Show file tree
Hide file tree
Showing 645 changed files with 10,597 additions and 11,324 deletions.
1 change: 1 addition & 0 deletions .github/auto-label-action-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
11 changes: 11 additions & 0 deletions .github/workflows/auto-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: 'Auto label QA'
on:
pull_request:
types: [opened, synchronize, labeled, unlabeled]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: ggazzo/gh-action-auto-label@beta-5
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19 changes: 19 additions & 0 deletions .kodiak.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# .kodiak.toml
version = 1

[merge]
method = "squash"
automerge_label = ["stat: ready to merge", "automerge"]
block_on_neutral_required_check_runs = true
blocking_labels = ["stat: needs QA", "Invalid PR Title"]
prioritize_ready_to_merge = true


[merge.message]
title = "pull_request_title" # default: "github_default"
body = "pull_request_body" # default: "github_default"
include_coauthors=true
[merge.automerge_dependencies]
versions = ["minor", "patch"]
usernames = ["dependabot"]

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 5.0.0
ENV RC_VERSION 5.0.0-develop

MAINTAINER buildmaster@rocket.chat

Expand Down
7 changes: 6 additions & 1 deletion apps/meteor/.mocharc.api.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,10 @@ module.exports = {
timeout: 10000,
bail: true,
file: 'tests/end-to-end/teardown.js',
spec: ['tests/unit/app/api/server/v1/*.spec.ts', 'tests/end-to-end/api/*.js', 'tests/end-to-end/api/*.ts', 'tests/end-to-end/apps/*.js'],
spec: [
'tests/unit/app/api/server/v1/**/*.spec.ts',
'tests/end-to-end/api/*.js',
'tests/end-to-end/api/*.ts',
'tests/end-to-end/apps/*.js',
],
};
20 changes: 18 additions & 2 deletions apps/meteor/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,24 @@ const { resolve, relative, join } = require('path');
const webpack = require('webpack');

module.exports = {
stories: ['../app/**/*.stories.{js,tsx}', '../client/**/*.stories.{js,tsx}', '../ee/**/*.stories.{js,tsx}'],
addons: ['@storybook/addon-essentials', '@storybook/addon-interactions', '@storybook/addon-postcss'],
stories: [
'../client/**/*.stories.{js,tsx}',
'../app/**/*.stories.{js,tsx}',
'../ee/app/**/*.stories.{js,tsx}',
'../ee/client/**/*.stories.{js,tsx}',
],
addons: [
'@storybook/addon-essentials',
'@storybook/addon-interactions',
{
name: '@storybook/addon-postcss',
options: {
postcssLoaderOptions: {
implementation: require('postcss'),
},
},
},
],
webpackFinal: async (config) => {
const cssRule = config.module.rules.find(({ test }) => test.test('index.css'));

Expand Down
24 changes: 16 additions & 8 deletions apps/meteor/app/api/server/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
} from '@rocket.chat/rest-typings';
import type { IUser, IMethodConnection, IRoom } from '@rocket.chat/core-typings';
import type { ValidateFunction } from 'ajv';
import type { Request } from 'express';

import { ITwoFactorOptions } from '../../2fa/server/code';

Expand Down Expand Up @@ -70,18 +71,12 @@ type Options = (
validateParams?: ValidateFunction;
};

type Request = {
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
url: string;
headers: Record<string, string>;
body: any;
};

type PartialThis = {
readonly request: Request & { query: Record<string, string> };
};

type ActionThis<TMethod extends Method, TPathPattern extends PathPattern, TOptions> = {
readonly requestIp: string;
urlParams: UrlParams<TPathPattern>;
// TODO make it unsafe
readonly queryParams: TMethod extends 'GET'
Expand Down Expand Up @@ -110,16 +105,29 @@ type ActionThis<TMethod extends Method, TPathPattern extends PathPattern, TOptio
};
/* @deprecated */
getUserFromParams(): IUser;
/* @deprecated */
getUserInfo(me: IUser): TOptions extends { authRequired: true }
? IUser & {
email?: string;
settings: {
profile: {};
preferences: unknown;
};
avatarUrl: string;
}
: undefined;
insertUserObject<T>({ object, userId }: { object: { [key: string]: unknown }; userId: string }): { [key: string]: unknown } & T;
composeRoomWithLastMessage(room: IRoom, userId: string): IRoom;
} & (TOptions extends { authRequired: true }
? {
readonly user: IUser;
readonly userId: string;
readonly token: string;
}
: {
readonly user: null;
readonly userId: null;
readonly userId: undefined;
readonly token?: string;
});

export type ResultFor<TMethod extends Method, TPathPattern extends PathPattern> =
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/helpers/parseJsonQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ API.helperMethods.set(
if (typeof fields === 'object') {
let nonSelectableFields = Object.keys(API.v1.defaultFieldsToExclude);
if (this.request.route.includes('/v1/users.')) {
const getFields = () =>
const getFields = (): string[] =>
Object.keys(
hasPermission(this.userId, 'view-full-other-user-info')
? API.v1.limitedUserFieldsToExcludeIfIsPrivilegedUser
Expand Down
20 changes: 0 additions & 20 deletions apps/meteor/app/api/server/lib/emoji-custom.js

This file was deleted.

34 changes: 34 additions & 0 deletions apps/meteor/app/api/server/lib/emoji-custom.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { IEmojiCustom, ILivechatDepartmentRecord } from '@rocket.chat/core-typings';
import { FilterQuery, SortOptionObject } from 'mongodb';

import { EmojiCustom } from '../../../models/server/raw';

export async function findEmojisCustom({
query = {},
pagination: { offset, count, sort },
}: {
query: FilterQuery<ILivechatDepartmentRecord>;
pagination: { offset: number; count: number; sort: SortOptionObject<IEmojiCustom> };
}): Promise<{
emojis: IEmojiCustom[];
count: number;
offset: any;
total: number;
}> {
const cursor = EmojiCustom.find(query, {
sort: sort || { name: 1 },
skip: offset,
limit: count,
});

const total = await cursor.count();

const emojis = await cursor.toArray();

return {
emojis,
count: emojis.length,
offset,
total,
};
}
37 changes: 0 additions & 37 deletions apps/meteor/app/api/server/lib/getUploadFormData.js

This file was deleted.

90 changes: 90 additions & 0 deletions apps/meteor/app/api/server/lib/getUploadFormData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import { Readable } from 'stream';

import { Meteor } from 'meteor/meteor';
import type { Request } from 'express';
import busboy from 'busboy';
import { ValidateFunction } from 'ajv';

type UploadResult = {
file: Readable;
filename: string;
encoding: string;
mimetype: string;
fileBuffer: Buffer;
};

export const getUploadFormData = async <T extends string, K, V extends ValidateFunction<K>>(
{ request }: { request: Request },
options: {
field?: T;
validate?: V;
} = {},
): Promise<
[
UploadResult,
K extends unknown
? {
[k: string]: string;
}
: K,
T,
]
> =>
new Promise((resolve, reject) => {
const bb = busboy({ headers: request.headers, defParamCharset: 'utf8' });
const fields: { [K: string]: string } = Object.create(null);

let uploadedFile: UploadResult | undefined;

let assetName: T | undefined;

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

file.on('data', (data: any) => fileData.push(data));

file.on('end', () => {
if (uploadedFile) {
return reject('Just 1 file is allowed');
}
if (options.field && fieldname !== options.field) {
return reject(new Meteor.Error('invalid-field'));
}
uploadedFile = {
file,
filename,
encoding,
mimetype,
fileBuffer: Buffer.concat(fileData),
};

assetName = fieldname as T;
});
},
);

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

bb.on('finish', () => {
if (!uploadedFile || !assetName) {
return reject('No file uploaded');
}
if (options.validate === undefined) {
return resolve([uploadedFile, fields, assetName]);
}
if (!options.validate(fields)) {
return reject(`Invalid fields${options.validate.errors?.join(', ')}`);
}
return resolve([uploadedFile, fields, assetName]);
});

request.pipe(bb);
});
Loading

0 comments on commit 707eff5

Please sign in to comment.