1
0
mirror of https://github.com/misskey-dev/misskey synced 2024-11-25 15:46:39 +09:00

[Server] ✌️

This commit is contained in:
syuilo 2017-02-12 06:27:47 +09:00
parent 3aec163822
commit 5149c4cea8
2 changed files with 9 additions and 7 deletions

View File

@ -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",

View File

@ -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;