Skip to content

Commit

Permalink
teste
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Aquino committed May 28, 2024
1 parent 612c78a commit 6f7047e
Show file tree
Hide file tree
Showing 11 changed files with 3,974 additions and 72 deletions.
30 changes: 30 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
### Rocket.Chat configuration
RC_DOCKERFILE = apps/meteor/.docker/Dockerfile
# Rocket.Chat version
# see:- https://github.com/RocketChat/Rocket.Chat/releases
RELEASE=
# MongoDB endpoint (include ?replicaSet= parameter)
MONGO_URL=mongodb://mongo:27017/rocketchat \
# MongoDB endpoint to the local database
MONGO_OPLOG_URL=
# IP to bind the process to
BIND_IP=
# URL used to access your Rocket.Chat instance
ROOT_URL= http://localhost:3000
# Port Rocket.Chat runs on (in-container)
PORT=3000
# Port on the host to bind to
HOST_PORT=

### MongoDB configuration
# MongoDB version/image tag
MONGODB_VERSION=
# See:- https://hub.docker.com/r/bitnami/mongodb

### Traefik config (if enabled)
# Traefik version/image tag
TRAEFIK_RELEASE=
# Domain for https (change ROOT_URL & BIND_IP accordingly)
DOMAIN=
# Email for certificate notifications
LETSENCRYPT_EMAIL=
1 change: 1 addition & 0 deletions apps/meteor/app/slashcommands-test/client/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './test';
24 changes: 24 additions & 0 deletions apps/meteor/app/slashcommands-test/client/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import type { SlashCommandCallbackParams } from '@rocket.chat/core-typings';

import { dispatchToastMessage } from '../../../client/lib/toast';
import { sdk } from '../../utils/client/lib/SDKClient';
import { slashCommands } from '../../utils/lib/slashCommand';

slashCommands.add({
command: 'test',
callback: async function Status({ params, userId }: SlashCommandCallbackParams<'test'>): Promise<void> {
if (!userId) {
return;
}

try {
await sdk.call('setUserStatus', undefined, params);
} catch (error) {
dispatchToastMessage({ type: 'error', message: error });
}
},
options: {
description: 'Slash_Status_Description',
params: 'Slash_Status_Params',
},
});
1 change: 1 addition & 0 deletions apps/meteor/app/slashcommands-test/server/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './test';
40 changes: 40 additions & 0 deletions apps/meteor/app/slashcommands-test/server/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { api } from '@rocket.chat/core-services';
import type { SlashCommandCallbackParams } from '@rocket.chat/core-typings';
import { Users } from '@rocket.chat/models';

import { i18n } from '../../../server/lib/i18n';
import { settings } from '../../settings/server';
import { setUserStatusMethod } from '../../user-status/server/methods/setUserStatus';
import { slashCommands } from '../../utils/lib/slashCommand';

slashCommands.add({
command: 'test',
callback: async function Status({ params, message, userId }: SlashCommandCallbackParams<'test'>): Promise<void> {
if (!userId) {
return;
}

const user = await Users.findOneById(userId, { projection: { language: 1 } });
const lng = user?.language || settings.get('Language') || 'en';

try {
await setUserStatusMethod(userId, undefined, params);

void api.broadcast('notify.ephemeralMessage', userId, message.rid, {
msg: i18n.t('StatusMessage_Changed_Successfully', { lng }),
});
} catch (err: any) {
if (err.error === 'error-not-allowed') {
void api.broadcast('notify.ephemeralMessage', userId, message.rid, {
msg: i18n.t('StatusMessage_Change_Disabled', { lng }),
});
}

throw err;
}
},
options: {
description: 'Slash_Status_Description',
params: 'Slash_Status_Params',
},
});
1 change: 1 addition & 0 deletions apps/meteor/client/importPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import '../app/slackbridge/client';
import '../app/slashcommands-archiveroom/client';
import '../app/slashcommand-asciiarts/client';
import '../app/slashcommands-create/client';
import '../app/slashcommands-test/client';
import '../app/slashcommands-hide/client';
import '../app/slashcommands-invite/client';
import '../app/slashcommands-inviteall/client';
Expand Down
1 change: 1 addition & 0 deletions apps/meteor/server/importPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import '../app/slackbridge/server';
import '../app/slashcommands-archiveroom/server';
import '../app/slashcommand-asciiarts/server';
import '../app/slashcommands-create/server';
import '../app/slashcommands-test/server';
import '../app/slashcommands-help/server';
import '../app/slashcommands-hide/server';
import '../app/slashcommands-invite/server';
Expand Down
46 changes: 46 additions & 0 deletions compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
volumes:
mongodb_data: { driver: local }

services:
rocketchat:
image: registry.rocket.chat/rocketchat/rocket.chat:${RELEASE:-latest}
restart: always
labels:
traefik.enable: 'true'
traefik.http.routers.rocketchat.rule: Host(`${DOMAIN:-}`)
traefik.http.routers.rocketchat.tls: 'true'
traefik.http.routers.rocketchat.entrypoints: https
traefik.http.routers.rocketchat.tls.certresolver: le
environment:
MONGO_URL: "${MONGO_URL:-\
mongodb://${MONGODB_ADVERTISED_HOSTNAME:-mongodb}:${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}/\
${MONGODB_DATABASE:-rocketchat}?replicaSet=${MONGODB_REPLICA_SET_NAME:-rs0}}"
MONGO_OPLOG_URL: "${MONGO_OPLOG_URL:\
-mongodb://${MONGODB_ADVERTISED_HOSTNAME:-mongodb}:${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}/\
local?replicaSet=${MONGODB_REPLICA_SET_NAME:-rs0}}"
ROOT_URL: ${ROOT_URL:-http://localhost:${HOST_PORT:-3000}}
PORT: ${PORT:-3000}
DEPLOY_METHOD: docker
DEPLOY_PLATFORM: ${DEPLOY_PLATFORM:-}
REG_TOKEN: ${REG_TOKEN:-}
depends_on:
- mongodb
expose:
- ${PORT:-3000}
ports:
- '${BIND_IP:-0.0.0.0}:${HOST_PORT:-3000}:${PORT:-3000}'

mongodb:
image: docker.io/bitnami/mongodb:${MONGODB_VERSION:-5.0}
restart: always
volumes:
- mongodb_data:/bitnami/mongodb
environment:
MONGODB_REPLICA_SET_MODE: primary
MONGODB_REPLICA_SET_NAME: ${MONGODB_REPLICA_SET_NAME:-rs0}
MONGODB_PORT_NUMBER: ${MONGODB_PORT_NUMBER:-27017}
MONGODB_INITIAL_PRIMARY_HOST: ${MONGODB_INITIAL_PRIMARY_HOST:-mongodb}
MONGODB_INITIAL_PRIMARY_PORT_NUMBER: ${MONGODB_INITIAL_PRIMARY_PORT_NUMBER:-27017}
MONGODB_ADVERTISED_HOSTNAME: ${MONGODB_ADVERTISED_HOSTNAME:-mongodb}
MONGODB_ENABLE_JOURNAL: ${MONGODB_ENABLE_JOURNAL:-true}
ALLOW_EMPTY_PASSWORD: ${ALLOW_EMPTY_PASSWORD:-yes}
Loading

0 comments on commit 6f7047e

Please sign in to comment.