Skip to content

Commit

Permalink
Merge branch 'fix/avatarEmoji' of github.com:RocketChat/Rocket.Chat i…
Browse files Browse the repository at this point in the history
…nto fix/avatarEmoji

* 'fix/avatarEmoji' of github.com:RocketChat/Rocket.Chat: (72 commits)
  refactor: `LivechatRooms` removal - 3 (#28506)
  fix: Livechat MessageList not auto scrolling on new message (#28547)
  chore: Add types for `Meteor.userAsync` (#28597)
  refactor: Easy replacements of Meteor.call to Meteor.callAsync (#28595)
  refactor: `Subscriptions` model - 2x (#28535)
  refactor: `LivechatRooms` 2 (#28504)
  regression: ldap sync not working (#28583)
  fix: Generic Table Search (#28401)
  refactor: Remove `Apps persistence` model (#28510)
  refactor(models): Use Messages Raw model (5/N) (#28590)
  refactor: federation promise.await methods 2/N (#28593)
  refactor: federation Promise.await 1/N (#28591)
  feat: Make the marketplace search bar placeholder dynamic (#28394)
  fix: Bring unseen app requests badge back and minor refactors (#28348)
  refactor: Remove `apps` & `app logs` models (#28509)
  refactor: Convert meteor call to callAsync (2/N) (#28588)
  refactor: Remove `Meteor.call` in favor of `Meteor.callAsync` - 1 (#28576)
  refactor: Restore removed function for counting on LivechatDepartmentAgents (#28577)
  refactor: Convert meteor call to callAsync (#28575)
  refactor: Remove optional return of room coordinator (#28592)
  ...
  • Loading branch information
gabriellsh committed Mar 24, 2023
2 parents 69aa3d7 + eced9c3 commit 22a3100
Show file tree
Hide file tree
Showing 777 changed files with 8,523 additions and 8,377 deletions.
18 changes: 9 additions & 9 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/packages/* @RocketChat/chat-engine
/packages/core-typings/ @RocketChat/chat-engine
/packages/rest-typings/ @RocketChat/chat-engine
/packages/* @RocketChat/Architecture
/packages/core-typings/ @RocketChat/Architecture
/packages/rest-typings/ @RocketChat/Architecture
/packages/ui-contexts/ @RocketChat/frontend
/packages/eslint-config/ @RocketChat/chat-engine
/packages/livechat/ @RocketChat/frontend @RocketChat/chat-engine
/.vscode/ @RocketChat/chat-engine
/.github/ @RocketChat/chat-engine
/_templates/ @RocketChat/chat-engine
/packages/eslint-config/ @RocketChat/Architecture
/packages/livechat/ @RocketChat/frontend @RocketChat/Architecture
/.vscode/ @RocketChat/Architecture
/.github/ @RocketChat/Architecture
/_templates/ @RocketChat/Architecture
/apps/meteor/client/ @RocketChat/frontend
/apps/meteor/tests/ @RocketChat/chat-engine
/apps/meteor/tests/ @RocketChat/Architecture
/apps/meteor/app/apps/ @RocketChat/apps
/apps/meteor/app/livechat @RocketChat/omnichannel
/apps/meteor/app/voip @RocketChat/omnichannel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-test-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ jobs:
path: ./apps/meteor/tests/e2e/.playwright*

- name: Show server logs if E2E test failed
if: inputs.type == 'ui' && failure()
if: failure()
run: docker compose -f docker-compose-ci.yml logs rocketchat

- name: Extract e2e:ee:coverage
Expand Down
76 changes: 66 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,15 @@ jobs:

test-unit:
name: 🔨 Test Unit
needs: [build, release-versions]
needs: [checks, build, release-versions]

uses: ./.github/workflows/ci-test-unit.yml
with:
node-version: ${{ needs.release-versions.outputs.node-version }}

test-api:
name: 🔨 Test API (CE)
needs: [build, release-versions]
needs: [checks, build, release-versions]

uses: ./.github/workflows/ci-test-e2e.yml
with:
Expand All @@ -229,7 +229,7 @@ jobs:

test-ui:
name: 🔨 Test UI (CE)
needs: [build, release-versions]
needs: [checks, build, release-versions]

uses: ./.github/workflows/ci-test-e2e.yml
with:
Expand All @@ -252,7 +252,7 @@ jobs:

test-api-ee:
name: 🔨 Test API (EE)
needs: [build, release-versions]
needs: [checks, build, release-versions]

uses: ./.github/workflows/ci-test-e2e.yml
with:
Expand All @@ -275,7 +275,7 @@ jobs:

test-ui-ee:
name: 🔨 Test UI (EE)
needs: [build, release-versions]
needs: [checks, build, release-versions]

uses: ./.github/workflows/ci-test-e2e.yml
with:
Expand Down Expand Up @@ -453,6 +453,11 @@ jobs:
echo "gh-image-name=${GH_IMAGE_NAME}" >> $GITHUB_OUTPUT
DOCKER_TAG_SHA="sha-${GITHUB_SHA:0:7}"
echo "DOCKER_TAG_SHA: ${DOCKER_TAG_SHA}"
echo "gh-docker-tag-sha=${DOCKER_TAG_SHA}" >> $GITHUB_OUTPUT
- name: Pull Docker image
run: docker pull ${{ steps.gh-docker.outputs.gh-image-name }}

Expand All @@ -470,13 +475,14 @@ jobs:
DOCKER_TAG="${DOCKER_TAG}-${{ matrix.release }}"
fi;
echo "IMAGE_NAME: $IMAGE_NAME"
echo "DOCKER_TAG: $DOCKER_TAG"
PUBLISHED_TAGS=()
# tag and push the specific tag version
docker tag ${{ steps.gh-docker.outputs.gh-image-name }} $IMAGE_NAME:$DOCKER_TAG
docker push $IMAGE_NAME:$DOCKER_TAG
PUBLISHED_TAGS+=("$IMAGE_NAME:$DOCKER_TAG")
if [[ $GITHUB_REF == refs/tags/* ]]; then
RELEASE="${{ needs.release-versions.outputs.release }}"
Expand All @@ -490,13 +496,38 @@ jobs:
if [[ '${{ needs.release-versions.outputs.latest-release }}' == $GITHUB_REF_NAME ]]; then
docker tag ${{ steps.gh-docker.outputs.gh-image-name }} $IMAGE_NAME:$RELEASE
docker push $IMAGE_NAME:$RELEASE
PUBLISHED_TAGS+=("$IMAGE_NAME:$RELEASE")
fi
else
docker tag ${{ steps.gh-docker.outputs.gh-image-name }} $IMAGE_NAME:$RELEASE
docker push $IMAGE_NAME:$RELEASE
PUBLISHED_TAGS+=("$IMAGE_NAME:$RELEASE")
fi
fi
# commit hash
TAG_SHA="${{ steps.gh-docker.outputs.gh-docker-tag-sha }}"
# append the variant name to docker tag
if [[ '${{ matrix.release }}' = 'alpine' ]]; then
TAG_SHA="${TAG_SHA}-${{ matrix.release }}"
fi;
docker tag ${{ steps.gh-docker.outputs.gh-image-name }} $IMAGE_NAME:$TAG_SHA
docker push $IMAGE_NAME:$TAG_SHA
PUBLISHED_TAGS+=("$IMAGE_NAME:$TAG_SHA")
echo "::group::Published tags"
for TAG in ${PUBLISHED_TAGS[@]}; do
echo $TAG
done
echo "::endgroup::"
services-docker-image-publish:
name: 🚀 Publish Docker Image (services)
runs-on: ubuntu-20.04
Expand Down Expand Up @@ -529,6 +560,11 @@ jobs:
echo "gh-image-name=${GH_IMAGE_NAME}" >> $GITHUB_OUTPUT
DOCKER_TAG_SHA="sha-${GITHUB_SHA:0:7}"
echo "DOCKER_TAG_SHA: ${DOCKER_TAG_SHA}"
echo "gh-docker-tag-sha=${DOCKER_TAG_SHA}" >> $GITHUB_OUTPUT
- name: Pull Docker image
run: docker pull ${{ steps.gh-docker.outputs.gh-image-name }}

Expand All @@ -539,24 +575,44 @@ jobs:
# 'develop' or 'tag'
DOCKER_TAG=$GITHUB_REF_NAME
echo "DH_IMAGE_NAME: $DH_IMAGE_NAME"
echo "DOCKER_TAG: $DOCKER_TAG"
PUBLISHED_TAGS=()
# tag and push the specific tag version
docker tag ${{ steps.gh-docker.outputs.gh-image-name }} $DH_IMAGE_NAME:$DOCKER_TAG
docker push $DH_IMAGE_NAME:$DOCKER_TAG
PUBLISHED_TAGS+=("$DH_IMAGE_NAME:$DOCKER_TAG")
if [[ $GITHUB_REF == refs/tags/* ]]; then
RELEASE="${{ needs.release-versions.outputs.release }}"
echo "RELEASE: $RELEASE"
if [[ $RELEASE == 'latest' ]]; then
if [[ '${{ needs.release-versions.outputs.latest-release }}' == $GITHUB_REF_NAME ]]; then
docker tag ${{ steps.gh-docker.outputs.gh-image-name }} $DH_IMAGE_NAME:$RELEASE
docker push $DH_IMAGE_NAME:$RELEASE
PUBLISHED_TAGS+=("$DH_IMAGE_NAME:$RELEASE")
fi
else
docker tag ${{ steps.gh-docker.outputs.gh-image-name }} $DH_IMAGE_NAME:$RELEASE
docker push $DH_IMAGE_NAME:$RELEASE
PUBLISHED_TAGS+=("$DH_IMAGE_NAME:$RELEASE")
fi
fi
# commit hash
TAG_SHA="${{ steps.gh-docker.outputs.gh-docker-tag-sha }}"
docker tag ${{ steps.gh-docker.outputs.gh-image-name }} $DH_IMAGE_NAME:$TAG_SHA
docker push $DH_IMAGE_NAME:$TAG_SHA
PUBLISHED_TAGS+=("$DH_IMAGE_NAME:$TAG_SHA")
echo "::group::Published tags"
for TAG in ${PUBLISHED_TAGS[@]}; do
echo $TAG
done
echo "::endgroup::"
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ yarn-error.log*
.idea/
.exrc
.history
.envrc
.envrc
1 change: 0 additions & 1 deletion apps/meteor/.eslintcache

This file was deleted.

3 changes: 2 additions & 1 deletion apps/meteor/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
}
}
],
"@typescript-eslint/no-floating-promises": "error"
"@typescript-eslint/no-floating-promises": "error",
"no-unreachable-loop": "error"
},
"parserOptions": {
"project": ["./tsconfig.json"]
Expand Down
3 changes: 2 additions & 1 deletion apps/meteor/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ tests/e2e/test-failures/
out.txt
dist
*-session.json
matrix-federation-config/*
matrix-federation-config/*
.eslintcache
2 changes: 1 addition & 1 deletion apps/meteor/.meteor/versions
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ rocketchat:i18n@0.0.1
rocketchat:livechat@0.0.1
rocketchat:mongo-config@0.0.1
rocketchat:oauth2-server@3.0.0
rocketchat:restivus@1.0.0
rocketchat:restivus@1.1.0
rocketchat:streamer@1.1.0
rocketchat:tap-i18n@3.0.0
rocketchat:version@1.0.0
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ declare const API: {
members?: { key: string; value?: string[] };
customFields?: { key: string; value?: string };
teams?: { key: string; value?: string[] };
}) => void;
}) => Promise<void>;
execute: (
userId: string,
params: {
Expand Down
20 changes: 11 additions & 9 deletions apps/meteor/app/api/server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Logger } from '../../../server/lib/logger/Logger';
import { getRestPayload } from '../../../server/lib/logger/logPayloads';
import { settings } from '../../settings/server';
import { metrics } from '../../metrics/server';
import { hasPermission } from '../../authorization/server';
import { hasPermissionAsync } from '../../authorization/server/functions/hasPermission';
import { getDefaultUserFields } from '../../utils/server/functions/getDefaultUserFields';
import { checkCodeForUser } from '../../2fa/server/code';
import { checkPermissionsForInvocation, checkPermissions } from './api.helpers';
Expand Down Expand Up @@ -218,7 +218,7 @@ export class APIClass extends Restivus {
rateLimiterDictionary.hasOwnProperty(route) &&
settings.get('API_Enable_Rate_Limiter') === true &&
(process.env.NODE_ENV !== 'development' || settings.get('API_Enable_Rate_Limiter_Dev') === true) &&
!(userId && hasPermission(userId, 'api-bypass-rate-limit'))
!(userId && Promise.await(hasPermissionAsync(userId, 'api-bypass-rate-limit')))
);
}

Expand Down Expand Up @@ -350,7 +350,8 @@ export class APIClass extends Restivus {
// Add a try/catch for each endpoint
const originalAction = endpoints[method].action;
const api = this;
endpoints[method].action = function _internalRouteActionHandler() {

endpoints[method].action = async function _internalRouteActionHandler() {
const rocketchatRestApiEnd = metrics.rocketchatRestApi.startTimer({
method,
version,
Expand Down Expand Up @@ -431,8 +432,7 @@ export class APIClass extends Restivus {
}
if (
shouldVerifyPermissions &&
(!this.userId ||
!Promise.await(checkPermissionsForInvocation(this.userId, _options.permissionsRequired, this.request.method)))
(!this.userId || !(await checkPermissionsForInvocation(this.userId, _options.permissionsRequired, this.request.method)))
) {
throw new Meteor.Error('error-unauthorized', 'User does not have the permissions required for this action', {
permissions: _options.permissionsRequired,
Expand Down Expand Up @@ -461,7 +461,7 @@ export class APIClass extends Restivus {
this.queryOperations = options.queryOperations;
this.queryFields = options.queryFields;

result = DDP._CurrentInvocation.withValue(invocation, () => Promise.await(originalAction.apply(this))) || API.v1.success();
result = (await DDP._CurrentInvocation.withValue(invocation, async () => originalAction.apply(this))) || API.v1.success();

log.http({
status: result.statusCode,
Expand Down Expand Up @@ -493,7 +493,9 @@ export class APIClass extends Restivus {
};

for (const [name, helperMethod] of this.getHelperMethods()) {
endpoints[method][name] = helperMethod;
endpoints[method][name] = function (...args) {
return Promise.await(helperMethod.apply(this, args));
};
}

// Allow the endpoints to make usage of the logger which respects the user's settings
Expand Down Expand Up @@ -583,7 +585,7 @@ export class APIClass extends Restivus {
'login',
{ authRequired: false },
{
post() {
async post() {
const args = loginCompatibility(this.bodyParams, this.request);
const getUserInfo = self.getHelperMethod('getUserInfo');

Expand All @@ -597,7 +599,7 @@ export class APIClass extends Restivus {

let auth;
try {
auth = DDP._CurrentInvocation.withValue(invocation, () => Meteor.call('login', args));
auth = await DDP._CurrentInvocation.withValue(invocation, () => Meteor.callAsync('login', args));
} catch (error) {
let e = error;
if (error.reason === 'User not found') {
Expand Down
16 changes: 8 additions & 8 deletions apps/meteor/app/api/server/helpers/parseJsonQuery.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Meteor } from 'meteor/meteor';
import { EJSON } from 'meteor/ejson';

import { hasPermission } from '../../../authorization/server';
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
import { isValidQuery } from '../lib/isValidQuery';
import { clean } from '../lib/cleanQuery';
import { API } from '../api';
Expand All @@ -20,7 +20,7 @@ const warnFields =

API.helperMethods.set(
'parseJsonQuery',
function _parseJsonQuery(this: {
async function _parseJsonQuery(this: {
request: {
route: string;
};
Expand Down Expand Up @@ -78,13 +78,13 @@ API.helperMethods.set(
if (typeof fields === 'object') {
let nonSelectableFields = Object.keys(API.v1.defaultFieldsToExclude);
if (this.request.route.includes('/v1/users.')) {
const getFields = (): string[] =>
nonSelectableFields = nonSelectableFields.concat(
Object.keys(
hasPermission(this.userId, 'view-full-other-user-info')
(await hasPermissionAsync(this.userId, 'view-full-other-user-info'))
? API.v1.limitedUserFieldsToExcludeIfIsPrivilegedUser
: API.v1.limitedUserFieldsToExclude,
);
nonSelectableFields = nonSelectableFields.concat(getFields());
),
);
}

Object.keys(fields).forEach((k) => {
Expand All @@ -97,7 +97,7 @@ API.helperMethods.set(
// Limit the fields by default
fields = Object.assign({}, fields, API.v1.defaultFieldsToExclude);
if (this.request.route.includes('/v1/users.')) {
if (hasPermission(this.userId, 'view-full-other-user-info')) {
if (await hasPermissionAsync(this.userId, 'view-full-other-user-info')) {
fields = Object.assign(fields, API.v1.limitedUserFieldsToExcludeIfIsPrivilegedUser);
} else {
fields = Object.assign(fields, API.v1.limitedUserFieldsToExclude);
Expand All @@ -124,7 +124,7 @@ API.helperMethods.set(
let nonQueryableFields = Object.keys(API.v1.defaultFieldsToExclude);

if (this.request.route.includes('/v1/users.')) {
if (hasPermission(this.userId, 'view-full-other-user-info')) {
if (await hasPermissionAsync(this.userId, 'view-full-other-user-info')) {
nonQueryableFields = nonQueryableFields.concat(Object.keys(API.v1.limitedUserFieldsToExcludeIfIsPrivilegedUser));
} else {
nonQueryableFields = nonQueryableFields.concat(Object.keys(API.v1.limitedUserFieldsToExclude));
Expand Down
2 changes: 1 addition & 1 deletion apps/meteor/app/api/server/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function findMentionedMessages({
throw new Error('invalid-user');
}

const { cursor, totalCount } = Messages.findVisibleByMentionAndRoomId(user.username, roomId, {
const { cursor, totalCount } = Messages.findPaginatedVisibleByMentionAndRoomId(user.username, roomId, {
sort: sort || { ts: -1 },
skip: offset,
limit: count,
Expand Down
Loading

0 comments on commit 22a3100

Please sign in to comment.