Merge remote-branch 'misskey/develop'

This commit is contained in:
NoriDev 2023-08-08 16:08:53 +09:00
commit 8fb121e3e5
8 changed files with 152 additions and 60 deletions

View file

@ -25,9 +25,13 @@
- Enhance: 自分が押したリアクションのデザインを改善
- Fix: サーバー情報画面(`/instance-info/{domain}`)でブロックができないのを修正
- Fix: 未読のお知らせの「わかった」をクリック・タップしてもその場で「わかった」が消えない問題を修正
- Fix: iOSで画面を回転させるとテキストサイズが変わる問題を修正
### Server
- cacheRemoteFilesの初期値はfalseになりました
- 一部のfeatured noteを照会できない問題を修正
- ファイルアップロード時等にファイル名の拡張子を修正する関数(correctFilename)の挙動を改善
- fix: muteがapiからのuser list timeline取得で機能しない問題を修正
## 13.14.2

View file

@ -138,13 +138,13 @@ export class ApNoteService {
this.logger.debug(`Note fetched: ${JSON.stringify(note, null, 2)}`);
if (note.id && !checkHttps(note.id)) {
throw new Error('unexpected shcema of note.id: ' + note.id);
throw new Error('unexpected schema of note.id: ' + note.id);
}
const url = getOneApHrefNullable(note.url);
if (url && !checkHttps(url)) {
throw new Error('unexpected shcema of note url: ' + url);
throw new Error('unexpected schema of note url: ' + url);
}
this.logger.info(`Creating the Note: ${note.id}`);
@ -299,26 +299,38 @@ export class ApNoteService {
}
}
return await this.noteCreateService.create(actor, {
createdAt: note.published ? new Date(note.published) : null,
files,
reply,
renote: quote,
name: note.name,
cw,
text,
localOnly: false,
disableRightClick: false,
visibility,
visibleUsers,
apMentions,
apHashtags,
apEmojis,
poll,
event,
uri: note.id,
url: url,
}, silent);
try {
return await this.noteCreateService.create(actor, {
createdAt: note.published ? new Date(note.published) : null,
files,
reply,
renote: quote,
name: note.name,
cw,
text,
localOnly: false,
disableRightClick: false,
visibility,
visibleUsers,
apMentions,
apHashtags,
apEmojis,
poll,
event,
uri: note.id,
url: url,
}, silent);
} catch (err: any) {
if (err.name !== 'duplicated') {
throw err;
}
this.logger.info('The note is already inserted while creating itself, reading again');
const duplicate = await this.fetchNote(value);
if (!duplicate) {
throw new Error('The note creation failed with duplication error even when there is no duplication');
}
return duplicate;
}
}
/**

View file

@ -3,18 +3,54 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
// 与えられた拡張子とファイル名が一致しているかどうかを確認し、
// 一致していない場合は拡張子を付与して返す
/**
* Array.includes()Set.has()
*/
const targetExtsToSkip = new Set([
'.gz',
'.tar',
'.tgz',
'.bz2',
'.xz',
'.zip',
'.7z',
]);
const extRegExp = /\.[0-9a-zA-Z]+$/i;
/**
*
*
*
* extはfile-typeのextを想定
*/
export function correctFilename(filename: string, ext: string | null) {
const dotExt = ext ? ext.startsWith('.') ? ext : `.${ext}` : '.unknown';
if (filename.endsWith(dotExt)) {
return filename;
}
if (ext === 'jpg' && filename.endsWith('.jpeg')) {
return filename;
}
if (ext === 'tif' && filename.endsWith('.tiff')) {
const dotExt = ext ? ext[0] === '.' ? ext : `.${ext}` : '.unknown';
const match = extRegExp.exec(filename);
if (!match || !match[0]) {
// filenameが拡張子を持っていない場合は拡張子をつける
return `${filename}${dotExt}`;
}
const filenameExt = match[0].toLowerCase();
if (
// 未知のファイル形式かつ拡張子がある場合は何もしない
ext === null ||
// 拡張子が一致している場合は何もしない
filenameExt === dotExt ||
// jpeg, tiffを同一視
dotExt === '.jpg' && filenameExt === '.jpeg' ||
dotExt === '.tif' && filenameExt === '.tiff' ||
// 圧縮形式っぽければ下手に拡張子を変えない
// https://github.com/misskey-dev/misskey/issues/11482
targetExtsToSkip.has(dotExt)
) {
return filename;
}
// 拡張子があるが一致していないなどの場合は拡張子を付け足す
return `${filename}${dotExt}`;
}

View file

@ -96,6 +96,10 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.andWhere('userListJoining.userListId = :userListId', { userListId: list.id });
this.queryService.generateVisibilityQuery(query, me);
this.queryService.generateMutedUserQuery(query, me);
this.queryService.generateMutedNoteQuery(query, me);
this.queryService.generateBlockedUserQuery(query, me);
this.queryService.generateMutedUserRenotesQueryForNotes(query, me);
if (ps.includeMyRenotes === false) {
query.andWhere(new Brackets(qb => {

View file

@ -259,6 +259,21 @@ describe('ActivityPub', () => {
assert.strictEqual(note.text, 'test test foo');
assert.strictEqual(note.uri, actor2Note.id);
});
test('Fetch a note that is a featured note of the attributed actor', async () => {
const actor = createRandomActor();
actor.featured = `${actor.id}/collections/featured`;
const featured = createRandomFeaturedCollection(actor, 5);
const firstNote = (featured.items as NonTransientIPost[])[0];
resolver.register(actor.id, actor);
resolver.register(actor.featured, featured);
resolver.register(firstNote.id, firstNote);
const note = await noteService.createNote(firstNote.id as string, resolver);
assert.strictEqual(note?.uri, firstNote.id);
});
});
describe('Images', () => {

View file

@ -0,0 +1,48 @@
/*
* SPDX-FileCopyrightText: syuilo and other misskey contributors
* SPDX-License-Identifier: AGPL-3.0-only
*/
import { correctFilename } from '@/misc/correct-filename.js';
describe(correctFilename, () => {
it('no ext to null', () => {
expect(correctFilename('test', null)).toBe('test.unknown');
});
it('no ext to jpg', () => {
expect(correctFilename('test', 'jpg')).toBe('test.jpg');
});
it('jpg to webp', () => {
expect(correctFilename('test.jpg', 'webp')).toBe('test.jpg.webp');
});
it('jpg to .webp', () => {
expect(correctFilename('test.jpg', '.webp')).toBe('test.jpg.webp');
});
it('jpeg to jpg', () => {
expect(correctFilename('test.jpeg', 'jpg')).toBe('test.jpeg');
});
it('JPEG to jpg', () => {
expect(correctFilename('test.JPEG', 'jpg')).toBe('test.JPEG');
});
it('jpg to jpg', () => {
expect(correctFilename('test.jpg', 'jpg')).toBe('test.jpg');
});
it('JPG to jpg', () => {
expect(correctFilename('test.JPG', 'jpg')).toBe('test.JPG');
});
it('tiff to tif', () => {
expect(correctFilename('test.tiff', 'tif')).toBe('test.tiff');
});
it('skip gz', () => {
expect(correctFilename('test.unitypackage', 'gz')).toBe('test.unitypackage');
});
it('skip text file', () => {
expect(correctFilename('test.txt', null)).toBe('test.txt');
});
it('unknown', () => {
expect(correctFilename('test.hoge', null)).toBe('test.hoge');
});
test('non ascii with space', () => {
expect(correctFilename('ファイル 名前', 'jpg')).toBe('ファイル 名前.jpg');
});
});

View file

@ -5,7 +5,6 @@
import { describe, test, expect } from '@jest/globals';
import { contentDisposition } from '@/misc/content-disposition.js';
import { correctFilename } from '@/misc/correct-filename.js';
describe('misc:content-disposition', () => {
test('inline', () => {
@ -18,30 +17,3 @@ describe('misc:content-disposition', () => {
expect(contentDisposition('attachment', 'ファイル名')).toBe('attachment; filename=\"_____\"; filename*=UTF-8\'\'%E3%83%95%E3%82%A1%E3%82%A4%E3%83%AB%E5%90%8D');
});
});
describe('misc:correct-filename', () => {
test('simple', () => {
expect(correctFilename('filename', 'jpg')).toBe('filename.jpg');
});
test('with same ext', () => {
expect(correctFilename('filename.jpg', 'jpg')).toBe('filename.jpg');
});
test('.ext', () => {
expect(correctFilename('filename.jpg', '.jpg')).toBe('filename.jpg');
});
test('with different ext', () => {
expect(correctFilename('filename.webp', 'jpg')).toBe('filename.webp.jpg');
});
test('non ascii with space', () => {
expect(correctFilename('ファイル 名前', 'jpg')).toBe('ファイル 名前.jpg');
});
test('jpeg', () => {
expect(correctFilename('filename.jpeg', 'jpg')).toBe('filename.jpeg');
});
test('tiff', () => {
expect(correctFilename('filename.tiff', 'tif')).toBe('filename.tiff');
});
test('null ext', () => {
expect(correctFilename('filename', null)).toBe('filename.unknown');
});
});

View file

@ -90,6 +90,7 @@ html {
line-height: 1.35;
text-size-adjust: 100%;
tab-size: 2;
-webkit-text-size-adjust: 100%;
&, * {
scrollbar-color: var(--scrollbarHandle) transparent;