commit
097c7c04f7
@ -1,13 +0,0 @@ |
||||
#!/bin/bash |
||||
set -euvo pipefail |
||||
IFS=$'\n\t' |
||||
|
||||
CURL_URL="https://registry.hub.docker.com/u/rocketchat/rocket.chat/trigger/$DOCKER_TRIGGER_TOKEN/" |
||||
|
||||
if [[ $CIRCLE_TAG ]]; then |
||||
CURL_DATA='{"source_type":"Tag","source_name":"'"$CIRCLE_TAG"'"}'; |
||||
else |
||||
CURL_DATA='{"source_type":"Branch","source_name":"'"$CIRCLE_BRANCH"'"}'; |
||||
fi |
||||
|
||||
curl -H "Content-Type: application/json" --data "$CURL_DATA" -X POST "$CURL_URL" |
@ -1,23 +1,104 @@ |
||||
{ |
||||
"extends": ["@rocket.chat/eslint-config"], |
||||
"parser": "babel-eslint", |
||||
"globals": { |
||||
"__meteor_bootstrap__" : false, |
||||
"__meteor_runtime_config__" : false, |
||||
"Assets" : false, |
||||
"chrome" : false |
||||
"extends": [ |
||||
"@rocket.chat/eslint-config" |
||||
], |
||||
"parser": "babel-eslint", |
||||
"globals": { |
||||
"__meteor_bootstrap__": false, |
||||
"__meteor_runtime_config__": false, |
||||
"Assets": false, |
||||
"chrome": false, |
||||
"jscolor": false |
||||
}, |
||||
"plugins": ["react"], |
||||
"rules": { |
||||
"jsx-quotes": ["error", "prefer-single"], |
||||
"plugins": [ |
||||
"react" |
||||
], |
||||
"rules": { |
||||
"jsx-quotes": [ |
||||
"error", |
||||
"prefer-single" |
||||
], |
||||
"react/jsx-uses-react": "error", |
||||
"react/jsx-uses-vars": "error", |
||||
"react/jsx-no-undef": "error", |
||||
"react/jsx-fragments": ["error", "syntax"], |
||||
"react/jsx-fragments": [ |
||||
"error", |
||||
"syntax" |
||||
], |
||||
}, |
||||
"settings": { |
||||
"react": { |
||||
"version": "detect", |
||||
}, |
||||
}, |
||||
"overrides": [ |
||||
{ |
||||
"files": [ |
||||
"**/*.ts", |
||||
"**/*.tsx" |
||||
], |
||||
"extends": [ |
||||
"@rocket.chat/eslint-config", |
||||
"plugin:@typescript-eslint/recommended", |
||||
"plugin:@typescript-eslint/eslint-recommended" |
||||
], |
||||
"globals": { |
||||
"Atomics": "readonly", |
||||
"SharedArrayBuffer": "readonly" |
||||
}, |
||||
"parser": "@typescript-eslint/parser", |
||||
"parserOptions": { |
||||
"sourceType": "module", |
||||
"ecmaVersion": 2018, |
||||
"warnOnUnsupportedTypeScriptVersion": false, |
||||
"ecmaFeatures": { |
||||
"experimentalObjectRestSpread": true, |
||||
"legacyDecorators": true |
||||
} |
||||
}, |
||||
"plugins": [ |
||||
"react", |
||||
"@typescript-eslint" |
||||
], |
||||
"rules": { |
||||
"jsx-quotes": [ |
||||
"error", |
||||
"prefer-single" |
||||
], |
||||
"react/jsx-uses-react": "error", |
||||
"react/jsx-uses-vars": "error", |
||||
"react/jsx-no-undef": "error", |
||||
"react/jsx-fragments": [ |
||||
"error", |
||||
"syntax" |
||||
], |
||||
"@typescript-eslint/ban-ts-ignore": "off", |
||||
"@typescript-eslint/no-explicit-any": "off", |
||||
"@typescript-eslint/interface-name-prefix": [ |
||||
"error", |
||||
"always" |
||||
] |
||||
}, |
||||
"env": { |
||||
"browser": true, |
||||
"commonjs": true, |
||||
"es6": true, |
||||
"node": true |
||||
}, |
||||
"settings": { |
||||
"import/resolver": { |
||||
"node": { |
||||
"extensions": [ |
||||
".js", |
||||
".ts", |
||||
".tsx" |
||||
] |
||||
} |
||||
}, |
||||
"react": { |
||||
"version": "detect" |
||||
} |
||||
} |
||||
} |
||||
] |
||||
} |
||||
|
@ -0,0 +1,443 @@ |
||||
name: Build and Test |
||||
|
||||
on: |
||||
release: |
||||
types: [published] |
||||
pull_request: |
||||
branches: '**' |
||||
push: |
||||
branches: |
||||
- develop |
||||
|
||||
env: |
||||
CI: true |
||||
MONGO_URL: mongodb://localhost:27017 |
||||
TOOL_NODE_FLAGS: --max_old_space_size=4096 |
||||
|
||||
jobs: |
||||
build: |
||||
runs-on: ubuntu-latest |
||||
|
||||
steps: |
||||
- name: Github Info |
||||
run: | |
||||
echo "GITHUB_ACTION: $GITHUB_ACTION" |
||||
echo "GITHUB_ACTOR: $GITHUB_ACTOR" |
||||
echo "GITHUB_REF: $GITHUB_REF" |
||||
echo "GITHUB_HEAD_REF: $GITHUB_HEAD_REF" |
||||
echo "GITHUB_BASE_REF: $GITHUB_BASE_REF" |
||||
echo "github.event_name: ${{ github.event_name }}" |
||||
cat $GITHUB_EVENT_PATH |
||||
|
||||
- name: Use Node.js 8.17.0 |
||||
uses: actions/setup-node@v1 |
||||
with: |
||||
node-version: "8.17.0" |
||||
|
||||
- uses: actions/checkout@v1 |
||||
|
||||
- name: check package-lock |
||||
run: | |
||||
npx package-lock-check |
||||
|
||||
- name: Cache node modules |
||||
id: cache-nodemodules |
||||
uses: actions/cache@v1 |
||||
with: |
||||
path: node_modules |
||||
key: ${{ runner.OS }}-node_modules-${{ hashFiles('**/package-lock.json') }} |
||||
|
||||
- name: Cache meteor local |
||||
uses: actions/cache@v1 |
||||
with: |
||||
path: ./.meteor/local |
||||
key: ${{ runner.OS }}-meteor_cache-${{ hashFiles('.meteor/versions') }} |
||||
|
||||
- name: Cache meteor |
||||
uses: actions/cache@v1 |
||||
with: |
||||
path: ~/.meteor |
||||
key: ${{ runner.OS }}-meteor-${{ hashFiles('.meteor/release') }} |
||||
|
||||
- name: Install Meteor |
||||
run: | |
||||
# Restore bin from cache |
||||
set +e |
||||
METEOR_SYMLINK_TARGET=$(readlink ~/.meteor/meteor) |
||||
METEOR_TOOL_DIRECTORY=$(dirname "$METEOR_SYMLINK_TARGET") |
||||
set -e |
||||
LAUNCHER=$HOME/.meteor/$METEOR_TOOL_DIRECTORY/scripts/admin/launch-meteor |
||||
if [ -e $LAUNCHER ] |
||||
then |
||||
echo "Cached Meteor bin found, restoring it" |
||||
sudo cp "$LAUNCHER" "/usr/local/bin/meteor" |
||||
else |
||||
echo "No cached Meteor bin found." |
||||
fi |
||||
|
||||
# only install meteor if bin isn't found |
||||
command -v meteor >/dev/null 2>&1 || curl https://install.meteor.com | sed s/--progress-bar/-sL/g | /bin/sh |
||||
|
||||
- name: Versions |
||||
run: | |
||||
npm --versions |
||||
node -v |
||||
meteor --version |
||||
meteor npm --versions |
||||
meteor node -v |
||||
git version |
||||
|
||||
- name: npm install |
||||
if: steps.cache-nodemodules.outputs.cache-hit != 'true' |
||||
run: | |
||||
meteor npm install |
||||
|
||||
- run: npm run lint |
||||
|
||||
- name: Launch MongoDB |
||||
uses: wbari/start-mongoDB@v0.2 |
||||
with: |
||||
mongoDBVersion: "4.0" |
||||
|
||||
- run: npm run testunit |
||||
|
||||
# To reduce memory need during actual build, build the packages solely first |
||||
# - name: Build a Meteor cache |
||||
# run: | |
||||
# # to do this we can clear the main files and it build the rest |
||||
# echo "" > server/main.js |
||||
# echo "" > client/main.js |
||||
# sed -i.backup 's/rocketchat:livechat/#rocketchat:livechat/' .meteor/packages |
||||
# meteor build --server-only --debug --directory /tmp/build-temp |
||||
# git checkout -- server/main.js client/main.js .meteor/packages |
||||
|
||||
- name: Reset Meteor |
||||
if: startsWith(github.ref, 'refs/tags/') == 'true' || github.ref == 'refs/heads/develop' |
||||
run: | |
||||
meteor reset |
||||
|
||||
- name: Build Rocket.Chat From Pull Request |
||||
if: startsWith(github.ref, 'refs/pull/') == true |
||||
env: |
||||
METEOR_PROFILE: 1000 |
||||
run: | |
||||
meteor build --server-only --directory --debug /tmp/build-test |
||||
|
||||
- name: Build Rocket.Chat |
||||
if: startsWith(github.ref, 'refs/pull/') != true |
||||
run: | |
||||
meteor build --server-only --directory /tmp/build-test |
||||
|
||||
- name: Prepare build |
||||
run: | |
||||
mkdir /tmp/build/ |
||||
cd /tmp/build-test |
||||
tar czf /tmp/build/Rocket.Chat.tar.gz bundle |
||||
cd /tmp/build-test/bundle/programs/server |
||||
npm install |
||||
cd /tmp |
||||
tar czf Rocket.Chat.test.tar.gz ./build-test |
||||
|
||||
- name: Store build for tests |
||||
uses: actions/upload-artifact@v1 |
||||
with: |
||||
name: build-test |
||||
path: /tmp/Rocket.Chat.test.tar.gz |
||||
|
||||
- name: Store build |
||||
uses: actions/upload-artifact@v1 |
||||
with: |
||||
name: build |
||||
path: /tmp/build |
||||
|
||||
test: |
||||
runs-on: ubuntu-16.04 |
||||
needs: build |
||||
|
||||
strategy: |
||||
matrix: |
||||
node-version: ["8.17.0"] |
||||
mongodb-version: ["3.4", "3.6", "4.0"] |
||||
|
||||
steps: |
||||
- name: Launch MongoDB |
||||
uses: wbari/start-mongoDB@v0.2 |
||||
with: |
||||
mongoDBVersion: ${{ matrix.mongodb-version }} --noprealloc --smallfiles --replSet=rs0 |
||||
|
||||
- name: Restore build for tests |
||||
uses: actions/download-artifact@v1 |
||||
with: |
||||
name: build-test |
||||
path: /tmp |
||||
|
||||
- name: Decompress build |
||||
run: | |
||||
cd /tmp |
||||
tar xzf Rocket.Chat.test.tar.gz |
||||
cd - |
||||
|
||||
- name: Use Node.js ${{ matrix.node-version }} |
||||
uses: actions/setup-node@v1 |
||||
with: |
||||
node-version: ${{ matrix.node-version }} |
||||
|
||||
- name: Setup Chrome |
||||
run: | |
||||
npm i chromedriver |
||||
|
||||
- name: Configure Replica Set |
||||
run: | |
||||
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 |
||||
|
||||
- name: Cache node modules |
||||
id: cache-nodemodules |
||||
uses: actions/cache@v1 |
||||
with: |
||||
path: node_modules |
||||
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }} |
||||
|
||||
- name: NPM install |
||||
if: steps.cache-nodemodules.outputs.cache-hit != 'true' |
||||
run: | |
||||
npm install |
||||
|
||||
- name: Test |
||||
env: |
||||
TEST_MODE: "true" |
||||
MONGO_URL: mongodb://localhost:27017/rocketchat |
||||
MONGO_OPLOG_URL: mongodb://localhost:27017/local |
||||
run: | |
||||
for i in $(seq 1 5); do (docker exec mongo mongo rocketchat --eval 'db.dropDatabase()') && xvfb-run --auto-servernum npm test && s=0 && break || s=$? && sleep 1; done; (exit $s) |
||||
|
||||
# notification: |
||||
# runs-on: ubuntu-latest |
||||
# needs: test |
||||
|
||||
# steps: |
||||
# - name: Rocket.Chat Notification |
||||
# uses: RocketChat/Rocket.Chat.GitHub.Action.Notification@1.1.1 |
||||
# with: |
||||
# type: ${{ job.status }} |
||||
# job_name: '**Build and Test**' |
||||
# url: ${{ secrets.ROCKETCHAT_WEBHOOK }} |
||||
# commit: true |
||||
# token: ${{ secrets.GITHUB_TOKEN }} |
||||
|
||||
build-image-pr: |
||||
runs-on: ubuntu-latest |
||||
if: github.event_name == 'pull_request' |
||||
|
||||
steps: |
||||
- uses: actions/checkout@v1 |
||||
|
||||
- name: Cache node modules |
||||
id: cache-nodemodules |
||||
uses: actions/cache@v1 |
||||
with: |
||||
path: node_modules |
||||
key: ${{ runner.OS }}-node_modules-${{ hashFiles('**/package-lock.json') }} |
||||
|
||||
- name: Cache meteor local |
||||
uses: actions/cache@v1 |
||||
with: |
||||
path: ./.meteor/local |
||||
key: ${{ runner.OS }}-meteor_cache-${{ hashFiles('.meteor/versions') }} |
||||
|
||||
- name: Cache meteor |
||||
uses: actions/cache@v1 |
||||
with: |
||||
path: ~/.meteor |
||||
key: ${{ runner.OS }}-meteor-${{ hashFiles('.meteor/release') }} |
||||
|
||||
- name: Use Node.js 8.17.0 |
||||
uses: actions/setup-node@v1 |
||||
with: |
||||
node-version: "8.17.0" |
||||
|
||||
- name: Install Meteor |
||||
run: | |
||||
# Restore bin from cache |
||||
set +e |
||||
METEOR_SYMLINK_TARGET=$(readlink ~/.meteor/meteor) |
||||
METEOR_TOOL_DIRECTORY=$(dirname "$METEOR_SYMLINK_TARGET") |
||||
set -e |
||||
LAUNCHER=$HOME/.meteor/$METEOR_TOOL_DIRECTORY/scripts/admin/launch-meteor |
||||
if [ -e $LAUNCHER ] |
||||
then |
||||
echo "Cached Meteor bin found, restoring it" |
||||
sudo cp "$LAUNCHER" "/usr/local/bin/meteor" |
||||
else |
||||
echo "No cached Meteor bin found." |
||||
fi |
||||
|
||||
# only install meteor if bin isn't found |
||||
command -v meteor >/dev/null 2>&1 || curl https://install.meteor.com | sed s/--progress-bar/-sL/g | /bin/sh |
||||
|
||||
- name: Versions |
||||
run: | |
||||
npm --versions |
||||
node -v |
||||
meteor --version |
||||
meteor npm --versions |
||||
meteor node -v |
||||
git version |
||||
echo $GITHUB_REF |
||||
|
||||
- name: npm install |
||||
if: steps.cache-nodemodules.outputs.cache-hit != 'true' |
||||
run: | |
||||
meteor npm install |
||||
|
||||
# To reduce memory need during actual build, build the packages solely first |
||||
# - name: Build a Meteor cache |
||||
# run: | |
||||
# # to do this we can clear the main files and it build the rest |
||||
# echo "" > server/main.js |
||||
# echo "" > client/main.js |
||||
# sed -i.backup 's/rocketchat:livechat/#rocketchat:livechat/' .meteor/packages |
||||
# meteor build --server-only --debug --directory /tmp/build-temp |
||||
# git checkout -- server/main.js client/main.js .meteor/packages |
||||
|
||||
- name: Build Rocket.Chat |
||||
run: | |
||||
meteor build --server-only --directory /tmp/build-pr |
||||
|
||||
- name: Build Docker image for PRs |
||||
env: |
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
||||
VERSION: pr-${{ github.event.number }} |
||||
run: | |
||||
cd /tmp/build-pr |
||||
|
||||
export OWNER="${GITHUB_REPOSITORY%/*}" |
||||
|
||||
docker login docker.pkg.github.com -u "${OWNER}" -p "${GITHUB_TOKEN}" |
||||
|
||||
cp $GITHUB_WORKSPACE/.docker/Dockerfile . |
||||
|
||||
export LOWERCASE_REPOSITORY=$(echo "$GITHUB_REPOSITORY" | tr "[:upper:]" "[:lower:]") |
||||
|
||||
export IMAGE_NAME="docker.pkg.github.com/${LOWERCASE_REPOSITORY}/rocket.chat:${VERSION}" |
||||
|
||||
echo "Build official Docker image ${IMAGE_NAME}" |
||||
|
||||
docker build -t $IMAGE_NAME . |
||||
docker push $IMAGE_NAME |
||||
|
||||
deploy: |
||||
runs-on: ubuntu-latest |
||||
if: github.event_name == 'release' || github.ref == 'refs/heads/develop' |
||||
needs: test |
||||
|
||||
steps: |
||||
- uses: actions/checkout@v1 |
||||
|
||||
- name: Restore build |
||||
uses: actions/download-artifact@v1 |
||||
with: |
||||
name: build |
||||
path: /tmp/build |
||||
|
||||
- name: Publish assets |
||||
env: |
||||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} |
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
||||
GPG_PASSWORD: ${{ secrets.GPG_PASSWORD }} |
||||
REDHAT_REGISTRY_PID: ${{ secrets.REDHAT_REGISTRY_PID }} |
||||
REDHAT_REGISTRY_KEY: ${{ secrets.REDHAT_REGISTRY_KEY }} |
||||
UPDATE_TOKEN: ${{ secrets.UPDATE_TOKEN }} |
||||
run: | |
||||
if [[ '${{ github.event_name }}' = 'release' ]]; then |
||||
export CIRCLE_TAG="${GITHUB_REF#*tags/}" |
||||
else |
||||
export CIRCLE_BRANCH="${GITHUB_REF#*heads/}" |
||||
fi; |
||||
|
||||
export CIRCLE_TAG=${CIRCLE_TAG:=} |
||||
export CIRCLE_SHA1=$GITHUB_SHA |
||||
export CIRCLE_BUILD_NUM=$GITHUB_SHA |
||||
|
||||
aws s3 cp s3://rocketchat/sign.key.gpg .circleci/sign.key.gpg |
||||
|
||||
source .circleci/setartname.sh |
||||
source .circleci/setdeploydir.sh |
||||
bash .circleci/setupsig.sh |
||||
bash .circleci/namefiles.sh |
||||
|
||||
aws s3 cp $ROCKET_DEPLOY_DIR/ s3://download.rocket.chat/build/ --recursive |
||||
|
||||
bash .circleci/update-releases.sh |
||||
# bash .circleci/snap.sh |
||||
bash .circleci/redhat-registry.sh |
||||
|
||||
image-build: |
||||
runs-on: ubuntu-latest |
||||
needs: deploy |
||||
|
||||
strategy: |
||||
matrix: |
||||
release: ["official", "preview"] |
||||
|
||||
env: |
||||
IMAGE: "rocketchat/rocket.chat" |
||||
|
||||
steps: |
||||
- uses: actions/checkout@v1 |
||||
|
||||
- name: Restore build |
||||
uses: actions/download-artifact@v1 |
||||
with: |
||||
name: build |
||||
path: /tmp/build |
||||
|
||||
- name: Unpack build |
||||
env: |
||||
DOCKER_USER: ${{ secrets.DOCKER_USER }} |
||||
DOCKER_PASS: ${{ secrets.DOCKER_PASS }} |
||||
run: | |
||||
cd /tmp/build |
||||
tar xzf Rocket.Chat.tar.gz |
||||
rm Rocket.Chat.tar.gz |
||||
|
||||
export DOCKER_PATH="${GITHUB_WORKSPACE}/.docker" |
||||
if [[ '${{ matrix.release }}' = 'preview' ]]; then |
||||
export IMAGE="${IMAGE}.preview" |
||||
export DOCKER_PATH="${DOCKER_PATH}-mongo" |
||||
fi; |
||||
|
||||
echo "Build ${{ matrix.release }} Docker image" |
||||
cp ${DOCKER_PATH}/Dockerfile . |
||||
if [ -e ${DOCKER_PATH}/entrypoint.sh ]; then |
||||
cp ${DOCKER_PATH}/entrypoint.sh . |
||||
fi; |
||||
|
||||
docker login -u $DOCKER_USER -p $DOCKER_PASS |
||||
|
||||
- name: Build Docker image for tag |
||||
if: github.event_name == 'release' |
||||
run: | |
||||
cd /tmp/build |
||||
export CIRCLE_TAG="${GITHUB_REF#*tags/}" |
||||
|
||||
docker build -t ${IMAGE}:$CIRCLE_TAG . |
||||
docker push ${IMAGE}:$CIRCLE_TAG |
||||
|
||||
if echo "$CIRCLE_TAG" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' ; then |
||||
export RELEASE="latest" |
||||
elif echo "$CIRCLE_TAG" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+$' ; then |
||||
export RELEASE="release-candidate" |
||||
fi |
||||
|
||||
docker tag ${IMAGE}:$CIRCLE_TAG ${IMAGE}:${RELEASE} |
||||
docker push ${IMAGE}:${RELEASE} |
||||
|
||||
- name: Build Docker image for develop |
||||
if: github.ref == 'refs/heads/develop' |
||||
run: | |
||||
cd /tmp/build |
||||
docker build -t ${IMAGE}:develop . |
||||
docker push ${IMAGE}:develop |
@ -1 +1 @@ |
||||
METEOR@1.8.1 |
||||
METEOR@1.8.3 |
||||
|
@ -0,0 +1,51 @@ |
||||
const getMongoVersion = async function({ version, git }) { |
||||
try { |
||||
const workflows = await git.show([`${ version }:.github/workflows/build_and_test.yml`]); |
||||
|
||||
const mongoMatch = workflows.match(/mongodb\-version: \[([^\]]+)\]/); |
||||
if (!mongoMatch) { |
||||
return []; |
||||
} |
||||
|
||||
return mongoMatch[1].replace(/"/g, '').replace(/ /g, '').split(','); |
||||
} catch (e) { |
||||
console.error(e); |
||||
} |
||||
return []; |
||||
}; |
||||
|
||||
const getNodeNpmVersions = async function({ version, git, request }) { |
||||
try { |
||||
const meteorRelease = await git.show([`${ version }:.meteor/release`]); |
||||
if (!/^METEOR@(\d+\.){1,2}\d/.test(meteorRelease)) { |
||||
return {}; |
||||
} |
||||
|
||||
const meteorVersion = meteorRelease.replace(/\n|\s/g, ''); |
||||
|
||||
const requestResult = await request(`https://raw.githubusercontent.com/meteor/meteor/release/${ meteorVersion }/scripts/build-dev-bundle-common.sh`); |
||||
|
||||
return { |
||||
node_version: requestResult.match(/NODE_VERSION=((?:\d+\.){2}\d)/m)[1], |
||||
npm_version: requestResult.match(/NPM_VERSION=((?:\d+\.){2}\d)/m)[1], |
||||
}; |
||||
} catch (e) { |
||||
console.error(e); |
||||
} |
||||
|
||||
return {}; |
||||
}; |
||||
|
||||
module.exports = async function({ version, git, request }) { |
||||
const mongo_versions = await getMongoVersion({ version, git }); |
||||
const { |
||||
node_version, |
||||
npm_version, |
||||
} = await getNodeNpmVersions({ version, git, request }); |
||||
|
||||
return { |
||||
node_version, |
||||
npm_version, |
||||
mongo_versions, |
||||
}; |
||||
}; |
@ -1,6 +0,0 @@ |
||||
#!/usr/bin/env bash |
||||
|
||||
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then |
||||
sh -e /etc/init.d/xvfb start |
||||
sleep 3 |
||||
fi |
@ -0,0 +1,31 @@ |
||||
import React from 'react'; |
||||
|
||||
import { MeteorProviderMock } from './providers'; |
||||
|
||||
export const rocketChatDecorator = (fn) => { |
||||
const linkElement = document.getElementById('theme-styles') || document.createElement('link'); |
||||
if (linkElement.id !== 'theme-styles') { |
||||
require('../../app/theme/client/main.css'); |
||||
require('../../app/theme/client/vendor/fontello/css/fontello.css'); |
||||
require('../../client/rocketchat.font.css'); |
||||
linkElement.setAttribute('id', 'theme-styles'); |
||||
linkElement.setAttribute('rel', 'stylesheet'); |
||||
linkElement.setAttribute('href', 'https://open.rocket.chat/theme.css'); |
||||
document.head.appendChild(linkElement); |
||||
} |
||||
|
||||
// eslint-disable-next-line import/no-unresolved
|
||||
const { default: icons } = require('!!raw-loader!../../private/public/icons.svg'); |
||||
|
||||
return <MeteorProviderMock> |
||||
<style>{` |
||||
body { |
||||
background-color: white; |
||||
} |
||||
`}</style>
|
||||
<div dangerouslySetInnerHTML={{ __html: icons }} /> |
||||
<div className='global-font-family color-primary-font-color'> |
||||
{fn()} |
||||
</div> |
||||
</MeteorProviderMock>; |
||||
}; |
@ -0,0 +1,67 @@ |
||||
import i18next from 'i18next'; |
||||
import React from 'react'; |
||||
|
||||
import { TranslationContext } from '../../client/contexts/TranslationContext'; |
||||
|
||||
let contextValue; |
||||
|
||||
const getContextValue = () => { |
||||
if (contextValue) { |
||||
return contextValue; |
||||
} |
||||
|
||||
i18next.init({ |
||||
fallbackLng: 'en', |
||||
defaultNS: 'project', |
||||
resources: { |
||||
en: { |
||||
project: require('../../packages/rocketchat-i18n/i18n/en.i18n.json'), |
||||
}, |
||||
}, |
||||
interpolation: { |
||||
prefix: '__', |
||||
suffix: '__', |
||||
}, |
||||
initImmediate: false, |
||||
}); |
||||
|
||||
const translate = (key, ...replaces) => { |
||||
if (typeof replaces[0] === 'object') { |
||||
const [options] = replaces; |
||||
return i18next.t(key, options); |
||||
} |
||||
|
||||
if (replaces.length === 0) { |
||||
return i18next.t(key); |
||||
} |
||||
|
||||
return i18next.t(key, { |
||||
postProcess: 'sprintf', |
||||
sprintf: replaces, |
||||
}); |
||||
}; |
||||
|
||||
translate.has = (key) => key && i18next.exists(key); |
||||
|
||||
contextValue = { |
||||
languages: [{ |
||||
name: 'English', |
||||
en: 'English', |
||||
key: 'en', |
||||
}], |
||||
language: 'en', |
||||
translate, |
||||
}; |
||||
|
||||
return contextValue; |
||||
}; |
||||
|
||||
function TranslationProviderMock({ children }) { |
||||
return <TranslationContext.Provider children={children} value={getContextValue()} />; |
||||
} |
||||
|
||||
export function MeteorProviderMock({ children }) { |
||||
return <TranslationProviderMock> |
||||
{children} |
||||
</TranslationProviderMock>; |
||||
} |
@ -1,4 +1,4 @@ |
||||
app/theme/client/vendor/fontello/css/fontello.css |
||||
packages/meteor-autocomplete/client/autocomplete.css |
||||
app/meteor-autocomplete/client/autocomplete.css |
||||
app/katex/katex.min.css |
||||
app/emoji-emojione/client/*.css |
||||
|
@ -1,104 +0,0 @@ |
||||
language: node_js |
||||
services: |
||||
- docker |
||||
- mongodb |
||||
branches: |
||||
only: |
||||
- develop |
||||
- "/^\\d+\\.\\d+\\.\\d+(-rc\\.\\d+)?$/" |
||||
git: |
||||
depth: 1 |
||||
node_js: |
||||
- '8' |
||||
addons: |
||||
apt: |
||||
sources: |
||||
- google-chrome |
||||
- ubuntu-toolchain-r-test |
||||
packages: |
||||
- google-chrome-stable |
||||
- g++-4.8 |
||||
firefox: "latest" |
||||
before_cache: |
||||
- rm -rf $HOME/build/RocketChat/Rocket.Chat/.meteor/local/log |
||||
- rm -rf $HOME/build/RocketChat/Rocket.Chat/.meteor/local/run |
||||
- rm -rf $HOME/build/RocketChat/Rocket.Chat/.meteor/local/db |
||||
cache: |
||||
directories: |
||||
- "$HOME/node_modules" |
||||
- "$HOME/.meteor" |
||||
- "$HOME/.npm" |
||||
- "$HOME/.node-gyp" |
||||
- "$HOME/build/RocketChat/Rocket.Chat/node_modules" |
||||
- "$HOME/build/RocketChat/Rocket.Chat/.meteor/local" |
||||
- "$HOME/build/RocketChat/Rocket.Chat/packages/rocketchat-livechat/.npm" |
||||
- "$HOME/build/RocketChat/Rocket.Chat/packages/rocketchat-livechat/.app/node_modules" |
||||
- "$HOME/build/RocketChat/Rocket.Chat/packages/rocketchat-livechat/.app/.meteor/local" |
||||
before_install: |
||||
- if [ ! -e "$HOME/.meteor/meteor" ]; then curl https://install.meteor.com | sed s/--progress-bar/-sL/g | /bin/sh; fi |
||||
# Start X Virtual Frame Buffer for headless testing with real browsers |
||||
- .scripts/start-xvfb.sh |
||||
install: |
||||
- export PATH="$HOME/.meteor:$PATH" |
||||
before_script: |
||||
- if [[ $TRAVIS_TAG ]]; then meteor reset; fi |
||||
- echo "replication:" | sudo tee -a /etc/mongod.conf |
||||
- |- |
||||
echo " replSetName: \"rs0\"" | sudo tee -a /etc/mongod.conf |
||||
- sudo service mongod restart |
||||
- mkdir /tmp/build |
||||
- meteor --version |
||||
- travis_retry meteor npm install |
||||
- |- |
||||
mongo --eval 'rs.initiate({_id:"rs0", members: [{"_id":1, "host":"localhost:27017"}]})' |
||||
- meteor npm run lint |
||||
- meteor npm run testunit |
||||
- travis_retry meteor build --headless /tmp/build |
||||
- mkdir /tmp/build-test |
||||
- tar -xf /tmp/build/Rocket.Chat.tar.gz -C /tmp/build-test/ |
||||
- cd /tmp/build-test/bundle/programs/server |
||||
- npm install |
||||
- cd - |
||||
- mongo --eval 'rs.status()' |
||||
- mongo meteor --eval 'db.getCollectionNames()' |
||||
script: |
||||
- travis_retry npm test |
||||
- mongo meteor --eval 'db.dropDatabase()' |
||||
- unset MONGO_OPLOG_URL |
||||
- travis_retry npm test |
||||
before_deploy: |
||||
- source ".travis/setartname.sh" |
||||
- source ".travis/setdeploydir.sh" |
||||
- ".travis/setupsig.sh" |
||||
- ".travis/namefiles.sh" |
||||
deploy: |
||||
- provider: s3 |
||||
access_key_id: AKIAIKIA7H7D47KUHYCA |
||||
secret_access_key: "$ACCESSKEY" |
||||
bucket: download.rocket.chat |
||||
skip_cleanup: true |
||||
upload_dir: build |
||||
local_dir: "$ROCKET_DEPLOY_DIR" |
||||
on: |
||||
condition: "$TRAVIS_PULL_REQUEST=false" |
||||
all_branches: true |
||||
# - provider: releases |
||||
# api-key: "$GITHUB_TOKEN" |
||||
# file_glob: true |
||||
# file: build/* |
||||
# skip_cleanup: true |
||||
# on: |
||||
# tags: true |
||||
|
||||
after_deploy: |
||||
- ".travis/docker.sh" |
||||
- ".travis/update-releases.sh" |
||||
- ".travis/snap.sh" |
||||
env: |
||||
global: |
||||
- DISPLAY=:99.0 |
||||
- CXX=g++-4.8 |
||||
- secure: HrPOM5sBibYkMcf9aeQThYPCDiXeLkg0Xgv0HvH88/ku/gphDpNEjHNReHZM3cyfm9y3RhHpVdD+Zzy38S2goKyewRzpXJsuyerOYkjND0v3tivhs9CAX8PAUxj1U5zllTyH4bgW2ZwRtNnwnmtIM/JJlnySMpKVDqIZBpbhn3ph9bJ2J+BW3D3Jw8meQ1vCX8szIibyJK/5QX6HG2RBFXJGYoQ8DmR8jQv0aJQvT1Az5DO4yImk8tX4NP95qOc19Jywr1DsbaSBZeJ8lFJAmBpIGx7KAmUVCcxSxfbXGRhs2K4iEYb3rJ/dU6KiyPsKGUG4aYNGgbvcX0ZxX/BZ6ZU9ff0E4IIf43IxoN3ElrOqOFk5msJAXbrJEreINSzDqKOy8NFYtCQ49E2gwzfage4ZXkhFyx3wMPa5bzpr3ncsTceMjMVz03uL781X6NLuCkUmXv+n8K2MNhJU9Xinpdx1GRJm+0lXJspNNJ1ruHeJtls4epj4bmCwKmmZbFKPXqa5e8xVcMIkwt1LMiHduhE+WgKNHdOMhXrCcTxF62ybLlsHXmyLLJeNjTeKS8QG2XSoonClDAz/1R41I1DsMPblcgz9uvYCf7UtyftbhJ83bnJeEmOYQiwijLG0+QMq+B2+mmZan3Z7Hl7O53dnwuLxz7EO7EhQhY+CqHVgc6s= |
||||
- MONGO_OPLOG_URL: "mongodb://localhost:27017/local" |
||||
- MONGO_URL: "mongodb://localhost:27017/meteor" |
||||
- TEST_MODE: "true" |
@ -1,15 +0,0 @@ |
||||
#!/bin/bash |
||||
set -x |
||||
set -euvo pipefail |
||||
IFS=$'\n\t' |
||||
|
||||
CURL_URL="https://registry.hub.docker.com/u/rocketchat/rocket.chat/trigger/$PUSHTOKEN/" |
||||
|
||||
if [[ $TRAVIS_TAG ]] |
||||
then |
||||
CURL_DATA='{"source_type":"Tag","source_name":"'"$TRAVIS_TAG"'"}'; |
||||
else |
||||
CURL_DATA='{"source_type":"Branch","source_name":"'"$TRAVIS_BRANCH"'"}'; |
||||
fi |
||||
|
||||
curl -H "Content-Type: application/json" --data "$CURL_DATA" -X POST "$CURL_URL" |
@ -1,9 +0,0 @@ |
||||
#!/bin/bash |
||||
set -x |
||||
set -euvo pipefail |
||||
IFS=$'\n\t' |
||||
|
||||
FILENAME="$ROCKET_DEPLOY_DIR/rocket.chat-$ARTIFACT_NAME.tgz"; |
||||
|
||||
ln -s /tmp/build/Rocket.Chat.tar.gz "$FILENAME" |
||||
gpg --armor --detach-sign "$FILENAME" |
@ -1,6 +0,0 @@ |
||||
if [[ $TRAVIS_TAG ]] |
||||
then |
||||
export ARTIFACT_NAME="$(meteor npm run version --silent)" |
||||
else |
||||
export ARTIFACT_NAME="$(meteor npm run version --silent).$TRAVIS_BUILD_NUMBER" |
||||
fi |
@ -1,2 +0,0 @@ |
||||
export ROCKET_DEPLOY_DIR="/tmp/deploy" |
||||
mkdir -p $ROCKET_DEPLOY_DIR |
@ -1,9 +0,0 @@ |
||||
#!/bin/bash |
||||
set -x |
||||
set -euvo pipefail |
||||
IFS=$'\n\t' |
||||
|
||||
cp .travis/sign.key.gpg /tmp |
||||
gpg --yes --batch --passphrase=$mypass /tmp/sign.key.gpg |
||||
gpg --allow-secret-key-import --import /tmp/sign.key |
||||
rm /tmp/sign.key |
Binary file not shown.
@ -1,54 +0,0 @@ |
||||
#!/bin/bash |
||||
set -euvo pipefail |
||||
IFS=$'\n\t' |
||||
|
||||
# Add launchpad to known hosts |
||||
ssh-keyscan -t rsa -H git.launchpad.net > ~/.ssh/known_hosts |
||||
|
||||
git config user.name "CI Bot" |
||||
git config user.email "rocketchat.buildmaster@git.launchpad.net" |
||||
|
||||
# Determine the channel to push snap to. |
||||
if [[ $TRAVIS_TAG =~ ^[0-9]+\.[0-9]+\.[0-9]+-rc\.[0-9]+ ]]; then |
||||
CHANNEL=candidate |
||||
RC_VERSION=$TRAVIS_TAG |
||||
elif [[ $TRAVIS_TAG ]]; then |
||||
CHANNEL=stable |
||||
RC_VERSION=$TRAVIS_TAG |
||||
else |
||||
CHANNEL=edge |
||||
RC_VERSION=2.3.2 |
||||
fi |
||||
|
||||
echo "Preparing to trigger a snap release for $CHANNEL channel" |
||||
|
||||
cd $PWD/.snapcraft |
||||
|
||||
# Decrypt key |
||||
openssl aes-256-cbc -K $encrypted_f5c8ae370556_key -iv $encrypted_f5c8ae370556_iv -in launchpadkey.enc -out launchpadkey -d |
||||
|
||||
# Change permissions |
||||
chmod 0600 launchpadkey |
||||
|
||||
# We need some meta data so it'll actually commit. This could be useful to have for debugging later. |
||||
echo "Tag: $TRAVIS_TAG \r\nBranch: $TRAVIS_BRANCH\r\nBuild: $TRAVIS_BUILD_NUMBER\r\nCommit: $TRAVIS_COMMIT" > buildinfo |
||||
|
||||
# Clone launchpad repo for the channel down. |
||||
GIT_SSH_COMMAND="ssh -i launchpadkey" git clone -b $CHANNEL git+ssh://rocket.chat.buildmaster@git.launchpad.net/rocket.chat launchpad |
||||
|
||||
# Rarely will change, but just incase we copy it all |
||||
cp -r resources buildinfo launchpad/ |
||||
sed s/#{RC_VERSION}/$RC_VERSION/ snapcraft.yaml > launchpad/snapcraft.yaml |
||||
|
||||
cd launchpad |
||||
git add resources snapcraft.yaml buildinfo |
||||
|
||||
# Another place where basic meta data will live for at a glance info |
||||
git commit -m "Travis Build: $TRAVIS_BUILD_NUMBER Travis Commit: $TRAVIS_COMMIT" |
||||
|
||||
# Push up up to the branch of choice. |
||||
GIT_SSH_COMMAND="ssh -i ../launchpadkey" git push origin $CHANNEL |
||||
|
||||
# Clean up |
||||
cd .. |
||||
rm -rf launchpadkey launchpad |
@ -1,8 +0,0 @@ |
||||
#!/bin/bash |
||||
set -x |
||||
set -euvo pipefail |
||||
IFS=$'\n\t' |
||||
|
||||
CURL_URL="https://rocket.chat/releases/update" |
||||
|
||||
curl -X POST "$CURL_URL" |
@ -0,0 +1,20 @@ |
||||
import { CustomSounds } from '../../../models/server/raw'; |
||||
|
||||
export async function findCustomSounds({ query = {}, pagination: { offset, count, sort } }) { |
||||
const cursor = await CustomSounds.find(query, { |
||||
sort: sort || { name: 1 }, |
||||
skip: offset, |
||||
limit: count, |
||||
}); |
||||
|
||||
const total = await cursor.count(); |
||||
|
||||
const sounds = await cursor.toArray(); |
||||
|
||||
return { |
||||
sounds, |
||||
count: sounds.length, |
||||
offset, |
||||
total, |
||||
}; |
||||
} |
@ -0,0 +1,20 @@ |
||||
import { CustomUserStatus } from '../../../models/server/raw'; |
||||
|
||||
export async function findCustomUserStatus({ query = {}, pagination: { offset, count, sort } }) { |
||||
const cursor = await CustomUserStatus.find(query, { |
||||
sort: sort || { name: 1 }, |
||||
skip: offset, |
||||
limit: count, |
||||
}); |
||||
|
||||
const total = await cursor.count(); |
||||
|
||||
const statuses = await cursor.toArray(); |
||||
|
||||
return { |
||||
statuses, |
||||
count: statuses.length, |
||||
offset, |
||||
total, |
||||
}; |
||||
} |
@ -0,0 +1,20 @@ |
||||
import { EmojiCustom } from '../../../models/server/raw'; |
||||
|
||||
export async function findEmojisCustom({ query = {}, pagination: { offset, count, sort } }) { |
||||
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, |
||||
}; |
||||
} |
@ -0,0 +1,27 @@ |
||||
import { Integrations } from '../../../models/server/raw'; |
||||
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission'; |
||||
|
||||
const hasIntegrationsPermission = async (userId, integration) => { |
||||
const type = integration.type === 'webhook-incoming' ? 'incoming' : 'outgoing'; |
||||
|
||||
if (await hasPermissionAsync(userId, `manage-${ type }-integrations`)) { |
||||
return true; |
||||
} |
||||
|
||||
if (userId === integration._createdBy._id) { |
||||
return hasPermissionAsync(userId, `manage-own-${ type }-integrations`); |
||||
} |
||||
|
||||
return false; |
||||
}; |
||||
|
||||
export const findOneIntegration = async ({ userId, integrationId, createdBy }) => { |
||||
const integration = await Integrations.findOneByIdAndCreatedByIfExists({ _id: integrationId, createdBy }); |
||||
if (!integration) { |
||||
throw new Error('The integration does not exists.'); |
||||
} |
||||
if (!await hasIntegrationsPermission(userId, integration)) { |
||||
throw new Error('not-authorized'); |
||||
} |
||||
return integration; |
||||
}; |
@ -0,0 +1,13 @@ |
||||
import { OAuthApps } from '../../../models/server/raw'; |
||||
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission'; |
||||
|
||||
export async function findOAuthApps({ uid }) { |
||||
if (!await hasPermissionAsync(uid, 'manage-oauth-apps')) { |
||||
throw new Error('error-not-allowed'); |
||||
} |
||||
return OAuthApps.find().toArray(); |
||||
} |
||||
|
||||
export async function findOneAuthApp({ clientId, appId }) { |
||||
return OAuthApps.findOneAuthAppByIdOrClientId({ clientId, appId }); |
||||
} |
@ -0,0 +1,77 @@ |
||||
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission'; |
||||
import { Rooms } from '../../../models/server/raw'; |
||||
|
||||
export async function findAdminRooms({ uid, filter, types = [], pagination: { offset, count, sort } }) { |
||||
if (!await hasPermissionAsync(uid, 'view-room-administration')) { |
||||
throw new Error('error-not-authorized'); |
||||
} |
||||
const fields = { |
||||
prid: 1, |
||||
fname: 1, |
||||
name: 1, |
||||
t: 1, |
||||
cl: 1, |
||||
u: 1, |
||||
usernames: 1, |
||||
usersCount: 1, |
||||
muted: 1, |
||||
unmuted: 1, |
||||
ro: 1, |
||||
default: 1, |
||||
topic: 1, |
||||
msgs: 1, |
||||
archived: 1, |
||||
tokenpass: 1, |
||||
}; |
||||
|
||||
const name = filter && filter.trim(); |
||||
const discussion = types && types.includes('discussions'); |
||||
const showTypes = Array.isArray(types) ? types.filter((type) => type !== 'discussions') : []; |
||||
const options = { |
||||
fields, |
||||
sort: sort || { default: -1, name: 1 }, |
||||
skip: offset, |
||||
limit: count, |
||||
}; |
||||
|
||||
let cursor = Rooms.findByNameContaining(name, discussion, options); |
||||
|
||||
if (name && showTypes.length) { |
||||
cursor = Rooms.findByNameContainingAndTypes(name, showTypes, discussion, options); |
||||
} else if (showTypes.length) { |
||||
cursor = Rooms.findByTypes(showTypes, discussion, options); |
||||
} |
||||
|
||||
const total = await cursor.count(); |
||||
|
||||
const rooms = await cursor.toArray(); |
||||
|
||||
return { |
||||
rooms, |
||||
count: rooms.length, |
||||
offset, |
||||
total, |
||||
}; |
||||
} |
||||
|
||||
export async function findChannelAndPrivateAutocomplete({ uid, selector }) { |
||||
if (!await hasPermissionAsync(uid, 'view-other-user-channels')) { |
||||
return { items: [] }; |
||||
} |
||||
const options = { |
||||
fields: { |
||||
_id: 1, |
||||
name: 1, |
||||
}, |
||||
limit: 10, |
||||
sort: { |
||||
name: 1, |
||||
}, |
||||
}; |
||||
|
||||
const rooms = await Rooms.findChannelAndPrivateByNameStarting(selector.name, options).toArray(); |
||||
|
||||
return { |
||||
items: rooms, |
||||
}; |
||||
} |
@ -0,0 +1,27 @@ |
||||
import { Users } from '../../../models/server/raw'; |
||||
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission'; |
||||
|
||||
export async function findUsersToAutocomplete({ uid, selector }) { |
||||
if (!await hasPermissionAsync(uid, 'view-outside-room')) { |
||||
return { items: [] }; |
||||
} |
||||
const exceptions = selector.exceptions || []; |
||||
const conditions = selector.conditions || {}; |
||||
const options = { |
||||
fields: { |
||||
name: 1, |
||||
username: 1, |
||||
status: 1, |
||||
}, |
||||
sort: { |
||||
username: 1, |
||||
}, |
||||
limit: 10, |
||||
}; |
||||
|
||||
const users = await Users.findActiveByUsernameOrNameRegexWithExceptionsAndConditions(selector.term, exceptions, conditions, options).toArray(); |
||||
|
||||
return { |
||||
items: users, |
||||
}; |
||||
} |
@ -0,0 +1,14 @@ |
||||
import { WebdavAccounts } from '../../../models/server/raw'; |
||||
|
||||
export async function findWebdavAccountsByUserId({ uid }) { |
||||
return { |
||||
accounts: await WebdavAccounts.findWithUserId(uid, { |
||||
fields: { |
||||
_id: 1, |
||||
username: 1, |
||||
server_url: 1, |
||||
name: 1, |
||||
}, |
||||
}).toArray(), |
||||
}; |
||||
} |
@ -0,0 +1,18 @@ |
||||
import { API } from '../api'; |
||||
import { findCustomSounds } from '../lib/custom-sounds'; |
||||
|
||||
API.v1.addRoute('custom-sounds.list', { authRequired: true }, { |
||||
get() { |
||||
const { offset, count } = this.getPaginationItems(); |
||||
const { sort, query } = this.parseJsonQuery(); |
||||
|
||||
return API.v1.success(Promise.await(findCustomSounds({ |
||||
query, |
||||
pagination: { |
||||
offset, |
||||
count, |
||||
sort, |
||||
}, |
||||
}))); |
||||
}, |
||||
}); |
@ -0,0 +1,18 @@ |
||||
import { API } from '../api'; |
||||
import { findCustomUserStatus } from '../lib/custom-user-status'; |
||||
|
||||
API.v1.addRoute('custom-user-status.list', { authRequired: true }, { |
||||
get() { |
||||
const { offset, count } = this.getPaginationItems(); |
||||
const { sort, query } = this.parseJsonQuery(); |
||||
|
||||
return API.v1.success(Promise.await(findCustomUserStatus({ |
||||
query, |
||||
pagination: { |
||||
offset, |
||||
count, |
||||
sort, |
||||
}, |
||||
}))); |
||||
}, |
||||
}); |
@ -0,0 +1,61 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
import { API } from '../api'; |
||||
import { findOrCreateInvite } from '../../../invites/server/functions/findOrCreateInvite'; |
||||
import { removeInvite } from '../../../invites/server/functions/removeInvite'; |
||||
import { listInvites } from '../../../invites/server/functions/listInvites'; |
||||
import { useInviteToken } from '../../../invites/server/functions/useInviteToken'; |
||||
import { validateInviteToken } from '../../../invites/server/functions/validateInviteToken'; |
||||
|
||||
API.v1.addRoute('listInvites', { authRequired: true }, { |
||||
get() { |
||||
const result = listInvites(this.userId); |
||||
return API.v1.success(result); |
||||
}, |
||||
}); |
||||
|
||||
API.v1.addRoute('findOrCreateInvite', { authRequired: true }, { |
||||
post() { |
||||
const { rid, days, maxUses } = this.bodyParams; |
||||
const result = findOrCreateInvite(this.userId, { rid, days, maxUses }); |
||||
|
||||
return API.v1.success(result); |
||||
}, |
||||
}); |
||||
|
||||
API.v1.addRoute('removeInvite/:_id', { authRequired: true }, { |
||||
delete() { |
||||
const { _id } = this.urlParams; |
||||
const result = removeInvite(this.userId, { _id }); |
||||
|
||||
return API.v1.success(result); |
||||
}, |
||||
}); |
||||
|
||||
API.v1.addRoute('useInviteToken', { authRequired: true }, { |
||||
post() { |
||||
const { token } = this.bodyParams; |
||||
const result = useInviteToken(this.userId, token); |
||||
|
||||
return API.v1.success(result); |
||||
}, |
||||
}); |
||||
|
||||
API.v1.addRoute('validateInviteToken', { authRequired: false }, { |
||||
post() { |
||||
const { token } = this.bodyParams; |
||||
|
||||
if (!token) { |
||||
throw new Meteor.Error('error-invalid-token', 'The invite token is invalid.', { method: 'validateInviteToken', field: 'token' }); |
||||
} |
||||
|
||||
let valid = true; |
||||
try { |
||||
validateInviteToken(token); |
||||
} catch (e) { |
||||
valid = false; |
||||
} |
||||
|
||||
return API.v1.success({ valid }); |
||||
}, |
||||
}); |
@ -0,0 +1,23 @@ |
||||
import { API } from '../api'; |
||||
import { findOAuthApps, findOneAuthApp } from '../lib/oauthApps'; |
||||
|
||||
API.v1.addRoute('oauth-apps.list', { authRequired: true }, { |
||||
get() { |
||||
return API.v1.success({ |
||||
oauthApps: Promise.await(findOAuthApps({ uid: this.userId })), |
||||
}); |
||||
}, |
||||
}); |
||||
|
||||
API.v1.addRoute('oauth-apps.get', { authRequired: true }, { |
||||
get() { |
||||
const { clientId, appId } = this.queryParams; |
||||
if (!clientId && !appId) { |
||||
return API.v1.failure('At least one of the query parameters "clientId" or "appId" is required.'); |
||||
} |
||||
|
||||
return API.v1.success({ |
||||
oauthApp: Promise.await(findOneAuthApp({ clientId, appId })), |
||||
}); |
||||
}, |
||||
}); |
@ -0,0 +1,8 @@ |
||||
import { API } from '../api'; |
||||
import { findWebdavAccountsByUserId } from '../lib/webdav'; |
||||
|
||||
API.v1.addRoute('webdav.getMyAccounts', { authRequired: true }, { |
||||
get() { |
||||
return API.v1.success(Promise.await(findWebdavAccountsByUserId({ uid: this.userId }))); |
||||
}, |
||||
}); |
@ -0,0 +1,3 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
export const rolesStreamer = new Meteor.Streamer('roles'); |
@ -1,6 +1,8 @@ |
||||
import { Roles } from '../../../models'; |
||||
import { Roles } from '../../../models/server/raw'; |
||||
|
||||
export const hasRole = (userId, roleNames, scope) => { |
||||
export const hasRoleAsync = async (userId, roleNames, scope) => { |
||||
roleNames = [].concat(roleNames); |
||||
return Roles.isUserInRoles(userId, roleNames, scope); |
||||
}; |
||||
|
||||
export const hasRole = (userId, roleNames, scope) => Promise.await(hasRoleAsync(userId, roleNames, scope)); |
||||
|
@ -0,0 +1,5 @@ |
||||
import { Meteor } from 'meteor/meteor'; |
||||
|
||||
export const rolesStreamer = new Meteor.Streamer('roles'); |
||||
rolesStreamer.allowWrite('none'); |
||||
rolesStreamer.allowRead('logged'); |
@ -1,3 +0,0 @@ |
||||
import { Mongo } from 'meteor/mongo'; |
||||
|
||||
export const DiscussionOfRoom = new Mongo.Collection('rocketchat_discussions_of_room'); |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue