Merge branch 'develop' of https://github.com/syuilo/misskey into develop

This commit is contained in:
syuilo 2019-03-11 09:59:14 +09:00
commit e3e08843f1
No known key found for this signature in database
GPG Key ID: BDC4C49D06AB9D69
8 changed files with 49 additions and 25 deletions

View File

@ -137,7 +137,7 @@ Please see the [Contribution Guide](./CONTRIBUTING.md).
<td><a href="https://www.patreon.com/user?u=16900731">Atsuko Tominaga</a></td>
</tr></table>
<table><tr>
<td><img src="https://c10.patreonusercontent.com/3/eyJ3IjoyMDB9/patreon-media/p/user/4389829/9f709180ac714651a70f74a82f3ffdb9/2?token-time=2145916800&token-hash=zcwFxb2zopzWwksKVU1YpfAEjsl4yKT02aQ6yiAFRiQ%3D" alt="natalie" width="100"></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJ3IjoyMDB9/patreon-media/p/user/4389829/9f709180ac714651a70f74a82f3ffdb9/3?token-time=2145916800&token-hash=-iJszBqgYBhsM5qMdA1knf9wvprhEfESzKfR2oh7mIA%3D" alt="natalie" width="100"></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJ3IjoyMDB9/patreon-media/p/user/13034746/c711c7f58e204ecfbc2fd646bc8a4eee/1?token-time=2145916800&token-hash=5T8XcaAf9Zyzfg3QubR06s_kJZkArVEM2dwObrBVAU4%3D" alt="Hiratake" width="100"></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJ3IjoyMDB9/patreon-media/p/user/18072312/98e894d960314fa7bc236a72a39488fe/1?token-time=2145916800&token-hash=D6QK3fPyqiYKJfOzc-QqaSSairUrWdjld-ewp2waj6s%3D" alt="@Hekovic@gyutte.site" width="100"></td>
<td><img src="https://c10.patreonusercontent.com/3/eyJ3IjoyMDB9/patreon-media/p/user/4503830/ccf2cc867ea64de0b524bb2e24b9a1cb/1?token-time=2145916800&token-hash=Ksk_2l3gjPDbnzMUOCSW1E-hdPJsNs2tSR4_RAakRK8%3D" alt="dansup" width="100"></td>
@ -154,7 +154,7 @@ Please see the [Contribution Guide](./CONTRIBUTING.md).
<td><a href="https://www.patreon.com/user?u=12531784">Takashi Shibuya</a></td>
</tr></table>
**Last updated:** Thu, 07 Mar 2019 11:30:05 UTC
**Last updated:** Sun, 10 Mar 2019 22:17:05 UTC
<!-- PATREON_END -->
:four_leaf_clover: Copyright

View File

@ -29,7 +29,19 @@ export default async function(resolver: Resolver, actor: IRemoteUser, activity:
return;
}
const renote = await resolveNote(note);
// Announce対象をresolve
let renote;
try {
renote = await resolveNote(note);
} catch (e) {
// 対象が4xxならスキップ
if (e.statusCode >= 400 && e.statusCode < 500) {
logger.warn(`Ignored announce target ${note.inReplyTo} - ${e.statusCode}`);
return;
}
logger.warn(`Error in announce target ${note.inReplyTo} - ${e.statusCode || e}`);
throw e;
}
logger.info(`Creating the (Re)Note: ${uri}`);

View File

@ -27,7 +27,17 @@ export async function createImage(actor: IRemoteUser, value: any): Promise<IDriv
const instance = await fetchMeta();
const cache = instance.cacheRemoteFiles;
let file = await uploadFromUrl(image.url, actor, null, image.url, image.sensitive, false, !cache);
let file;
try {
file = await uploadFromUrl(image.url, actor, null, image.url, image.sensitive, false, !cache);
} catch (e) {
// 4xxの場合は添付されてなかったことにする
if (e >= 400 && e < 500) {
logger.warn(`Ignored image: ${image.url} - ${e}`);
return null;
}
throw e;
}
if (file.metadata.isRemote) {
// URLが異なっている場合、同じ画像が以前に異なるURLで登録されていたということなので、

View File

@ -111,11 +111,22 @@ export async function createNote(value: any, resolver?: Resolver, silent = false
note.attachment = Array.isArray(note.attachment) ? note.attachment : note.attachment ? [note.attachment] : [];
const files = note.attachment
.map(attach => attach.sensitive = note.sensitive)
? await Promise.all(note.attachment.map(x => limit(() => resolveImage(actor, x)) as Promise<IDriveFile>))
? (await Promise.all(note.attachment.map(x => limit(() => resolveImage(actor, x)) as Promise<IDriveFile>)))
.filter(image => image != null)
: [];
// リプライ
const reply = note.inReplyTo ? await resolveNote(note.inReplyTo, resolver) : null;
const reply = note.inReplyTo
? await resolveNote(note.inReplyTo, resolver).catch(e => {
// 4xxの場合はリプライしてないことにする
if (e.statusCode >= 400 && e.statusCode < 500) {
logger.warn(`Ignored inReplyTo ${note.inReplyTo} - ${e.statusCode} `);
return null;
}
logger.warn(`Error in inReplyTo ${note.inReplyTo} - ${e.statusCode || e}`);
throw e;
})
: null;
// 引用
let quote: INote;

View File

@ -1,9 +1,6 @@
import * as request from 'request-promise-native';
import { IObject } from './type';
import config from '../../config';
import { apLogger } from './logger';
export const logger = apLogger.createSubLogger('resolver');
export default class Resolver {
private history: Set<string>;
@ -34,7 +31,6 @@ export default class Resolver {
}
default: {
logger.error(`unknown collection type: ${collection.type}`);
throw new Error(`unknown collection type: ${collection.type}`);
}
}
@ -44,7 +40,6 @@ export default class Resolver {
public async resolve(value: any): Promise<IObject> {
if (value == null) {
logger.error('resolvee is null (or undefined)');
throw new Error('resolvee is null (or undefined)');
}
@ -53,7 +48,6 @@ export default class Resolver {
}
if (this.history.has(value)) {
logger.error(`cannot resolve already resolved one: ${value}`);
throw new Error('cannot resolve already resolved one');
}
@ -68,12 +62,6 @@ export default class Resolver {
Accept: 'application/activity+json, application/ld+json'
},
json: true
}).catch(e => {
logger.error(`request error: ${value}: ${e.message}`, {
url: value,
e: e
});
throw new Error(`request error: ${e.message}`);
});
if (object === null || (
@ -81,10 +69,6 @@ export default class Resolver {
!object['@context'].includes('https://www.w3.org/ns/activitystreams') :
object['@context'] !== 'https://www.w3.org/ns/activitystreams'
)) {
logger.error(`invalid response: ${value}`, {
url: value,
object: object
});
throw new Error('invalid response');
}

View File

@ -6,7 +6,7 @@ import * as request from 'request';
import fileType from 'file-type';
import { serverLogger } from '..';
import config from '../../config';
import { IImage, ConvertToPng } from '../../services/drive/image-processor';
import { IImage, ConvertToPng, ConvertToJpeg } from '../../services/drive/image-processor';
import checkSvg from '../../misc/check-svg';
export async function proxyMedia(ctx: Koa.BaseContext) {
@ -29,6 +29,8 @@ export async function proxyMedia(ctx: Koa.BaseContext) {
if ('static' in ctx.query && ['image/png', 'image/gif'].includes(type)) {
image = await ConvertToPng(path, 498, 280);
} else if ('preview' in ctx.query && ['image/jpeg', 'image/png', 'image/gif'].includes(type)) {
image = await ConvertToJpeg(path, 200, 200);
} else {
image = {
data: fs.readFileSync(path),

View File

@ -3,6 +3,8 @@ import * as request from 'request-promise-native';
import summaly from 'summaly';
import fetchMeta from '../../misc/fetch-meta';
import Logger from '../../services/logger';
import config from '../../config';
import { query } from '../../prelude/url';
const logger = new Logger('url-preview');
@ -44,7 +46,10 @@ module.exports = async (ctx: Koa.BaseContext) => {
function wrap(url: string): string {
return url != null
? url.match(/^https?:\/\//)
? `https://images.weserv.nl/?url=${encodeURIComponent(url.replace(/^http:\/\//, '').replace(/^https:\/\//, 'ssl:'))}&w=200&h=200`
? `${config.url}/proxy/preview.jpg?${query({
url,
preview: '1'
})}`
: url
: null;
}

View File

@ -42,7 +42,7 @@ export default async (
const writable = fs.createWriteStream(path);
writable.on('finish', () => {
logger.succ(`Download succeeded: ${chalk.cyan(url)}`);
logger.succ(`Download finished: ${chalk.cyan(url)}`);
res();
});