[mirotalksfu] - add Slack integration
هذا الالتزام موجود في:
@@ -46,6 +46,7 @@
|
|||||||
- Possibility to Change UI Themes
|
- Possibility to Change UI Themes
|
||||||
- Possibility to protect your Host with username and password (default disabled)
|
- Possibility to protect your Host with username and password (default disabled)
|
||||||
- Supports [REST API](app/api/README.md) (Application Programming Interface)
|
- Supports [REST API](app/api/README.md) (Application Programming Interface)
|
||||||
|
- [Slack](https://api.slack.com/apps/) API integration
|
||||||
- [Sentry](https://sentry.io/) error reporting
|
- [Sentry](https://sentry.io/) error reporting
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|||||||
@@ -22,6 +22,13 @@ const swaggerDocument = yamlJS.load(path.join(__dirname + '/../api/swagger.yaml'
|
|||||||
const Sentry = require('@sentry/node');
|
const Sentry = require('@sentry/node');
|
||||||
const { CaptureConsole } = require('@sentry/integrations');
|
const { CaptureConsole } = require('@sentry/integrations');
|
||||||
|
|
||||||
|
// Slack API
|
||||||
|
const CryptoJS = require('crypto-js');
|
||||||
|
const qS = require('qs');
|
||||||
|
const slackEnabled = config.slack.enabled;
|
||||||
|
const slackSigningSecret = config.slack.signingSecret;
|
||||||
|
const bodyParser = require('body-parser');
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
const options = {
|
const options = {
|
||||||
@@ -102,6 +109,7 @@ app.use(cors());
|
|||||||
app.use(compression());
|
app.use(compression());
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
app.use(express.static(dir.public));
|
app.use(express.static(dir.public));
|
||||||
|
app.use(bodyParser.urlencoded({ extended: true }));
|
||||||
app.use(apiBasePath + '/docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); // api docs
|
app.use(apiBasePath + '/docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument)); // api docs
|
||||||
|
|
||||||
// Remove trailing slashes in url handle bad requests
|
// Remove trailing slashes in url handle bad requests
|
||||||
@@ -259,6 +267,37 @@ app.post(['/api/v1/join'], (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ####################################################
|
||||||
|
// SLACK API
|
||||||
|
// ####################################################
|
||||||
|
|
||||||
|
app.post('/slack', (req, res) => {
|
||||||
|
if (!slackEnabled) return res.end('`Under maintenance` - Please check back soon.');
|
||||||
|
|
||||||
|
log.debug('Slack', req.headers);
|
||||||
|
|
||||||
|
if (!slackSigningSecret) return res.end('`Slack Signing Secret is empty!`');
|
||||||
|
|
||||||
|
let slackSignature = req.headers['x-slack-signature'];
|
||||||
|
let requestBody = qS.stringify(req.body, { format: 'RFC1738' });
|
||||||
|
let timeStamp = req.headers['x-slack-request-timestamp'];
|
||||||
|
let time = Math.floor(new Date().getTime() / 1000);
|
||||||
|
|
||||||
|
if (Math.abs(time - timeStamp) > 300) return res.end('`Wrong timestamp` - Ignore this request.');
|
||||||
|
|
||||||
|
let sigBaseString = 'v0:' + timeStamp + ':' + requestBody;
|
||||||
|
let mySignature = 'v0=' + CryptoJS.HmacSHA256(sigBaseString, slackSigningSecret);
|
||||||
|
|
||||||
|
if (mySignature == slackSignature) {
|
||||||
|
let host = req.headers.host;
|
||||||
|
let api = new ServerApi(host);
|
||||||
|
let meetingURL = api.getMeetingURL();
|
||||||
|
log.debug('Slack', { meeting: meetingURL });
|
||||||
|
return res.end(meetingURL);
|
||||||
|
}
|
||||||
|
return res.end('`Wrong signature` - Verification failed!');
|
||||||
|
});
|
||||||
|
|
||||||
// not match any of page before, so 404 not found
|
// not match any of page before, so 404 not found
|
||||||
app.get('*', function (req, res) {
|
app.get('*', function (req, res) {
|
||||||
res.sendFile(views.notFound);
|
res.sendFile(views.notFound);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ const config = require('./config');
|
|||||||
const { v4: uuidV4 } = require('uuid');
|
const { v4: uuidV4 } = require('uuid');
|
||||||
|
|
||||||
module.exports = class ServerApi {
|
module.exports = class ServerApi {
|
||||||
constructor(host, authorization) {
|
constructor(host = null, authorization = null) {
|
||||||
this._host = host;
|
this._host = host;
|
||||||
this._authorization = authorization;
|
this._authorization = authorization;
|
||||||
this._api_key_secret = config.apiKeySecret;
|
this._api_key_secret = config.apiKeySecret;
|
||||||
|
|||||||
@@ -55,6 +55,16 @@ module.exports = {
|
|||||||
DSN: '',
|
DSN: '',
|
||||||
tracesSampleRate: 0.5,
|
tracesSampleRate: 0.5,
|
||||||
},
|
},
|
||||||
|
slack: {
|
||||||
|
/*
|
||||||
|
1. Goto https://api.slack.com/apps/
|
||||||
|
2. Create your app
|
||||||
|
3. On Settings - Basic Information - App Credentials, chose your Signing Secret
|
||||||
|
4. Create a Slash Commands and put as Request URL: https://your.domain.name/slack
|
||||||
|
*/
|
||||||
|
enabled: false,
|
||||||
|
signingSecret: '',
|
||||||
|
},
|
||||||
mediasoup: {
|
mediasoup: {
|
||||||
// Worker settings
|
// Worker settings
|
||||||
numWorkers: Object.keys(os.cpus()).length,
|
numWorkers: Object.keys(os.cpus()).length,
|
||||||
|
|||||||
@@ -16,13 +16,16 @@
|
|||||||
"author": "Miroslav Pejic",
|
"author": "Miroslav Pejic",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"body-parser": "^1.20.0",
|
||||||
"compression": "1.7.4",
|
"compression": "1.7.4",
|
||||||
"cors": "2.8.5",
|
"cors": "2.8.5",
|
||||||
|
"crypto-js": "^4.1.1",
|
||||||
"express": "4.18.1",
|
"express": "4.18.1",
|
||||||
"httpolyglot": "0.1.2",
|
"httpolyglot": "0.1.2",
|
||||||
"mediasoup": "3.9.17",
|
"mediasoup": "3.9.17",
|
||||||
"mediasoup-client": "3.6.52",
|
"mediasoup-client": "3.6.52",
|
||||||
"ngrok": "4.3.1",
|
"ngrok": "4.3.1",
|
||||||
|
"qs": "^6.10.5",
|
||||||
"@sentry/node": "7.2.0",
|
"@sentry/node": "7.2.0",
|
||||||
"@sentry/integrations": "7.2.0",
|
"@sentry/integrations": "7.2.0",
|
||||||
"socket.io": "4.5.1",
|
"socket.io": "4.5.1",
|
||||||
|
|||||||
المرجع في مشكلة جديدة
حظر مستخدم