mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-12 01:51:02 +01:00
[Server] ✌️
This commit is contained in:
parent
3aec163822
commit
5149c4cea8
2 changed files with 9 additions and 7 deletions
|
@ -91,7 +91,6 @@
|
||||||
"file-type": "4.1.0",
|
"file-type": "4.1.0",
|
||||||
"fuckadblock": "3.2.1",
|
"fuckadblock": "3.2.1",
|
||||||
"git-last-commit": "0.2.0",
|
"git-last-commit": "0.2.0",
|
||||||
"github-webhook-handler": "0.6.0",
|
|
||||||
"glob": "7.1.1",
|
"glob": "7.1.1",
|
||||||
"gm": "1.23.0",
|
"gm": "1.23.0",
|
||||||
"gulp": "3.9.1",
|
"gulp": "3.9.1",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
import * as EventEmitter from 'events';
|
||||||
import * as express from 'express';
|
import * as express from 'express';
|
||||||
const createHandler = require('github-webhook-handler');
|
|
||||||
import User from '../models/user';
|
import User from '../models/user';
|
||||||
import config from '../../conf';
|
import config from '../../conf';
|
||||||
|
|
||||||
|
@ -17,12 +17,15 @@ module.exports = async (app: express.Application) => {
|
||||||
|
|
||||||
const post = text => require('../endpoints/posts/create')({ text }, bot);
|
const post = text => require('../endpoints/posts/create')({ text }, bot);
|
||||||
|
|
||||||
const handler = createHandler({
|
const handler = new EventEmitter();
|
||||||
path: '/hooks/github',
|
|
||||||
secret: config.github_bot.hook_secret
|
|
||||||
});
|
|
||||||
|
|
||||||
app.post('/hooks/github', handler);
|
app.post('/hooks/github', (req, res, next) => {
|
||||||
|
if (req.headers['x-hub-signature'] == config.github_bot.hook_secret) {
|
||||||
|
handler.emit(req.headers['x-github-event'], req.body);
|
||||||
|
} else {
|
||||||
|
res.sendStatus(400);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
handler.on('push', event => {
|
handler.on('push', event => {
|
||||||
const ref = event.payload.ref;
|
const ref = event.payload.ref;
|
||||||
|
|
Loading…
Reference in a new issue