Merge tag '13.14.2' into io

This commit is contained in:
まっちゃとーにゅ
2023-07-27 18:21:05 +09:00
46 changed files with 2221 additions and 326 deletions

View File

@@ -28,6 +28,7 @@
"@swc/core-android-arm64": "1.3.11",
"@swc/core-darwin-arm64": "1.3.56",
"@swc/core-darwin-x64": "1.3.56",
"@swc/core-freebsd-x64": "1.3.11",
"@swc/core-linux-arm-gnueabihf": "1.3.56",
"@swc/core-linux-arm64-gnu": "1.3.56",
"@swc/core-linux-arm64-musl": "1.3.56",
@@ -39,18 +40,19 @@
"@tensorflow/tfjs": "4.4.0",
"@tensorflow/tfjs-node": "4.4.0",
"bufferutil": "^4.0.7",
"slacc-android-arm-eabi": "0.0.9",
"slacc-android-arm64": "0.0.9",
"slacc-darwin-arm64": "0.0.9",
"slacc-darwin-universal": "0.0.9",
"slacc-darwin-x64": "0.0.9",
"slacc-freebsd-x64": "0.0.9",
"slacc-linux-arm-gnueabihf": "0.0.9",
"slacc-linux-arm64-gnu": "0.0.9",
"slacc-linux-arm64-musl": "0.0.9",
"slacc-linux-x64-gnu": "0.0.9",
"slacc-win32-arm64-msvc": "0.0.9",
"slacc-win32-x64-msvc": "0.0.9",
"slacc-android-arm-eabi": "0.0.10",
"slacc-android-arm64": "0.0.10",
"slacc-darwin-arm64": "0.0.10",
"slacc-darwin-universal": "0.0.10",
"slacc-darwin-x64": "0.0.10",
"slacc-freebsd-x64": "0.0.10",
"slacc-linux-arm-gnueabihf": "0.0.10",
"slacc-linux-arm64-gnu": "0.0.10",
"slacc-linux-arm64-musl": "0.0.10",
"slacc-linux-x64-gnu": "0.0.10",
"slacc-linux-x64-musl": "0.0.10",
"slacc-win32-arm64-msvc": "0.0.10",
"slacc-win32-x64-msvc": "0.0.10",
"utf-8-validate": "^6.0.3"
},
"dependencies": {
@@ -141,7 +143,7 @@
"semver": "7.5.4",
"sharp": "0.32.3",
"sharp-read-bmp": "github:misskey-dev/sharp-read-bmp",
"slacc": "0.0.9",
"slacc": "0.0.10",
"strict-event-emitter-types": "2.0.0",
"stringz": "2.1.0",
"summaly": "github:misskey-dev/summaly",

View File

@@ -1,6 +1,5 @@
import * as fs from 'node:fs';
import * as stream from 'node:stream';
import * as util from 'node:util';
import * as stream from 'node:stream/promises';
import { Inject, Injectable } from '@nestjs/common';
import ipaddr from 'ipaddr.js';
import chalk from 'chalk';
@@ -14,7 +13,6 @@ import { StatusError } from '@/misc/status-error.js';
import { LoggerService } from '@/core/LoggerService.js';
import type Logger from '@/logger.js';
const pipeline = util.promisify(stream.pipeline);
import { bindThis } from '@/decorators.js';
@Injectable()
@@ -102,7 +100,7 @@ export class DownloadService {
});
try {
await pipeline(req, fs.createWriteStream(path));
await stream.pipeline(req, fs.createWriteStream(path));
} catch (e) {
if (e instanceof Got.HTTPError) {
throw new StatusError(`${e.response.statusCode} ${e.response.statusMessage}`, e.response.statusCode, e.response.statusMessage);
@@ -129,7 +127,7 @@ export class DownloadService {
// write content at URL to temp file
await this.downloadUrl(url, path);
const text = await util.promisify(fs.readFile)(path, 'utf8');
const text = await fs.promises.readFile(path, 'utf8');
return text;
} finally {

View File

@@ -1,8 +1,7 @@
import * as fs from 'node:fs';
import * as crypto from 'node:crypto';
import { join } from 'node:path';
import * as stream from 'node:stream';
import * as util from 'node:util';
import * as stream from 'node:stream/promises';
import { Injectable } from '@nestjs/common';
import { FSWatcher } from 'chokidar';
import * as fileType from 'file-type';
@@ -16,8 +15,6 @@ import { createTempDir } from '@/misc/create-temp.js';
import { AiService } from '@/core/AiService.js';
import { bindThis } from '@/decorators.js';
const pipeline = util.promisify(stream.pipeline);
export type FileInfo = {
size: number;
md5: string;
@@ -371,8 +368,7 @@ export class FileInfoService {
*/
@bindThis
public async getFileSize(path: string): Promise<number> {
const getStat = util.promisify(fs.stat);
return (await getStat(path)).size;
return (await fs.promises.stat(path)).size;
}
/**
@@ -381,7 +377,7 @@ export class FileInfoService {
@bindThis
private async calcHash(path: string): Promise<string> {
const hash = crypto.createHash('md5').setEncoding('hex');
await pipeline(fs.createReadStream(path), hash);
await stream.pipeline(fs.createReadStream(path), hash);
return hash.read();
}

View File

@@ -1,7 +1,6 @@
import { randomUUID } from 'node:crypto';
import { pipeline } from 'node:stream';
import * as fs from 'node:fs';
import { promisify } from 'node:util';
import * as stream from 'node:stream/promises';
import { Inject, Injectable } from '@nestjs/common';
import { DI } from '@/di-symbols.js';
import { getIpHash } from '@/misc/get-ip-hash.js';
@@ -21,8 +20,6 @@ import type { FastifyRequest, FastifyReply } from 'fastify';
import type { OnApplicationShutdown } from '@nestjs/common';
import type { IEndpointMeta, IEndpoint } from './endpoints.js';
const pump = promisify(pipeline);
const accessDenied = {
message: 'Access denied.',
code: 'ACCESS_DENIED',
@@ -138,7 +135,7 @@ export class ApiCallService implements OnApplicationShutdown {
}
const [path] = await createTemp();
await pump(multipartData.file, fs.createWriteStream(path));
await stream.pipeline(multipartData.file, fs.createWriteStream(path));
const fields = {} as Record<string, unknown>;
for (const [k, v] of Object.entries(multipartData.fields)) {

View File

@@ -60,7 +60,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
}
query.limit(ps.limit);
query.skip(ps.offset);
query.offset(ps.offset);
const tickets = await query.getMany();

View File

@@ -105,7 +105,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
}
query.limit(ps.limit);
query.skip(ps.offset);
query.offset(ps.offset);
const users = await query.getMany();

View File

@@ -126,7 +126,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
query.andWhere('instance.host like :host', { host: '%' + sqlLikeEscape(ps.host.toLowerCase()) + '%' });
}
const instances = await query.limit(ps.limit).skip(ps.offset).getMany();
const instances = await query.limit(ps.limit).offset(ps.offset).getMany();
return await this.instanceEntityService.packMany(instances);
});

View File

@@ -42,7 +42,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.orderBy('tag.count', 'DESC')
.groupBy('tag.id')
.limit(ps.limit)
.skip(ps.offset)
.offset(ps.offset)
.getMany();
return hashtags.map(tag => tag.name);

View File

@@ -83,7 +83,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
const polls = await query
.orderBy('poll.noteId', 'DESC')
.limit(ps.limit)
.skip(ps.offset)
.offset(ps.offset)
.getMany();
if (polls.length === 0) return [];

View File

@@ -81,7 +81,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
if (me) this.queryService.generateBlockQueryForUsers(query, me);
query.limit(ps.limit);
query.skip(ps.offset);
query.offset(ps.offset);
const users = await query.getMany();

View File

@@ -70,7 +70,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
query.setParameters(followingQuery.getParameters());
const users = await query.limit(ps.limit).skip(ps.offset).getMany();
const users = await query.limit(ps.limit).offset(ps.offset).getMany();
return await this.userEntityService.packMany(users, me, { detail: true });
});

View File

@@ -75,7 +75,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
users = await usernameQuery
.orderBy('user.updatedAt', 'DESC', 'NULLS LAST')
.limit(ps.limit)
.skip(ps.offset)
.offset(ps.offset)
.getMany();
} else {
const nameQuery = this.usersRepository.createQueryBuilder('user')
@@ -102,7 +102,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
users = await nameQuery
.orderBy('user.updatedAt', 'DESC', 'NULLS LAST')
.limit(ps.limit)
.skip(ps.offset)
.offset(ps.offset)
.getMany();
if (users.length < ps.limit) {
@@ -128,7 +128,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
users = users.concat(await query
.orderBy('user.updatedAt', 'DESC', 'NULLS LAST')
.limit(ps.limit)
.skip(ps.offset)
.offset(ps.offset)
.getMany(),
);
}

View File

@@ -16,8 +16,12 @@ block og
meta(property='og:title' content= title)
meta(property='og:description' content= post.description)
meta(property='og:url' content= url)
meta(property='og:image' content= post.files[0].thumbnailUrl)
meta(property='twitter:card' content='summary_large_image')
if post.isSensitive
meta(property='og:image' content= avatarUrl)
meta(property='twitter:card' content='summary')
else
meta(property='og:image' content= post.files[0].thumbnailUrl)
meta(property='twitter:card' content='summary_large_image')
block meta
if user.host || profile.noCrawle

View File

@@ -5,6 +5,7 @@ import { Note } from '@/models/entities/Note.js';
import { signup, post, uploadUrl, startServer, initTestDb, api, uploadFile } from '../utils.js';
import type { INestApplicationContext } from '@nestjs/common';
import type * as misskey from 'misskey-js';
import { MAX_NOTE_TEXT_LENGTH } from '@/const.js';
describe('Note', () => {
let app: INestApplicationContext;
@@ -164,7 +165,7 @@ describe('Note', () => {
test('文字数ぎりぎりで怒られない', async () => {
const post = {
text: '!'.repeat(3000),
text: '!'.repeat(MAX_NOTE_TEXT_LENGTH), // 3000文字
};
const res = await api('/notes/create', post, alice);
assert.strictEqual(res.status, 200);
@@ -172,7 +173,7 @@ describe('Note', () => {
test('文字数オーバーで怒られる', async () => {
const post = {
text: '!'.repeat(3001),
text: '!'.repeat(MAX_NOTE_TEXT_LENGTH + 1), // 3001文字
};
const res = await api('/notes/create', post, alice);
assert.strictEqual(res.status, 400);