Skip to content

Commit

Permalink
Merge branch 'develop' into advanced-saml
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-lehnen-rc committed Jun 19, 2020
2 parents d1d9ea2 + 4680501 commit 2e276d0
Show file tree
Hide file tree
Showing 286 changed files with 7,386 additions and 2,996 deletions.
42 changes: 29 additions & 13 deletions .docker-mongo/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,40 @@
FROM rocketchat/base:12.16.1
FROM node:12.16.1-buster-slim

LABEL maintainer="[email protected]"

# Install MongoDB and dependencies
RUN set -x \
&& apt-get update \
&& apt-get install -y wget \
&& wget -qO - https://www.mongodb.org/static/pgp/server-4.0.asc | apt-key add - \
&& echo "deb http://repo.mongodb.org/apt/debian stretch/mongodb-org/4.0 main" | tee /etc/apt/sources.list.d/mongodb-org-4.0.list \
&& apt-get update \
&& apt-get install -y pwgen mongodb-org \
&& apt-get clean my room
&& apt-get update \
&& apt-get install -y wget gnupg dirmngr pwgen \
&& wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | apt-key add - \
&& echo "deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list \
&& apt-get update \
&& apt-get install -y mongodb-org fontconfig \
&& apt-get clean my room \
&& groupadd -g 65533 -r rocketchat \
&& useradd -u 65533 -r -g rocketchat rocketchat \
&& mkdir -p /app/uploads \
&& chown rocketchat:rocketchat /app/uploads

ADD . /app
ADD entrypoint.sh /app/bundle/

RUN set -x \
&& cd /app/bundle/programs/server \
&& npm install \
&& npm cache clear --force \
&& chown -R rocketchat:rocketchat /app
RUN aptMark="$(apt-mark showmanual)" \
&& apt-get install -y --no-install-recommends g++ make python ca-certificates \
&& cd /app/bundle/programs/server \
&& npm install \
&& apt-mark auto '.*' > /dev/null \
&& apt-mark manual $aptMark > /dev/null \
&& find /usr/local -type f -executable -exec ldd '{}' ';' \
| awk '/=>/ { print $(NF-1) }' \
| sort -u \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
| xargs -r apt-mark manual \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& npm cache clear --force \
&& chown -R rocketchat:rocketchat /app

VOLUME /app/uploads

Expand Down
2 changes: 1 addition & 1 deletion .docker-mongo/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ echo """
╚═╝ ╚═╝ ╚═════╝ ╚═════╝╚═╝ ╚═╝╚══════╝ ╚═╝╚═╝ ╚═════╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝ ╚═══╝ ╚═╝╚══════╝ ╚══╝╚══╝
"""

mongod --smallfiles --storageEngine=mmapv1 --fork --replSet rs0 --config /etc/mongod.conf
mongod --fork --replSet rs0 --config /etc/mongod.conf

until mongo --eval "db" &> /dev/null; do
echo "MongoDB still not ready, sleeping"
Expand Down
35 changes: 27 additions & 8 deletions .docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
FROM rocketchat/base:12.16.1

ADD . /app
FROM node:12.16.1-buster-slim

LABEL maintainer="[email protected]"

RUN set -x \
&& cd /app/bundle/programs/server \
&& npm install \
&& npm cache clear --force \
&& chown -R rocketchat:rocketchat /app
# dependencies
RUN groupadd -g 65533 -r rocketchat \
&& useradd -u 65533 -r -g rocketchat rocketchat \
&& mkdir -p /app/uploads \
&& chown rocketchat:rocketchat /app/uploads \
&& apt-get update \
&& apt-get install -y --no-install-recommends fontconfig

ADD . /app

RUN aptMark="$(apt-mark showmanual)" \
&& apt-get install -y --no-install-recommends g++ make python ca-certificates \
&& cd /app/bundle/programs/server \
&& npm install \
&& apt-mark auto '.*' > /dev/null \
&& apt-mark manual $aptMark > /dev/null \
&& find /usr/local -type f -executable -exec ldd '{}' ';' \
| awk '/=>/ { print $(NF-1) }' \
| sort -u \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
| xargs -r apt-mark manual \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& npm cache clear --force \
&& chown -R rocketchat:rocketchat /app

USER rocketchat

Expand Down
7 changes: 5 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"jscolor": false
},
"plugins": [
"react"
"react",
"react-hooks"
],
"rules": {
"jsx-quotes": [
Expand All @@ -24,7 +25,9 @@
"react/jsx-fragments": [
"error",
"syntax"
]
],
"react-hooks/rules-of-hooks": "error",
"react-hooks/exhaustive-deps": "warn"
},
"settings": {
"import/resolver": {
Expand Down
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ __Note:__ If there's a feature you'd like, there's a bug you'd like to fix, or y

## Setup

Your development workstation needs to have at least 8GB or RAM to be able to build the Rocket.Chat's source code.
Your development workstation needs to have at least 8GB RAM or more to be able to build the Rocket.Chat's source code.

Rocket.Chat runs on top of [Meteor](https://www.meteor.com/). To run it on development mode you need to [install Meteor](https://www.meteor.com/install) and clone/download the Rocket.Chat's code, then just open the code folder and run:
```shell
Expand Down Expand Up @@ -241,7 +241,7 @@ All those PRs will be grouped under the `Minor changes` section which is collaps

- Prefer inform the fields you want, and only the necessary ones, when querying data from database over query the full documents
- Limit the number of returned records to a reasonable value
- Check if the query is using indexes, it it's not create new indexes
- Check if the query is using indexes, if it's not create new indexes
- Prefer queues over long executions
- Create new metrics to mesure things whenever possible
- Cache data and returns whenever possible
Expand Down
7 changes: 0 additions & 7 deletions .github/ISSUE_TEMPLATE/custom.md

This file was deleted.

17 changes: 17 additions & 0 deletions .github/issue-close.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Config for Close Issue app: https://probot.github.io/apps/close-issue/

# Comment that will be sent if an issue is judged to be closed
comment: "This issue was closed because it does not use any of our issue templates. Please make sure to use one of the suggested templates."
issueConfigs:
# There can be several configs for different kind of issues.
- content:
# Bug report
- "Steps to reproduce"
- "Expected behavior"
- "Actual behavior"
- "Version of Rocket.Chat Server"
- content:
# Release issue
- "Before Release - Preparation"
# The issue is considered to be valid if it includes all keywords from any of these two configs.
# Or it will be closed by the app.
21 changes: 15 additions & 6 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
runs-on: ubuntu-latest

steps:

- name: Github Info
run: |
echo "GITHUB_ACTION: $GITHUB_ACTION"
Expand All @@ -34,7 +35,15 @@ jobs:
with:
node-version: "12.16.1"

- uses: actions/checkout@v1
- uses: actions/checkout@v2

- name: Free disk space
run: |
sudo swapoff -a
sudo rm -f /swapfile
sudo apt clean
docker rmi $(docker image ls -aq)
df -h
- name: check package-lock
run: |
Expand Down Expand Up @@ -199,7 +208,7 @@ jobs:
docker exec mongo mongo --eval 'rs.initiate({_id:"rs0", members: [{"_id":1, "host":"localhost:27017"}]})'
docker exec mongo mongo --eval 'rs.status()'
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- name: Cache cypress
id: cache-cypress
Expand Down Expand Up @@ -245,10 +254,10 @@ jobs:

build-image-pr:
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
if: github.event.pull_request.head.repo.full_name == github.repository

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- name: Free disk space
run: |
Expand Down Expand Up @@ -356,7 +365,7 @@ jobs:
needs: test

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- name: Restore build
uses: actions/download-artifact@v1
Expand Down Expand Up @@ -409,7 +418,7 @@ jobs:
IMAGE: "rocketchat/rocket.chat"

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2

- name: Restore build
uses: actions/download-artifact@v1
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Stale Questions

on:
schedule:
- cron: "0 */6 * * *"

jobs:
stale:
runs-on: ubuntu-latest

steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-stale: 10
days-before-close: 4
only-labels: 'stat: need more info'
stale-issue-message: >-
This issue has been marked as stale because there has been
no further activity in the last 10 days. If the issue remains
stale for the next 4 days (a total of two weeks with no activity),
then it will be assumed that the question has been resolved and
the issue will be automatically closed.
stale-issue-label: 'stat: no response'
operations-per-run: 40

- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
days-before-stale: 60
days-before-close: 7
exempt-issue-labels: 'Epic,Feature: Planned,sla,sponsored,stat: waiting PR merge,Triaged,subj: security'
stale-issue-message: >-
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
stale-issue-label: 'stat: stale'
operations-per-run: 40
2 changes: 1 addition & 1 deletion .storybook/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const useAutoToggle = (initialValue = false, ms = 1000) => {
return () => {
clearInterval(timer);
};
}, []);
}, [ms]);

return value;
};
2 changes: 1 addition & 1 deletion app/api/server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ const defaultOptionsEndpoint = function _defaultOptionsEndpoint() {
this.response.writeHead(200, {
'Access-Control-Allow-Origin': settings.get('API_CORS_Origin'),
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, HEAD, PATCH',
'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, X-User-Id, X-Auth-Token, x-visitor-token',
'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept, X-User-Id, X-Auth-Token, x-visitor-token, Authorization',
});
} else {
this.response.writeHead(405);
Expand Down
1 change: 1 addition & 0 deletions app/api/server/lib/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export async function findUsersToAutocomplete({ uid, selector }) {
name: 1,
username: 1,
status: 1,
avatarETag: 1,
},
sort: {
username: 1,
Expand Down
3 changes: 1 addition & 2 deletions app/api/server/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ settings.addGroup('General', function() {
this.add('API_Enable_CORS', false, { type: 'boolean', public: false });
this.add('API_CORS_Origin', '*', { type: 'string', public: false, enableQuery: { _id: 'API_Enable_CORS', value: true } });

this.add('API_Use_REST_For_DDP_Calls', false, {
this.add('API_Use_REST_For_DDP_Calls', true, {
type: 'boolean',
public: true,
alert: 'API_Use_REST_For_DDP_Calls_Alert',
});
});
});
7 changes: 4 additions & 3 deletions app/api/server/v1/chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { Messages } from '../../../models';
import { canAccessRoom, hasPermission } from '../../../authorization';
import { normalizeMessagesForUser } from '../../../utils/server/lib/normalizeMessagesForUser';
import { processWebhookMessage } from '../../../lib/server';
import { executeSendMessage } from '../../../lib/server/methods/sendMessage';
import { executeSetReaction } from '../../../reactions/server/setReaction';
import { API } from '../api';
import Rooms from '../../../models/server/models/Rooms';
import Users from '../../../models/server/models/Users';
Expand Down Expand Up @@ -172,8 +174,7 @@ API.v1.addRoute('chat.sendMessage', { authRequired: true }, {
throw new Meteor.Error('error-invalid-params', 'The "message" parameter must be provided.');
}

const sent = Meteor.runAsUser(this.userId, () => Meteor.call('sendMessage', this.bodyParams.message));

const sent = executeSendMessage(this.userId, this.bodyParams.message);
const [message] = normalizeMessagesForUser([sent], this.userId);

return API.v1.success({
Expand Down Expand Up @@ -294,7 +295,7 @@ API.v1.addRoute('chat.react', { authRequired: true }, {
throw new Meteor.Error('error-emoji-param-not-provided', 'The required "emoji" param is missing.');
}

Meteor.runAsUser(this.userId, () => Meteor.call('setReaction', emoji, msg._id, this.bodyParams.shouldReact));
Meteor.runAsUser(this.userId, () => Promise.await(executeSetReaction(emoji, msg._id, this.bodyParams.shouldReact)));

return API.v1.success();
},
Expand Down
Loading

0 comments on commit 2e276d0

Please sign in to comment.