Implement remote status retrieval
This commit is contained in:
parent
7da60a0147
commit
68a9aac957
46 changed files with 468 additions and 198 deletions
9
src/processor/http/index.ts
Normal file
9
src/processor/http/index.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import performActivityPub from './perform-activitypub';
|
||||
import reportGitHubFailure from './report-github-failure';
|
||||
|
||||
const handlers = {
|
||||
performActivityPub,
|
||||
reportGitHubFailure,
|
||||
};
|
||||
|
||||
export default (job, done) => handlers[job.data.type](job).then(() => done(), done);
|
||||
6
src/processor/http/perform-activitypub.ts
Normal file
6
src/processor/http/perform-activitypub.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import User from '../../models/user';
|
||||
import act from '../../common/remote/activitypub/act';
|
||||
|
||||
export default ({ data }, done) => User.findOne({ _id: data.actor })
|
||||
.then(actor => act(actor, data.outbox))
|
||||
.then(() => done(), done);
|
||||
29
src/processor/http/report-github-failure.ts
Normal file
29
src/processor/http/report-github-failure.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import * as request from 'request';
|
||||
import User from '../../models/user';
|
||||
const createPost = require('../../server/api/endpoints/posts/create');
|
||||
|
||||
export default ({ data }, done) => {
|
||||
const asyncBot = User.findOne({ _id: data.userId });
|
||||
|
||||
// Fetch parent status
|
||||
request({
|
||||
url: `${data.parentUrl}/statuses`,
|
||||
headers: {
|
||||
'User-Agent': 'misskey'
|
||||
}
|
||||
}, async (err, res, body) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
return;
|
||||
}
|
||||
const parentStatuses = JSON.parse(body);
|
||||
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);
|
||||
done();
|
||||
});
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue