1
0
forked from mirror/misskey
misskey/src/queue/processors/http/report-github-failure.ts

25 lines
771 B
TypeScript
Raw Normal View History

2018-04-03 02:09:50 +09:00
import * as request from 'request-promise-native';
2018-03-31 19:55:00 +09:00
import User from '../../models/user';
const createPost = require('../../server/api/endpoints/posts/create');
2018-03-29 01:20:40 +09:00
2018-04-03 02:09:50 +09:00
export default async ({ data }) => {
2018-03-29 01:20:40 +09:00
const asyncBot = User.findOne({ _id: data.userId });
// Fetch parent status
2018-04-03 02:09:50 +09:00
const parentStatuses = await request({
2018-03-29 01:20:40 +09:00
url: `${data.parentUrl}/statuses`,
headers: {
'User-Agent': 'misskey'
2018-04-03 02:09:50 +09:00
},
json: true
2018-03-29 01:20:40 +09:00
});
2018-04-03 02:09:50 +09:00
const parentState = parentStatuses[0].state;
const stillFailed = parentState == 'failure' || parentState == 'error';
const text = stillFailed ?
`**⚠BUILD STILL FAILED⚠**: ?[${data.message}](${data.htmlUrl})` :
`**🚨BUILD FAILED🚨**: →→→?[${data.message}](${data.htmlUrl})←←←`;
createPost({ text }, await asyncBot);
2018-03-29 01:20:40 +09:00
};