Fix job processor interfaces

This commit is contained in:
Akihiko Odaki 2018-04-03 02:09:50 +09:00
parent 45fb451111
commit 63906af5ab
4 changed files with 19 additions and 25 deletions

View File

@ -11,7 +11,7 @@ import context from '../../remote/activitypub/renderer/context';
import render from '../../remote/activitypub/renderer/follow'; import render from '../../remote/activitypub/renderer/follow';
import config from '../../config'; import config from '../../config';
export default ({ data }, done) => Following.findOne({ _id: data.following }).then(({ followerId, followeeId }) => { export default ({ data }) => Following.findOne({ _id: data.following }).then(({ followerId, followeeId }) => {
const promisedFollower = User.findOne({ _id: followerId }); const promisedFollower = User.findOne({ _id: followerId });
const promisedFollowee = User.findOne({ _id: followeeId }); const promisedFollowee = User.findOne({ _id: followeeId });
@ -104,4 +104,4 @@ export default ({ data }, done) => Following.findOne({ _id: data.following }).th
return Promise.all([followerEvent, followeeEvent]); return Promise.all([followerEvent, followeeEvent]);
}) })
]); ]);
}).then(done, done); });

View File

@ -1,6 +1,5 @@
import User from '../../models/user'; import User from '../../models/user';
import act from '../../remote/activitypub/act'; import act from '../../remote/activitypub/act';
export default ({ data }, done) => User.findOne({ _id: data.actor }) export default ({ data }) => User.findOne({ _id: data.actor })
.then(actor => act(actor, data.outbox, false)) .then(actor => act(actor, data.outbox, false));
.then(() => done(), done);

View File

@ -4,7 +4,7 @@ import User, { IRemoteUser } from '../../models/user';
import act from '../../remote/activitypub/act'; import act from '../../remote/activitypub/act';
import resolvePerson from '../../remote/activitypub/resolve-person'; import resolvePerson from '../../remote/activitypub/resolve-person';
export default ({ data }, done) => (async () => { export default async ({ data }) => {
const keyIdLower = data.signature.keyId.toLowerCase(); const keyIdLower = data.signature.keyId.toLowerCase();
let user; let user;
@ -35,4 +35,4 @@ export default ({ data }, done) => (async () => {
} }
await act(user, data.inbox, true); await act(user, data.inbox, true);
})().then(done, done); };

View File

@ -1,22 +1,19 @@
import * as request from 'request'; import * as request from 'request-promise-native';
import User from '../../models/user'; import User from '../../models/user';
const createPost = require('../../server/api/endpoints/posts/create'); const createPost = require('../../server/api/endpoints/posts/create');
export default ({ data }, done) => { export default async ({ data }) => {
const asyncBot = User.findOne({ _id: data.userId }); const asyncBot = User.findOne({ _id: data.userId });
// Fetch parent status // Fetch parent status
request({ const parentStatuses = await request({
url: `${data.parentUrl}/statuses`, url: `${data.parentUrl}/statuses`,
headers: { headers: {
'User-Agent': 'misskey' 'User-Agent': 'misskey'
} },
}, async (err, res, body) => { json: true
if (err) { });
console.error(err);
return;
}
const parentStatuses = JSON.parse(body);
const parentState = parentStatuses[0].state; const parentState = parentStatuses[0].state;
const stillFailed = parentState == 'failure' || parentState == 'error'; const stillFailed = parentState == 'failure' || parentState == 'error';
const text = stillFailed ? const text = stillFailed ?
@ -24,6 +21,4 @@ export default ({ data }, done) => {
`**🚨BUILD FAILED🚨**: →→→?[${data.message}](${data.htmlUrl})←←←`; `**🚨BUILD FAILED🚨**: →→→?[${data.message}](${data.htmlUrl})←←←`;
createPost({ text }, await asyncBot); createPost({ text }, await asyncBot);
done();
});
}; };