mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-26 22:29:28 +09:00
wip
This commit is contained in:
parent
06347cd71e
commit
7403f38fb4
@ -18,20 +18,21 @@ import html from '../../text/html';
|
|||||||
import { IApp } from '../../models/app';
|
import { IApp } from '../../models/app';
|
||||||
|
|
||||||
export default async (user: IUser, content: {
|
export default async (user: IUser, content: {
|
||||||
createdAt: Date;
|
createdAt?: Date;
|
||||||
text: string;
|
text?: string;
|
||||||
reply: IPost;
|
reply?: IPost;
|
||||||
repost: IPost;
|
repost?: IPost;
|
||||||
media: IDriveFile[];
|
media?: IDriveFile[];
|
||||||
geo: any;
|
geo?: any;
|
||||||
poll?: any;
|
poll?: any;
|
||||||
viaMobile: boolean;
|
viaMobile?: boolean;
|
||||||
tags?: string[];
|
tags?: string[];
|
||||||
cw?: string;
|
cw?: string;
|
||||||
visibility?: string;
|
visibility?: string;
|
||||||
uri?: string;
|
uri?: string;
|
||||||
app?: IApp;
|
app?: IApp;
|
||||||
}) => new Promise<IPost>(async (res, rej) => {
|
}) => new Promise<IPost>(async (res, rej) => {
|
||||||
|
if (content.createdAt == null) content.createdAt = new Date();
|
||||||
if (content.visibility == null) content.visibility = 'public';
|
if (content.visibility == null) content.visibility = 'public';
|
||||||
|
|
||||||
const tags = content.tags || [];
|
const tags = content.tags || [];
|
||||||
|
@ -103,7 +103,7 @@ async function workerMain(opt) {
|
|||||||
|
|
||||||
if (!opt['only-server']) {
|
if (!opt['only-server']) {
|
||||||
// start processor
|
// start processor
|
||||||
require('./processor').default();
|
require('./queue').default();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send a 'ready' message to parent process
|
// Send a 'ready' message to parent process
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
import { createQueue } from 'kue';
|
import { createQueue } from 'kue';
|
||||||
|
import * as debug from 'debug';
|
||||||
|
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
import db from './processors/db';
|
import db from './processors/db';
|
||||||
import http from './processors/http';
|
import http from './processors/http';
|
||||||
|
|
||||||
|
const log = debug('misskey:queue');
|
||||||
|
|
||||||
const queue = createQueue({
|
const queue = createQueue({
|
||||||
redis: {
|
redis: {
|
||||||
port: config.redis.port,
|
port: config.redis.port,
|
||||||
@ -12,6 +16,8 @@ const queue = createQueue({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export function createHttp(data) {
|
export function createHttp(data) {
|
||||||
|
log(`HTTP job created: ${JSON.stringify(data)}`);
|
||||||
|
|
||||||
return queue
|
return queue
|
||||||
.create('http', data)
|
.create('http', data)
|
||||||
.attempts(16)
|
.attempts(16)
|
||||||
@ -22,7 +28,7 @@ export function createDb(data) {
|
|||||||
return queue.create('db', data);
|
return queue.create('db', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function process() {
|
export default function() {
|
||||||
queue.process('db', db);
|
queue.process('db', db);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3,5 +3,12 @@ import * as kue from 'kue';
|
|||||||
import request from '../../../remote/request';
|
import request from '../../../remote/request';
|
||||||
|
|
||||||
export default async (job: kue.Job, done): Promise<void> => {
|
export default async (job: kue.Job, done): Promise<void> => {
|
||||||
|
try {
|
||||||
await request(job.data.user, job.data.to, job.data.content);
|
await request(job.data.user, job.data.to, job.data.content);
|
||||||
|
done();
|
||||||
|
} catch (e) {
|
||||||
|
console.warn(`deliver failed: ${e}`);
|
||||||
|
|
||||||
|
done(e);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -5,7 +5,15 @@ import reportGitHubFailure from './report-github-failure';
|
|||||||
const handlers = {
|
const handlers = {
|
||||||
deliver,
|
deliver,
|
||||||
processInbox,
|
processInbox,
|
||||||
reportGitHubFailure,
|
reportGitHubFailure
|
||||||
};
|
};
|
||||||
|
|
||||||
export default (job, done) => handlers[job.data.type](job).then(() => done(), done);
|
export default (job, done) => {
|
||||||
|
const handler = handlers[job.data.type];
|
||||||
|
|
||||||
|
if (handler) {
|
||||||
|
handler(job).then(() => done(), done);
|
||||||
|
} else {
|
||||||
|
console.warn(`Unknown job: ${job.data.type}`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import * as request from 'request-promise-native';
|
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');
|
import createPost from '../../../api/post/create';
|
||||||
|
|
||||||
export default async ({ data }) => {
|
export default async ({ data }) => {
|
||||||
const asyncBot = User.findOne({ _id: data.userId });
|
const asyncBot = User.findOne({ _id: data.userId });
|
||||||
@ -20,5 +20,5 @@ export default async ({ data }) => {
|
|||||||
`**⚠️BUILD STILL FAILED⚠️**: ?[${data.message}](${data.htmlUrl})` :
|
`**⚠️BUILD STILL FAILED⚠️**: ?[${data.message}](${data.htmlUrl})` :
|
||||||
`**🚨BUILD FAILED🚨**: →→→?[${data.message}](${data.htmlUrl})←←←`;
|
`**🚨BUILD FAILED🚨**: →→→?[${data.message}](${data.htmlUrl})←←←`;
|
||||||
|
|
||||||
createPost({ text }, await asyncBot);
|
createPost(await asyncBot, { text });
|
||||||
};
|
};
|
||||||
|
@ -59,7 +59,7 @@ export default class Resolver {
|
|||||||
throw new Error('invalid response');
|
throw new Error('invalid response');
|
||||||
}
|
}
|
||||||
|
|
||||||
log(`resolved: ${JSON.stringify(object)}`);
|
log(`resolved: ${JSON.stringify(object, null, 2)}`);
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
import { request } from 'https';
|
import { request } from 'https';
|
||||||
import { sign } from 'http-signature';
|
import { sign } from 'http-signature';
|
||||||
import { URL } from 'url';
|
import { URL } from 'url';
|
||||||
|
import * as debug from 'debug';
|
||||||
|
|
||||||
import config from '../config';
|
import config from '../config';
|
||||||
|
|
||||||
|
const log = debug('misskey:activitypub:deliver');
|
||||||
|
|
||||||
export default ({ account, username }, url, object) => new Promise((resolve, reject) => {
|
export default ({ account, username }, url, object) => new Promise((resolve, reject) => {
|
||||||
|
log(`--> ${url}`);
|
||||||
|
|
||||||
const { protocol, hostname, port, pathname, search } = new URL(url);
|
const { protocol, hostname, port, pathname, search } = new URL(url);
|
||||||
|
|
||||||
const req = request({
|
const req = request({
|
||||||
@ -14,6 +20,8 @@ export default ({ account, username }, url, object) => new Promise((resolve, rej
|
|||||||
path: pathname + search,
|
path: pathname + search,
|
||||||
}, res => {
|
}, res => {
|
||||||
res.on('end', () => {
|
res.on('end', () => {
|
||||||
|
log(`${url} --> ${res.statusCode}`);
|
||||||
|
|
||||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
resolve();
|
resolve();
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
import $ from 'cafy';
|
import $ from 'cafy';
|
||||||
import User from '../../../../models/user';
|
import User from '../../../../models/user';
|
||||||
import Following from '../../../../models/following';
|
import Following from '../../../../models/following';
|
||||||
import queue from '../../../../queue';
|
import create from '../../../../api/following/create';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Follow a user
|
* Follow a user
|
||||||
@ -50,15 +50,8 @@ module.exports = (params, user) => new Promise(async (res, rej) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create following
|
// Create following
|
||||||
const { _id } = await Following.insert({
|
create(follower, followee);
|
||||||
createdAt: new Date(),
|
|
||||||
followerId: follower._id,
|
|
||||||
followeeId: followee._id
|
|
||||||
});
|
|
||||||
|
|
||||||
queue.create('http', { type: 'follow', following: _id }).save();
|
|
||||||
|
|
||||||
// Send response
|
// Send response
|
||||||
res();
|
res();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user