mirror of
https://github.com/paricafe/misskey.git
synced 2024-11-24 17:36:43 -06: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",
|
||||
"fuckadblock": "3.2.1",
|
||||
"git-last-commit": "0.2.0",
|
||||
"github-webhook-handler": "0.6.0",
|
||||
"glob": "7.1.1",
|
||||
"gm": "1.23.0",
|
||||
"gulp": "3.9.1",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as EventEmitter from 'events';
|
||||
import * as express from 'express';
|
||||
const createHandler = require('github-webhook-handler');
|
||||
import User from '../models/user';
|
||||
import config from '../../conf';
|
||||
|
||||
|
@ -17,12 +17,15 @@ module.exports = async (app: express.Application) => {
|
|||
|
||||
const post = text => require('../endpoints/posts/create')({ text }, bot);
|
||||
|
||||
const handler = createHandler({
|
||||
path: '/hooks/github',
|
||||
secret: config.github_bot.hook_secret
|
||||
});
|
||||
const handler = new EventEmitter();
|
||||
|
||||
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 => {
|
||||
const ref = event.payload.ref;
|
||||
|
|
Loading…
Reference in a new issue