summaryrefslogtreecommitdiff
path: root/src/queue/processors/http/report-github-failure.ts
blob: e747d062d3073f361522c29792b1aaba23450503 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import * as request from 'request-promise-native';
import User from '../../../models/user';
import createPost from '../../../api/post/create';

export default async ({ data }) => {
	const asyncBot = User.findOne({ _id: data.userId });

	// Fetch parent status
	const parentStatuses = await request({
		url: `${data.parentUrl}/statuses`,
		headers: {
			'User-Agent': 'misskey'
		},
		json: true
	});

	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(await asyncBot, { text });
};