Merge remote-tracking branch 'upstream/develop' into abuse-report-resolver
This commit is contained in:
commit
4ab8f1415c
|
@ -12,11 +12,17 @@
|
||||||
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
## 13.x.x (unreleased)
|
||||||
|
|
||||||
|
### Client
|
||||||
|
- Fix: サーバーメトリクスが90度傾いている
|
||||||
|
|
||||||
## 13.13.2
|
## 13.13.2
|
||||||
|
|
||||||
### General
|
### General
|
||||||
- エラー時や項目が存在しないときなどのアイコン画像をサーバー管理者が設定できるように
|
- エラー時や項目が存在しないときなどのアイコン画像をサーバー管理者が設定できるように
|
||||||
- ロールが付与されているユーザーリストを非公開にできるように
|
- ロールが付与されているユーザーリストを非公開にできるように
|
||||||
|
- サーバーの負荷が非常に高いため、ユーザー統計表示機能を削除しました
|
||||||
|
|
||||||
### Client
|
### Client
|
||||||
- Fix: タブがバックグラウンドでもstreamが切断されないように
|
- Fix: タブがバックグラウンドでもstreamが切断されないように
|
||||||
|
|
|
@ -56,11 +56,11 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/gulp": "4.0.10",
|
"@types/gulp": "4.0.10",
|
||||||
"@types/gulp-rename": "2.0.1",
|
"@types/gulp-rename": "2.0.1",
|
||||||
"@typescript-eslint/eslint-plugin": "5.59.8",
|
"@typescript-eslint/eslint-plugin": "5.60.0",
|
||||||
"@typescript-eslint/parser": "5.59.8",
|
"@typescript-eslint/parser": "5.60.0",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"cypress": "12.13.0",
|
"cypress": "12.15.0",
|
||||||
"eslint": "8.41.0",
|
"eslint": "8.43.0",
|
||||||
"start-server-and-test": "2.0.0"
|
"start-server-and-test": "2.0.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
|
|
|
@ -54,31 +54,31 @@
|
||||||
"@aws-sdk/client-s3": "3.321.1",
|
"@aws-sdk/client-s3": "3.321.1",
|
||||||
"@aws-sdk/lib-storage": "3.321.1",
|
"@aws-sdk/lib-storage": "3.321.1",
|
||||||
"@aws-sdk/node-http-handler": "3.321.1",
|
"@aws-sdk/node-http-handler": "3.321.1",
|
||||||
"@bull-board/api": "5.2.0",
|
"@bull-board/api": "5.5.3",
|
||||||
"@bull-board/fastify": "5.2.0",
|
"@bull-board/fastify": "5.5.3",
|
||||||
"@bull-board/ui": "5.2.0",
|
"@bull-board/ui": "5.5.3",
|
||||||
"@discordapp/twemoji": "14.1.2",
|
"@discordapp/twemoji": "14.1.2",
|
||||||
"@fastify/accepts": "4.1.0",
|
"@fastify/accepts": "4.2.0",
|
||||||
"@fastify/cookie": "8.3.0",
|
"@fastify/cookie": "8.3.0",
|
||||||
"@fastify/cors": "8.3.0",
|
"@fastify/cors": "8.3.0",
|
||||||
"@fastify/http-proxy": "9.1.0",
|
"@fastify/http-proxy": "9.2.1",
|
||||||
"@fastify/multipart": "7.6.0",
|
"@fastify/multipart": "7.7.0",
|
||||||
"@fastify/static": "6.10.2",
|
"@fastify/static": "6.10.2",
|
||||||
"@fastify/view": "7.4.1",
|
"@fastify/view": "7.4.1",
|
||||||
"@nestjs/common": "9.4.2",
|
"@nestjs/common": "10.0.3",
|
||||||
"@nestjs/core": "9.4.2",
|
"@nestjs/core": "10.0.3",
|
||||||
"@nestjs/testing": "9.4.2",
|
"@nestjs/testing": "10.0.3",
|
||||||
"@peertube/http-signature": "1.7.0",
|
"@peertube/http-signature": "1.7.0",
|
||||||
"@sinonjs/fake-timers": "10.2.0",
|
"@sinonjs/fake-timers": "10.3.0",
|
||||||
"@swc/cli": "0.1.62",
|
"@swc/cli": "0.1.62",
|
||||||
"@swc/core": "1.3.61",
|
"@swc/core": "1.3.66",
|
||||||
"accepts": "1.3.8",
|
"accepts": "1.3.8",
|
||||||
"ajv": "8.12.0",
|
"ajv": "8.12.0",
|
||||||
"archiver": "5.3.1",
|
"archiver": "5.3.1",
|
||||||
"autwh": "0.1.0",
|
"autwh": "0.1.0",
|
||||||
"bcryptjs": "2.4.3",
|
"bcryptjs": "2.4.3",
|
||||||
"blurhash": "2.0.5",
|
"blurhash": "2.0.5",
|
||||||
"bullmq": "3.15.0",
|
"bullmq": "4.1.0",
|
||||||
"cacheable-lookup": "6.1.0",
|
"cacheable-lookup": "6.1.0",
|
||||||
"cbor": "9.0.0",
|
"cbor": "9.0.0",
|
||||||
"chalk": "5.2.0",
|
"chalk": "5.2.0",
|
||||||
|
@ -90,9 +90,9 @@
|
||||||
"date-fns": "2.30.0",
|
"date-fns": "2.30.0",
|
||||||
"deep-email-validator": "0.1.21",
|
"deep-email-validator": "0.1.21",
|
||||||
"escape-regexp": "0.0.1",
|
"escape-regexp": "0.0.1",
|
||||||
"fastify": "4.17.0",
|
"fastify": "4.18.0",
|
||||||
"feed": "4.2.2",
|
"feed": "4.2.2",
|
||||||
"file-type": "18.4.0",
|
"file-type": "18.5.0",
|
||||||
"fluent-ffmpeg": "2.1.2",
|
"fluent-ffmpeg": "2.1.2",
|
||||||
"form-data": "4.0.0",
|
"form-data": "4.0.0",
|
||||||
"got": "12.6.0",
|
"got": "12.6.0",
|
||||||
|
@ -100,13 +100,14 @@
|
||||||
"hpagent": "1.2.0",
|
"hpagent": "1.2.0",
|
||||||
"ioredis": "5.3.2",
|
"ioredis": "5.3.2",
|
||||||
"ip-cidr": "3.1.0",
|
"ip-cidr": "3.1.0",
|
||||||
|
"ipaddr.js": "2.1.0",
|
||||||
"is-svg": "4.3.2",
|
"is-svg": "4.3.2",
|
||||||
"js-yaml": "4.1.0",
|
"js-yaml": "4.1.0",
|
||||||
"jsdom": "22.1.0",
|
"jsdom": "22.1.0",
|
||||||
"json5": "2.2.3",
|
"json5": "2.2.3",
|
||||||
"jsonld": "8.2.0",
|
"jsonld": "8.2.0",
|
||||||
"jsrsasign": "10.8.6",
|
"jsrsasign": "10.8.6",
|
||||||
"meilisearch": "0.32.5",
|
"meilisearch": "0.33.0",
|
||||||
"mfm-js": "0.23.3",
|
"mfm-js": "0.23.3",
|
||||||
"mime-types": "2.1.35",
|
"mime-types": "2.1.35",
|
||||||
"misskey-js": "workspace:*",
|
"misskey-js": "workspace:*",
|
||||||
|
@ -120,7 +121,6 @@
|
||||||
"otpauth": "9.1.2",
|
"otpauth": "9.1.2",
|
||||||
"parse5": "7.1.2",
|
"parse5": "7.1.2",
|
||||||
"pg": "8.11.0",
|
"pg": "8.11.0",
|
||||||
"private-ip": "3.0.0",
|
|
||||||
"probe-image-size": "7.2.3",
|
"probe-image-size": "7.2.3",
|
||||||
"promise-limit": "2.7.0",
|
"promise-limit": "2.7.0",
|
||||||
"pug": "3.0.2",
|
"pug": "3.0.2",
|
||||||
|
@ -129,36 +129,35 @@
|
||||||
"qrcode": "1.5.3",
|
"qrcode": "1.5.3",
|
||||||
"random-seed": "0.3.0",
|
"random-seed": "0.3.0",
|
||||||
"ratelimiter": "3.4.1",
|
"ratelimiter": "3.4.1",
|
||||||
"re2": "1.19.0",
|
"re2": "1.19.1",
|
||||||
"redis-lock": "0.1.4",
|
"redis-lock": "0.1.4",
|
||||||
"reflect-metadata": "0.1.13",
|
"reflect-metadata": "0.1.13",
|
||||||
"rename": "1.0.4",
|
"rename": "1.0.4",
|
||||||
"rndstr": "1.0.0",
|
|
||||||
"rss-parser": "3.13.0",
|
"rss-parser": "3.13.0",
|
||||||
"rxjs": "7.8.1",
|
"rxjs": "7.8.1",
|
||||||
"s-age": "1.1.2",
|
"s-age": "1.1.2",
|
||||||
"sanitize-html": "2.10.0",
|
"sanitize-html": "2.11.0",
|
||||||
"seedrandom": "3.0.5",
|
"seedrandom": "3.0.5",
|
||||||
"semver": "7.5.1",
|
"semver": "7.5.3",
|
||||||
"sharp": "0.32.1",
|
"sharp": "0.32.1",
|
||||||
"sharp-read-bmp": "github:misskey-dev/sharp-read-bmp",
|
"sharp-read-bmp": "github:misskey-dev/sharp-read-bmp",
|
||||||
"slacc": "0.0.9",
|
"slacc": "0.0.9",
|
||||||
"strict-event-emitter-types": "2.0.0",
|
"strict-event-emitter-types": "2.0.0",
|
||||||
"stringz": "2.1.0",
|
"stringz": "2.1.0",
|
||||||
"summaly": "github:misskey-dev/summaly",
|
"summaly": "github:misskey-dev/summaly",
|
||||||
"systeminformation": "5.17.16",
|
"systeminformation": "5.18.4",
|
||||||
"tinycolor2": "1.6.0",
|
"tinycolor2": "1.6.0",
|
||||||
"tmp": "0.2.1",
|
"tmp": "0.2.1",
|
||||||
"tsc-alias": "1.8.6",
|
"tsc-alias": "1.8.6",
|
||||||
"tsconfig-paths": "4.2.0",
|
"tsconfig-paths": "4.2.0",
|
||||||
"twemoji-parser": "14.0.0",
|
"twemoji-parser": "14.0.0",
|
||||||
"typeorm": "0.3.16",
|
"typeorm": "0.3.17",
|
||||||
"typescript": "5.1.3",
|
"typescript": "5.1.3",
|
||||||
"ulid": "2.3.0",
|
"ulid": "2.3.0",
|
||||||
"unzipper": "0.10.14",
|
"unzipper": "0.10.14",
|
||||||
"uuid": "9.0.0",
|
"uuid": "9.0.0",
|
||||||
"vary": "1.1.2",
|
"vary": "1.1.2",
|
||||||
"web-push": "3.6.1",
|
"web-push": "3.6.3",
|
||||||
"ws": "8.13.0",
|
"ws": "8.13.0",
|
||||||
"xev": "3.0.2"
|
"xev": "3.0.2"
|
||||||
},
|
},
|
||||||
|
@ -176,14 +175,14 @@
|
||||||
"@types/jest": "29.5.2",
|
"@types/jest": "29.5.2",
|
||||||
"@types/js-yaml": "4.0.5",
|
"@types/js-yaml": "4.0.5",
|
||||||
"@types/jsdom": "21.1.1",
|
"@types/jsdom": "21.1.1",
|
||||||
"@types/jsonld": "1.5.8",
|
"@types/jsonld": "1.5.9",
|
||||||
"@types/jsrsasign": "10.5.8",
|
"@types/jsrsasign": "10.5.8",
|
||||||
"@types/mime-types": "2.1.1",
|
"@types/mime-types": "2.1.1",
|
||||||
"@types/node": "20.2.5",
|
"@types/node": "20.3.1",
|
||||||
"@types/node-fetch": "3.0.3",
|
"@types/node-fetch": "3.0.3",
|
||||||
"@types/nodemailer": "6.4.8",
|
"@types/nodemailer": "6.4.8",
|
||||||
"@types/oauth": "0.9.1",
|
"@types/oauth": "0.9.1",
|
||||||
"@types/pg": "8.10.1",
|
"@types/pg": "8.10.2",
|
||||||
"@types/pug": "2.0.6",
|
"@types/pug": "2.0.6",
|
||||||
"@types/punycode": "2.1.0",
|
"@types/punycode": "2.1.0",
|
||||||
"@types/qrcode": "1.5.0",
|
"@types/qrcode": "1.5.0",
|
||||||
|
@ -198,16 +197,16 @@
|
||||||
"@types/tinycolor2": "1.4.3",
|
"@types/tinycolor2": "1.4.3",
|
||||||
"@types/tmp": "0.2.3",
|
"@types/tmp": "0.2.3",
|
||||||
"@types/unzipper": "0.10.6",
|
"@types/unzipper": "0.10.6",
|
||||||
"@types/uuid": "9.0.1",
|
"@types/uuid": "9.0.2",
|
||||||
"@types/vary": "1.1.0",
|
"@types/vary": "1.1.0",
|
||||||
"@types/web-push": "3.3.2",
|
"@types/web-push": "3.3.2",
|
||||||
"@types/websocket": "1.0.5",
|
"@types/websocket": "1.0.5",
|
||||||
"@types/ws": "8.5.4",
|
"@types/ws": "8.5.5",
|
||||||
"@typescript-eslint/eslint-plugin": "5.59.8",
|
"@typescript-eslint/eslint-plugin": "5.60.0",
|
||||||
"@typescript-eslint/parser": "5.59.8",
|
"@typescript-eslint/parser": "5.60.0",
|
||||||
"aws-sdk-client-mock": "2.1.1",
|
"aws-sdk-client-mock": "2.1.1",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"eslint": "8.41.0",
|
"eslint": "8.43.0",
|
||||||
"eslint-plugin-import": "2.27.5",
|
"eslint-plugin-import": "2.27.5",
|
||||||
"execa": "6.1.0",
|
"execa": "6.1.0",
|
||||||
"jest": "29.5.0",
|
"jest": "29.5.0",
|
||||||
|
|
|
@ -2,8 +2,7 @@ import * as fs from 'node:fs';
|
||||||
import * as stream from 'node:stream';
|
import * as stream from 'node:stream';
|
||||||
import * as util from 'node:util';
|
import * as util from 'node:util';
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import IPCIDR from 'ip-cidr';
|
import ipaddr from 'ipaddr.js';
|
||||||
import PrivateIp from 'private-ip';
|
|
||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import got, * as Got from 'got';
|
import got, * as Got from 'got';
|
||||||
import { parse } from 'content-disposition';
|
import { parse } from 'content-disposition';
|
||||||
|
@ -123,15 +122,15 @@ export class DownloadService {
|
||||||
public async downloadTextFile(url: string): Promise<string> {
|
public async downloadTextFile(url: string): Promise<string> {
|
||||||
// Create temp file
|
// Create temp file
|
||||||
const [path, cleanup] = await createTemp();
|
const [path, cleanup] = await createTemp();
|
||||||
|
|
||||||
this.logger.info(`text file: Temp file is ${path}`);
|
this.logger.info(`text file: Temp file is ${path}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// write content at URL to temp file
|
// write content at URL to temp file
|
||||||
await this.downloadUrl(url, path);
|
await this.downloadUrl(url, path);
|
||||||
|
|
||||||
const text = await util.promisify(fs.readFile)(path, 'utf8');
|
const text = await util.promisify(fs.readFile)(path, 'utf8');
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
} finally {
|
} finally {
|
||||||
cleanup();
|
cleanup();
|
||||||
|
@ -140,13 +139,14 @@ export class DownloadService {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
private isPrivateIp(ip: string): boolean {
|
private isPrivateIp(ip: string): boolean {
|
||||||
|
const parsedIp = ipaddr.parse(ip);
|
||||||
|
|
||||||
for (const net of this.config.allowedPrivateNetworks ?? []) {
|
for (const net of this.config.allowedPrivateNetworks ?? []) {
|
||||||
const cidr = new IPCIDR(net);
|
if (parsedIp.match(ipaddr.parseCIDR(net))) {
|
||||||
if (cidr.contains(ip)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return PrivateIp(ip) ?? false;
|
return parsedIp.range() !== 'unicast';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import type { Config } from '@/config.js';
|
||||||
import { genAid, parseAid } from '@/misc/id/aid.js';
|
import { genAid, parseAid } from '@/misc/id/aid.js';
|
||||||
import { genMeid, parseMeid } from '@/misc/id/meid.js';
|
import { genMeid, parseMeid } from '@/misc/id/meid.js';
|
||||||
import { genMeidg, parseMeidg } from '@/misc/id/meidg.js';
|
import { genMeidg, parseMeidg } from '@/misc/id/meidg.js';
|
||||||
import { genObjectId } from '@/misc/id/object-id.js';
|
import { genObjectId, parseObjectId } from '@/misc/id/object-id.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { parseUlid } from '@/misc/id/ulid.js';
|
import { parseUlid } from '@/misc/id/ulid.js';
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ export class IdService {
|
||||||
public parse(id: string): { date: Date; } {
|
public parse(id: string): { date: Date; } {
|
||||||
switch (this.method) {
|
switch (this.method) {
|
||||||
case 'aid': return parseAid(id);
|
case 'aid': return parseAid(id);
|
||||||
case 'objectid':
|
case 'objectid': return parseObjectId(id);
|
||||||
case 'meid': return parseMeid(id);
|
case 'meid': return parseMeid(id);
|
||||||
case 'meidg': return parseMeidg(id);
|
case 'meidg': return parseMeidg(id);
|
||||||
case 'ulid': return parseUlid(id);
|
case 'ulid': return parseUlid(id);
|
||||||
|
|
|
@ -406,11 +406,11 @@ export class QueueService {
|
||||||
this.deliverQueue.once('cleaned', (jobs, status) => {
|
this.deliverQueue.once('cleaned', (jobs, status) => {
|
||||||
//deliverLogger.succ(`Cleaned ${jobs.length} ${status} jobs`);
|
//deliverLogger.succ(`Cleaned ${jobs.length} ${status} jobs`);
|
||||||
});
|
});
|
||||||
this.deliverQueue.clean(0, Infinity, 'delayed');
|
this.deliverQueue.clean(0, 0, 'delayed');
|
||||||
|
|
||||||
this.inboxQueue.once('cleaned', (jobs, status) => {
|
this.inboxQueue.once('cleaned', (jobs, status) => {
|
||||||
//inboxLogger.succ(`Cleaned ${jobs.length} ${status} jobs`);
|
//inboxLogger.succ(`Cleaned ${jobs.length} ${status} jobs`);
|
||||||
});
|
});
|
||||||
this.inboxQueue.clean(0, Infinity, 'delayed');
|
this.inboxQueue.clean(0, 0, 'delayed');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||||
|
|
||||||
export default () => secureRndstr(16, true);
|
export default () => secureRndstr(16);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import IPCIDR from 'ip-cidr';
|
import IPCIDR from 'ip-cidr';
|
||||||
|
|
||||||
export function getIpHash(ip: string) {
|
export function getIpHash(ip: string): string {
|
||||||
try {
|
try {
|
||||||
// because a single person may control many IPv6 addresses,
|
// because a single person may control many IPv6 addresses,
|
||||||
// only a /64 subnet prefix of any IP will be taken into account.
|
// only a /64 subnet prefix of any IP will be taken into account.
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import * as crypto from 'node:crypto';
|
import * as crypto from 'node:crypto';
|
||||||
|
|
||||||
const L_CHARS = '0123456789abcdefghijklmnopqrstuvwxyz';
|
export const L_CHARS = '0123456789abcdefghijklmnopqrstuvwxyz';
|
||||||
const LU_CHARS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
const LU_CHARS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||||
|
|
||||||
export function secureRndstr(length = 32, useLU = true): string {
|
export function secureRndstr(length = 32, { chars = LU_CHARS } = {}): string {
|
||||||
const chars = useLU ? LU_CHARS : L_CHARS;
|
|
||||||
const chars_len = chars.length;
|
const chars_len = chars.length;
|
||||||
|
|
||||||
let str = '';
|
let str = '';
|
||||||
|
|
|
@ -337,7 +337,6 @@ import * as ep___users_reportAbuse from './endpoints/users/report-abuse.js';
|
||||||
import * as ep___users_searchByUsernameAndHost from './endpoints/users/search-by-username-and-host.js';
|
import * as ep___users_searchByUsernameAndHost from './endpoints/users/search-by-username-and-host.js';
|
||||||
import * as ep___users_search from './endpoints/users/search.js';
|
import * as ep___users_search from './endpoints/users/search.js';
|
||||||
import * as ep___users_show from './endpoints/users/show.js';
|
import * as ep___users_show from './endpoints/users/show.js';
|
||||||
import * as ep___users_stats from './endpoints/users/stats.js';
|
|
||||||
import * as ep___users_achievements from './endpoints/users/achievements.js';
|
import * as ep___users_achievements from './endpoints/users/achievements.js';
|
||||||
import * as ep___users_updateMemo from './endpoints/users/update-memo.js';
|
import * as ep___users_updateMemo from './endpoints/users/update-memo.js';
|
||||||
import * as ep___fetchRss from './endpoints/fetch-rss.js';
|
import * as ep___fetchRss from './endpoints/fetch-rss.js';
|
||||||
|
@ -682,7 +681,6 @@ const $users_reportAbuse: Provider = { provide: 'ep:users/report-abuse', useClas
|
||||||
const $users_searchByUsernameAndHost: Provider = { provide: 'ep:users/search-by-username-and-host', useClass: ep___users_searchByUsernameAndHost.default };
|
const $users_searchByUsernameAndHost: Provider = { provide: 'ep:users/search-by-username-and-host', useClass: ep___users_searchByUsernameAndHost.default };
|
||||||
const $users_search: Provider = { provide: 'ep:users/search', useClass: ep___users_search.default };
|
const $users_search: Provider = { provide: 'ep:users/search', useClass: ep___users_search.default };
|
||||||
const $users_show: Provider = { provide: 'ep:users/show', useClass: ep___users_show.default };
|
const $users_show: Provider = { provide: 'ep:users/show', useClass: ep___users_show.default };
|
||||||
const $users_stats: Provider = { provide: 'ep:users/stats', useClass: ep___users_stats.default };
|
|
||||||
const $users_achievements: Provider = { provide: 'ep:users/achievements', useClass: ep___users_achievements.default };
|
const $users_achievements: Provider = { provide: 'ep:users/achievements', useClass: ep___users_achievements.default };
|
||||||
const $users_updateMemo: Provider = { provide: 'ep:users/update-memo', useClass: ep___users_updateMemo.default };
|
const $users_updateMemo: Provider = { provide: 'ep:users/update-memo', useClass: ep___users_updateMemo.default };
|
||||||
const $fetchRss: Provider = { provide: 'ep:fetch-rss', useClass: ep___fetchRss.default };
|
const $fetchRss: Provider = { provide: 'ep:fetch-rss', useClass: ep___fetchRss.default };
|
||||||
|
@ -1031,7 +1029,6 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention
|
||||||
$users_searchByUsernameAndHost,
|
$users_searchByUsernameAndHost,
|
||||||
$users_search,
|
$users_search,
|
||||||
$users_show,
|
$users_show,
|
||||||
$users_stats,
|
|
||||||
$users_achievements,
|
$users_achievements,
|
||||||
$users_updateMemo,
|
$users_updateMemo,
|
||||||
$fetchRss,
|
$fetchRss,
|
||||||
|
@ -1372,7 +1369,6 @@ const $retention: Provider = { provide: 'ep:retention', useClass: ep___retention
|
||||||
$users_searchByUsernameAndHost,
|
$users_searchByUsernameAndHost,
|
||||||
$users_search,
|
$users_search,
|
||||||
$users_show,
|
$users_show,
|
||||||
$users_stats,
|
|
||||||
$users_achievements,
|
$users_achievements,
|
||||||
$users_updateMemo,
|
$users_updateMemo,
|
||||||
$fetchRss,
|
$fetchRss,
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import rndstr from 'rndstr';
|
|
||||||
import bcrypt from 'bcryptjs';
|
import bcrypt from 'bcryptjs';
|
||||||
import { IsNull } from 'typeorm';
|
import { IsNull } from 'typeorm';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
@ -16,6 +15,7 @@ import { FastifyReplyError } from '@/misc/fastify-reply-error.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { SigninService } from './SigninService.js';
|
import { SigninService } from './SigninService.js';
|
||||||
import type { FastifyRequest, FastifyReply } from 'fastify';
|
import type { FastifyRequest, FastifyReply } from 'fastify';
|
||||||
|
import { L_CHARS, secureRndstr } from '@/misc/secure-rndstr.js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SignupApiService {
|
export class SignupApiService {
|
||||||
|
@ -67,7 +67,7 @@ export class SignupApiService {
|
||||||
const body = request.body;
|
const body = request.body;
|
||||||
|
|
||||||
const instance = await this.metaService.fetch(true);
|
const instance = await this.metaService.fetch(true);
|
||||||
|
|
||||||
// Verify *Captcha
|
// Verify *Captcha
|
||||||
// ただしテスト時はこの機構は障害となるため無効にする
|
// ただしテスト時はこの機構は障害となるため無効にする
|
||||||
if (process.env.NODE_ENV !== 'test') {
|
if (process.env.NODE_ENV !== 'test') {
|
||||||
|
@ -76,7 +76,7 @@ export class SignupApiService {
|
||||||
throw new FastifyReplyError(400, err);
|
throw new FastifyReplyError(400, err);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instance.enableRecaptcha && instance.recaptchaSecretKey) {
|
if (instance.enableRecaptcha && instance.recaptchaSecretKey) {
|
||||||
await this.captchaService.verifyRecaptcha(instance.recaptchaSecretKey, body['g-recaptcha-response']).catch(err => {
|
await this.captchaService.verifyRecaptcha(instance.recaptchaSecretKey, body['g-recaptcha-response']).catch(err => {
|
||||||
throw new FastifyReplyError(400, err);
|
throw new FastifyReplyError(400, err);
|
||||||
|
@ -89,44 +89,44 @@ export class SignupApiService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const username = body['username'];
|
const username = body['username'];
|
||||||
const password = body['password'];
|
const password = body['password'];
|
||||||
const host: string | null = process.env.NODE_ENV === 'test' ? (body['host'] ?? null) : null;
|
const host: string | null = process.env.NODE_ENV === 'test' ? (body['host'] ?? null) : null;
|
||||||
const invitationCode = body['invitationCode'];
|
const invitationCode = body['invitationCode'];
|
||||||
const emailAddress = body['emailAddress'];
|
const emailAddress = body['emailAddress'];
|
||||||
|
|
||||||
if (instance.emailRequiredForSignup) {
|
if (instance.emailRequiredForSignup) {
|
||||||
if (emailAddress == null || typeof emailAddress !== 'string') {
|
if (emailAddress == null || typeof emailAddress !== 'string') {
|
||||||
reply.code(400);
|
reply.code(400);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await this.emailService.validateEmailForAccount(emailAddress);
|
const res = await this.emailService.validateEmailForAccount(emailAddress);
|
||||||
if (!res.available) {
|
if (!res.available) {
|
||||||
reply.code(400);
|
reply.code(400);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instance.disableRegistration) {
|
if (instance.disableRegistration) {
|
||||||
if (invitationCode == null || typeof invitationCode !== 'string') {
|
if (invitationCode == null || typeof invitationCode !== 'string') {
|
||||||
reply.code(400);
|
reply.code(400);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ticket = await this.registrationTicketsRepository.findOneBy({
|
const ticket = await this.registrationTicketsRepository.findOneBy({
|
||||||
code: invitationCode,
|
code: invitationCode,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (ticket == null) {
|
if (ticket == null) {
|
||||||
reply.code(400);
|
reply.code(400);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.registrationTicketsRepository.delete(ticket.id);
|
this.registrationTicketsRepository.delete(ticket.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instance.emailRequiredForSignup) {
|
if (instance.emailRequiredForSignup) {
|
||||||
if (await this.usersRepository.findOneBy({ usernameLower: username.toLowerCase(), host: IsNull() })) {
|
if (await this.usersRepository.findOneBy({ usernameLower: username.toLowerCase(), host: IsNull() })) {
|
||||||
throw new FastifyReplyError(400, 'DUPLICATED_USERNAME');
|
throw new FastifyReplyError(400, 'DUPLICATED_USERNAME');
|
||||||
|
@ -142,7 +142,7 @@ export class SignupApiService {
|
||||||
throw new FastifyReplyError(400, 'DENIED_USERNAME');
|
throw new FastifyReplyError(400, 'DENIED_USERNAME');
|
||||||
}
|
}
|
||||||
|
|
||||||
const code = rndstr('a-z0-9', 16);
|
const code = secureRndstr(16, { chars: L_CHARS });
|
||||||
|
|
||||||
// Generate hash of password
|
// Generate hash of password
|
||||||
const salt = await bcrypt.genSalt(8);
|
const salt = await bcrypt.genSalt(8);
|
||||||
|
@ -170,12 +170,12 @@ export class SignupApiService {
|
||||||
const { account, secret } = await this.signupService.signup({
|
const { account, secret } = await this.signupService.signup({
|
||||||
username, password, host,
|
username, password, host,
|
||||||
});
|
});
|
||||||
|
|
||||||
const res = await this.userEntityService.pack(account, account, {
|
const res = await this.userEntityService.pack(account, account, {
|
||||||
detail: true,
|
detail: true,
|
||||||
includeSecrets: true,
|
includeSecrets: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...res,
|
...res,
|
||||||
token: secret,
|
token: secret,
|
||||||
|
|
|
@ -337,7 +337,6 @@ import * as ep___users_reportAbuse from './endpoints/users/report-abuse.js';
|
||||||
import * as ep___users_searchByUsernameAndHost from './endpoints/users/search-by-username-and-host.js';
|
import * as ep___users_searchByUsernameAndHost from './endpoints/users/search-by-username-and-host.js';
|
||||||
import * as ep___users_search from './endpoints/users/search.js';
|
import * as ep___users_search from './endpoints/users/search.js';
|
||||||
import * as ep___users_show from './endpoints/users/show.js';
|
import * as ep___users_show from './endpoints/users/show.js';
|
||||||
import * as ep___users_stats from './endpoints/users/stats.js';
|
|
||||||
import * as ep___users_achievements from './endpoints/users/achievements.js';
|
import * as ep___users_achievements from './endpoints/users/achievements.js';
|
||||||
import * as ep___users_updateMemo from './endpoints/users/update-memo.js';
|
import * as ep___users_updateMemo from './endpoints/users/update-memo.js';
|
||||||
import * as ep___fetchRss from './endpoints/fetch-rss.js';
|
import * as ep___fetchRss from './endpoints/fetch-rss.js';
|
||||||
|
@ -680,7 +679,6 @@ const eps = [
|
||||||
['users/search-by-username-and-host', ep___users_searchByUsernameAndHost],
|
['users/search-by-username-and-host', ep___users_searchByUsernameAndHost],
|
||||||
['users/search', ep___users_search],
|
['users/search', ep___users_search],
|
||||||
['users/show', ep___users_show],
|
['users/show', ep___users_show],
|
||||||
['users/stats', ep___users_stats],
|
|
||||||
['users/achievements', ep___users_achievements],
|
['users/achievements', ep___users_achievements],
|
||||||
['users/update-memo', ep___users_updateMemo],
|
['users/update-memo', ep___users_updateMemo],
|
||||||
['fetch-rss', ep___fetchRss],
|
['fetch-rss', ep___fetchRss],
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import rndstr from 'rndstr';
|
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import type { DriveFilesRepository } from '@/models/index.js';
|
import type { DriveFilesRepository } from '@/models/index.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import bcrypt from 'bcryptjs';
|
import bcrypt from 'bcryptjs';
|
||||||
import rndstr from 'rndstr';
|
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import type { UsersRepository, UserProfilesRepository } from '@/models/index.js';
|
import type { UsersRepository, UserProfilesRepository } from '@/models/index.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['admin'],
|
tags: ['admin'],
|
||||||
|
@ -54,7 +54,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
throw new Error('cannot reset password of root');
|
throw new Error('cannot reset password of root');
|
||||||
}
|
}
|
||||||
|
|
||||||
const passwd = rndstr('a-zA-Z0-9', 8);
|
const passwd = secureRndstr(8);
|
||||||
|
|
||||||
// Generate hash of password
|
// Generate hash of password
|
||||||
const hash = bcrypt.hashSync(passwd);
|
const hash = bcrypt.hashSync(passwd);
|
||||||
|
|
|
@ -44,7 +44,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
// Generate secret
|
// Generate secret
|
||||||
const secret = secureRndstr(32, true);
|
const secret = secureRndstr(32);
|
||||||
|
|
||||||
// for backward compatibility
|
// for backward compatibility
|
||||||
const permission = unique(ps.permission.map(v => v.replace(/^(.+)(\/|-)(read|write)$/, '$3:$1')));
|
const permission = unique(ps.permission.map(v => v.replace(/^(.+)(\/|-)(read|write)$/, '$3:$1')));
|
||||||
|
|
|
@ -55,7 +55,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
throw new ApiError(meta.errors.noSuchSession);
|
throw new ApiError(meta.errors.noSuchSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
const accessToken = secureRndstr(32, true);
|
const accessToken = secureRndstr(32);
|
||||||
|
|
||||||
// Fetch exist access token
|
// Fetch exist access token
|
||||||
const exist = await this.accessTokensRepository.findOneBy({
|
const exist = await this.accessTokensRepository.findOneBy({
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import rndstr from 'rndstr';
|
|
||||||
import ms from 'ms';
|
import ms from 'ms';
|
||||||
import bcrypt from 'bcryptjs';
|
import bcrypt from 'bcryptjs';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
|
@ -9,6 +8,7 @@ import { EmailService } from '@/core/EmailService.js';
|
||||||
import type { Config } from '@/config.js';
|
import type { Config } from '@/config.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||||
|
import { L_CHARS, secureRndstr } from '@/misc/secure-rndstr.js';
|
||||||
import { ApiError } from '../../error.js';
|
import { ApiError } from '../../error.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
|
@ -94,7 +94,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
this.globalEventService.publishMainStream(me.id, 'meUpdated', iObj);
|
this.globalEventService.publishMainStream(me.id, 'meUpdated', iObj);
|
||||||
|
|
||||||
if (ps.email != null) {
|
if (ps.email != null) {
|
||||||
const code = rndstr('a-z0-9', 16);
|
const code = secureRndstr(16, { chars: L_CHARS });
|
||||||
|
|
||||||
await this.userProfilesRepository.update(me.id, {
|
await this.userProfilesRepository.update(me.id, {
|
||||||
emailVerifyCode: code,
|
emailVerifyCode: code,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import rndstr from 'rndstr';
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import type { RegistrationTicketsRepository } from '@/models/index.js';
|
import type { RegistrationTicketsRepository } from '@/models/index.js';
|
||||||
import { IdService } from '@/core/IdService.js';
|
import { IdService } from '@/core/IdService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
|
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['meta'],
|
tags: ['meta'],
|
||||||
|
@ -42,9 +42,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
private idService: IdService,
|
private idService: IdService,
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
const code = rndstr({
|
const code = secureRndstr(8, {
|
||||||
length: 8,
|
chars: '23456789ABCDEFGHJKLMNPQRSTUVWXYZ', // [0-9A-Z] w/o [01IO] (32 patterns)
|
||||||
chars: '2-9A-HJ-NP-Z', // [0-9A-Z] w/o [01IO] (32 patterns)
|
|
||||||
});
|
});
|
||||||
|
|
||||||
await this.registrationTicketsRepository.insert({
|
await this.registrationTicketsRepository.insert({
|
||||||
|
|
|
@ -49,7 +49,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
) {
|
) {
|
||||||
super(meta, paramDef, async (ps, me) => {
|
super(meta, paramDef, async (ps, me) => {
|
||||||
// Generate access token
|
// Generate access token
|
||||||
const accessToken = secureRndstr(32, true);
|
const accessToken = secureRndstr(32);
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import rndstr from 'rndstr';
|
|
||||||
import ms from 'ms';
|
import ms from 'ms';
|
||||||
import { IsNull } from 'typeorm';
|
import { IsNull } from 'typeorm';
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
|
@ -8,6 +7,7 @@ import { IdService } from '@/core/IdService.js';
|
||||||
import type { Config } from '@/config.js';
|
import type { Config } from '@/config.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { EmailService } from '@/core/EmailService.js';
|
import { EmailService } from '@/core/EmailService.js';
|
||||||
|
import { L_CHARS, secureRndstr } from '@/misc/secure-rndstr.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['reset password'],
|
tags: ['reset password'],
|
||||||
|
@ -41,7 +41,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
constructor(
|
constructor(
|
||||||
@Inject(DI.config)
|
@Inject(DI.config)
|
||||||
private config: Config,
|
private config: Config,
|
||||||
|
|
||||||
@Inject(DI.usersRepository)
|
@Inject(DI.usersRepository)
|
||||||
private usersRepository: UsersRepository,
|
private usersRepository: UsersRepository,
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const token = rndstr('a-z0-9', 64);
|
const token = secureRndstr(64, { chars: L_CHARS });
|
||||||
|
|
||||||
await this.passwordResetRequestsRepository.insert({
|
await this.passwordResetRequestsRepository.insert({
|
||||||
id: this.idService.genId(),
|
id: this.idService.genId(),
|
||||||
|
|
|
@ -1,228 +0,0 @@
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
|
||||||
import { awaitAll } from '@/misc/prelude/await-all.js';
|
|
||||||
import { Endpoint } from '@/server/api/endpoint-base.js';
|
|
||||||
import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js';
|
|
||||||
import { DI } from '@/di-symbols.js';
|
|
||||||
import type { UsersRepository, NotesRepository, FollowingsRepository, DriveFilesRepository, NoteReactionsRepository, PageLikesRepository, NoteFavoritesRepository, PollVotesRepository } from '@/models/index.js';
|
|
||||||
import { ApiError } from '../../error.js';
|
|
||||||
|
|
||||||
export const meta = {
|
|
||||||
tags: ['users'],
|
|
||||||
|
|
||||||
requireCredential: false,
|
|
||||||
|
|
||||||
description: 'Show statistics about a user.',
|
|
||||||
|
|
||||||
errors: {
|
|
||||||
noSuchUser: {
|
|
||||||
message: 'No such user.',
|
|
||||||
code: 'NO_SUCH_USER',
|
|
||||||
id: '9e638e45-3b25-4ef7-8f95-07e8498f1819',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
res: {
|
|
||||||
type: 'object',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
properties: {
|
|
||||||
notesCount: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
repliesCount: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
renotesCount: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
repliedCount: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
renotedCount: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
pollVotesCount: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
pollVotedCount: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
localFollowingCount: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
remoteFollowingCount: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
localFollowersCount: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
remoteFollowersCount: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
followingCount: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
followersCount: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
sentReactionsCount: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
receivedReactionsCount: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
noteFavoritesCount: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
pageLikesCount: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
pageLikedCount: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
driveFilesCount: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
},
|
|
||||||
driveUsage: {
|
|
||||||
type: 'integer',
|
|
||||||
optional: false, nullable: false,
|
|
||||||
description: 'Drive usage in bytes',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
export const paramDef = {
|
|
||||||
type: 'object',
|
|
||||||
properties: {
|
|
||||||
userId: { type: 'string', format: 'misskey:id' },
|
|
||||||
},
|
|
||||||
required: ['userId'],
|
|
||||||
} as const;
|
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
|
||||||
@Injectable()
|
|
||||||
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|
||||||
constructor(
|
|
||||||
@Inject(DI.usersRepository)
|
|
||||||
private usersRepository: UsersRepository,
|
|
||||||
|
|
||||||
@Inject(DI.notesRepository)
|
|
||||||
private notesRepository: NotesRepository,
|
|
||||||
|
|
||||||
@Inject(DI.followingsRepository)
|
|
||||||
private followingsRepository: FollowingsRepository,
|
|
||||||
|
|
||||||
@Inject(DI.driveFilesRepository)
|
|
||||||
private driveFilesRepository: DriveFilesRepository,
|
|
||||||
|
|
||||||
@Inject(DI.noteReactionsRepository)
|
|
||||||
private noteReactionsRepository: NoteReactionsRepository,
|
|
||||||
|
|
||||||
@Inject(DI.pageLikesRepository)
|
|
||||||
private pageLikesRepository: PageLikesRepository,
|
|
||||||
|
|
||||||
@Inject(DI.noteFavoritesRepository)
|
|
||||||
private noteFavoritesRepository: NoteFavoritesRepository,
|
|
||||||
|
|
||||||
@Inject(DI.pollVotesRepository)
|
|
||||||
private pollVotesRepository: PollVotesRepository,
|
|
||||||
|
|
||||||
private driveFileEntityService: DriveFileEntityService,
|
|
||||||
) {
|
|
||||||
super(meta, paramDef, async (ps, me) => {
|
|
||||||
const user = await this.usersRepository.findOneBy({ id: ps.userId });
|
|
||||||
if (user == null) {
|
|
||||||
throw new ApiError(meta.errors.noSuchUser);
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = await awaitAll({
|
|
||||||
notesCount: this.notesRepository.createQueryBuilder('note')
|
|
||||||
.where('note.userId = :userId', { userId: user.id })
|
|
||||||
.getCount(),
|
|
||||||
repliesCount: this.notesRepository.createQueryBuilder('note')
|
|
||||||
.where('note.userId = :userId', { userId: user.id })
|
|
||||||
.andWhere('note.replyId IS NOT NULL')
|
|
||||||
.getCount(),
|
|
||||||
renotesCount: this.notesRepository.createQueryBuilder('note')
|
|
||||||
.where('note.userId = :userId', { userId: user.id })
|
|
||||||
.andWhere('note.renoteId IS NOT NULL')
|
|
||||||
.getCount(),
|
|
||||||
repliedCount: this.notesRepository.createQueryBuilder('note')
|
|
||||||
.where('note.replyUserId = :userId', { userId: user.id })
|
|
||||||
.getCount(),
|
|
||||||
renotedCount: this.notesRepository.createQueryBuilder('note')
|
|
||||||
.where('note.renoteUserId = :userId', { userId: user.id })
|
|
||||||
.getCount(),
|
|
||||||
pollVotesCount: this.pollVotesRepository.createQueryBuilder('vote')
|
|
||||||
.where('vote.userId = :userId', { userId: user.id })
|
|
||||||
.getCount(),
|
|
||||||
pollVotedCount: this.pollVotesRepository.createQueryBuilder('vote')
|
|
||||||
.innerJoin('vote.note', 'note')
|
|
||||||
.where('note.userId = :userId', { userId: user.id })
|
|
||||||
.getCount(),
|
|
||||||
localFollowingCount: this.followingsRepository.createQueryBuilder('following')
|
|
||||||
.where('following.followerId = :userId', { userId: user.id })
|
|
||||||
.andWhere('following.followeeHost IS NULL')
|
|
||||||
.getCount(),
|
|
||||||
remoteFollowingCount: this.followingsRepository.createQueryBuilder('following')
|
|
||||||
.where('following.followerId = :userId', { userId: user.id })
|
|
||||||
.andWhere('following.followeeHost IS NOT NULL')
|
|
||||||
.getCount(),
|
|
||||||
localFollowersCount: this.followingsRepository.createQueryBuilder('following')
|
|
||||||
.where('following.followeeId = :userId', { userId: user.id })
|
|
||||||
.andWhere('following.followerHost IS NULL')
|
|
||||||
.getCount(),
|
|
||||||
remoteFollowersCount: this.followingsRepository.createQueryBuilder('following')
|
|
||||||
.where('following.followeeId = :userId', { userId: user.id })
|
|
||||||
.andWhere('following.followerHost IS NOT NULL')
|
|
||||||
.getCount(),
|
|
||||||
sentReactionsCount: this.noteReactionsRepository.createQueryBuilder('reaction')
|
|
||||||
.where('reaction.userId = :userId', { userId: user.id })
|
|
||||||
.getCount(),
|
|
||||||
receivedReactionsCount: this.noteReactionsRepository.createQueryBuilder('reaction')
|
|
||||||
.innerJoin('reaction.note', 'note')
|
|
||||||
.where('note.userId = :userId', { userId: user.id })
|
|
||||||
.getCount(),
|
|
||||||
noteFavoritesCount: this.noteFavoritesRepository.createQueryBuilder('favorite')
|
|
||||||
.where('favorite.userId = :userId', { userId: user.id })
|
|
||||||
.getCount(),
|
|
||||||
pageLikesCount: this.pageLikesRepository.createQueryBuilder('like')
|
|
||||||
.where('like.userId = :userId', { userId: user.id })
|
|
||||||
.getCount(),
|
|
||||||
pageLikedCount: this.pageLikesRepository.createQueryBuilder('like')
|
|
||||||
.innerJoin('like.page', 'page')
|
|
||||||
.where('page.userId = :userId', { userId: user.id })
|
|
||||||
.getCount(),
|
|
||||||
driveFilesCount: this.driveFilesRepository.createQueryBuilder('file')
|
|
||||||
.where('file.userId = :userId', { userId: user.id })
|
|
||||||
.getCount(),
|
|
||||||
driveUsage: this.driveFileEntityService.calcDriveUsageOf(user),
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
...result,
|
|
||||||
followingCount: result.localFollowingCount + result.remoteFollowingCount,
|
|
||||||
followersCount: result.localFollowersCount + result.remoteFollowersCount,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -35,7 +35,7 @@ html
|
||||||
link(rel='prefetch' href=infoImageUrl)
|
link(rel='prefetch' href=infoImageUrl)
|
||||||
link(rel='prefetch' href=notFoundImageUrl)
|
link(rel='prefetch' href=notFoundImageUrl)
|
||||||
//- https://github.com/misskey-dev/misskey/issues/9842
|
//- https://github.com/misskey-dev/misskey/issues/9842
|
||||||
link(rel='stylesheet' href='/assets/tabler-icons/tabler-icons.min.css?v2.21.0')
|
link(rel='stylesheet' href='/assets/tabler-icons/tabler-icons.min.css?v2.22.0')
|
||||||
link(rel='modulepreload' href=`/vite/${clientEntry.file}`)
|
link(rel='modulepreload' href=`/vite/${clientEntry.file}`)
|
||||||
|
|
||||||
if !config.clientManifestExists
|
if !config.clientManifestExists
|
||||||
|
|
|
@ -7,10 +7,11 @@ import * as OTPAuth from 'otpauth';
|
||||||
import { loadConfig } from '../../src/config.js';
|
import { loadConfig } from '../../src/config.js';
|
||||||
import { signup, api, post, react, startServer, waitFire } from '../utils.js';
|
import { signup, api, post, react, startServer, waitFire } from '../utils.js';
|
||||||
import type { INestApplicationContext } from '@nestjs/common';
|
import type { INestApplicationContext } from '@nestjs/common';
|
||||||
|
import type * as misskey from 'misskey-js';
|
||||||
|
|
||||||
describe('2要素認証', () => {
|
describe('2要素認証', () => {
|
||||||
let app: INestApplicationContext;
|
let app: INestApplicationContext;
|
||||||
let alice: unknown;
|
let alice: misskey.entities.MeSignup;
|
||||||
|
|
||||||
const config = loadConfig();
|
const config = loadConfig();
|
||||||
const password = 'test';
|
const password = 'test';
|
||||||
|
@ -68,7 +69,7 @@ describe('2要素認証', () => {
|
||||||
]));
|
]));
|
||||||
|
|
||||||
// AuthenticatorAssertionResponse.authenticatorData
|
// AuthenticatorAssertionResponse.authenticatorData
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/AuthenticatorAssertionResponse/authenticatorData
|
// https://developer.mozilla.org/en-US/docs/Web/API/AuthenticatorAssertionResponse/authenticatorData
|
||||||
const credentialIdLength = Buffer.allocUnsafe(2);
|
const credentialIdLength = Buffer.allocUnsafe(2);
|
||||||
credentialIdLength.writeUInt16BE(param.credentialId.length);
|
credentialIdLength.writeUInt16BE(param.credentialId.length);
|
||||||
const authData = Buffer.concat([
|
const authData = Buffer.concat([
|
||||||
|
@ -80,7 +81,7 @@ describe('2要素認証', () => {
|
||||||
param.credentialId,
|
param.credentialId,
|
||||||
credentialPublicKey,
|
credentialPublicKey,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
attestationObject: cbor.encode({
|
attestationObject: cbor.encode({
|
||||||
fmt: 'none',
|
fmt: 'none',
|
||||||
|
@ -98,7 +99,7 @@ describe('2要素認証', () => {
|
||||||
name: param.keyName,
|
name: param.keyName,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const signinParam = (): {
|
const signinParam = (): {
|
||||||
username: string,
|
username: string,
|
||||||
password: string,
|
password: string,
|
||||||
|
@ -130,7 +131,7 @@ describe('2要素認証', () => {
|
||||||
'hcaptcha-response'?: string | null,
|
'hcaptcha-response'?: string | null,
|
||||||
} => {
|
} => {
|
||||||
// AuthenticatorAssertionResponse.authenticatorData
|
// AuthenticatorAssertionResponse.authenticatorData
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/AuthenticatorAssertionResponse/authenticatorData
|
// https://developer.mozilla.org/en-US/docs/Web/API/AuthenticatorAssertionResponse/authenticatorData
|
||||||
const authenticatorData = Buffer.concat([
|
const authenticatorData = Buffer.concat([
|
||||||
rpIdHash(),
|
rpIdHash(),
|
||||||
Buffer.from([0x05]), // flags(1)
|
Buffer.from([0x05]), // flags(1)
|
||||||
|
@ -146,7 +147,7 @@ describe('2要素認証', () => {
|
||||||
.update(clientDataJSONBuffer)
|
.update(clientDataJSONBuffer)
|
||||||
.digest();
|
.digest();
|
||||||
const privateKey = crypto.createPrivateKey(pemToSign);
|
const privateKey = crypto.createPrivateKey(pemToSign);
|
||||||
const signature = crypto.createSign('SHA256')
|
const signature = crypto.createSign('SHA256')
|
||||||
.update(Buffer.concat([authenticatorData, hashedclientDataJSON]))
|
.update(Buffer.concat([authenticatorData, hashedclientDataJSON]))
|
||||||
.sign(privateKey);
|
.sign(privateKey);
|
||||||
return {
|
return {
|
||||||
|
@ -186,14 +187,14 @@ describe('2要素認証', () => {
|
||||||
token: otpToken(registerResponse.body.secret),
|
token: otpToken(registerResponse.body.secret),
|
||||||
}, alice);
|
}, alice);
|
||||||
assert.strictEqual(doneResponse.status, 204);
|
assert.strictEqual(doneResponse.status, 204);
|
||||||
|
|
||||||
const usersShowResponse = await api('/users/show', {
|
const usersShowResponse = await api('/users/show', {
|
||||||
username,
|
username,
|
||||||
}, alice);
|
}, alice);
|
||||||
assert.strictEqual(usersShowResponse.status, 200);
|
assert.strictEqual(usersShowResponse.status, 200);
|
||||||
assert.strictEqual(usersShowResponse.body.twoFactorEnabled, true);
|
assert.strictEqual(usersShowResponse.body.twoFactorEnabled, true);
|
||||||
|
|
||||||
const signinResponse = await api('/signin', {
|
const signinResponse = await api('/signin', {
|
||||||
...signinParam(),
|
...signinParam(),
|
||||||
token: otpToken(registerResponse.body.secret),
|
token: otpToken(registerResponse.body.secret),
|
||||||
});
|
});
|
||||||
|
@ -211,7 +212,7 @@ describe('2要素認証', () => {
|
||||||
token: otpToken(registerResponse.body.secret),
|
token: otpToken(registerResponse.body.secret),
|
||||||
}, alice);
|
}, alice);
|
||||||
assert.strictEqual(doneResponse.status, 204);
|
assert.strictEqual(doneResponse.status, 204);
|
||||||
|
|
||||||
const registerKeyResponse = await api('/i/2fa/register-key', {
|
const registerKeyResponse = await api('/i/2fa/register-key', {
|
||||||
password,
|
password,
|
||||||
}, alice);
|
}, alice);
|
||||||
|
@ -230,7 +231,7 @@ describe('2要素認証', () => {
|
||||||
assert.strictEqual(keyDoneResponse.status, 200);
|
assert.strictEqual(keyDoneResponse.status, 200);
|
||||||
assert.strictEqual(keyDoneResponse.body.id, credentialId.toString('hex'));
|
assert.strictEqual(keyDoneResponse.body.id, credentialId.toString('hex'));
|
||||||
assert.strictEqual(keyDoneResponse.body.name, keyName);
|
assert.strictEqual(keyDoneResponse.body.name, keyName);
|
||||||
|
|
||||||
const usersShowResponse = await api('/users/show', {
|
const usersShowResponse = await api('/users/show', {
|
||||||
username,
|
username,
|
||||||
});
|
});
|
||||||
|
@ -267,7 +268,7 @@ describe('2要素認証', () => {
|
||||||
token: otpToken(registerResponse.body.secret),
|
token: otpToken(registerResponse.body.secret),
|
||||||
}, alice);
|
}, alice);
|
||||||
assert.strictEqual(doneResponse.status, 204);
|
assert.strictEqual(doneResponse.status, 204);
|
||||||
|
|
||||||
const registerKeyResponse = await api('/i/2fa/register-key', {
|
const registerKeyResponse = await api('/i/2fa/register-key', {
|
||||||
password,
|
password,
|
||||||
}, alice);
|
}, alice);
|
||||||
|
@ -282,7 +283,7 @@ describe('2要素認証', () => {
|
||||||
credentialId,
|
credentialId,
|
||||||
}), alice);
|
}), alice);
|
||||||
assert.strictEqual(keyDoneResponse.status, 200);
|
assert.strictEqual(keyDoneResponse.status, 200);
|
||||||
|
|
||||||
const passwordLessResponse = await api('/i/2fa/password-less', {
|
const passwordLessResponse = await api('/i/2fa/password-less', {
|
||||||
value: true,
|
value: true,
|
||||||
}, alice);
|
}, alice);
|
||||||
|
@ -301,7 +302,7 @@ describe('2要素認証', () => {
|
||||||
assert.strictEqual(signinResponse.status, 200);
|
assert.strictEqual(signinResponse.status, 200);
|
||||||
assert.strictEqual(signinResponse.body.i, undefined);
|
assert.strictEqual(signinResponse.body.i, undefined);
|
||||||
|
|
||||||
const signinResponse2 = await api('/signin', {
|
const signinResponse2 = await api('/signin', {
|
||||||
...signinWithSecurityKeyParam({
|
...signinWithSecurityKeyParam({
|
||||||
keyName,
|
keyName,
|
||||||
challengeId: signinResponse.body.challengeId,
|
challengeId: signinResponse.body.challengeId,
|
||||||
|
@ -324,7 +325,7 @@ describe('2要素認証', () => {
|
||||||
token: otpToken(registerResponse.body.secret),
|
token: otpToken(registerResponse.body.secret),
|
||||||
}, alice);
|
}, alice);
|
||||||
assert.strictEqual(doneResponse.status, 204);
|
assert.strictEqual(doneResponse.status, 204);
|
||||||
|
|
||||||
const registerKeyResponse = await api('/i/2fa/register-key', {
|
const registerKeyResponse = await api('/i/2fa/register-key', {
|
||||||
password,
|
password,
|
||||||
}, alice);
|
}, alice);
|
||||||
|
@ -339,14 +340,14 @@ describe('2要素認証', () => {
|
||||||
credentialId,
|
credentialId,
|
||||||
}), alice);
|
}), alice);
|
||||||
assert.strictEqual(keyDoneResponse.status, 200);
|
assert.strictEqual(keyDoneResponse.status, 200);
|
||||||
|
|
||||||
const renamedKey = 'other-key';
|
const renamedKey = 'other-key';
|
||||||
const updateKeyResponse = await api('/i/2fa/update-key', {
|
const updateKeyResponse = await api('/i/2fa/update-key', {
|
||||||
name: renamedKey,
|
name: renamedKey,
|
||||||
credentialId: credentialId.toString('hex'),
|
credentialId: credentialId.toString('hex'),
|
||||||
}, alice);
|
}, alice);
|
||||||
assert.strictEqual(updateKeyResponse.status, 200);
|
assert.strictEqual(updateKeyResponse.status, 200);
|
||||||
|
|
||||||
const iResponse = await api('/i', {
|
const iResponse = await api('/i', {
|
||||||
}, alice);
|
}, alice);
|
||||||
assert.strictEqual(iResponse.status, 200);
|
assert.strictEqual(iResponse.status, 200);
|
||||||
|
@ -366,7 +367,7 @@ describe('2要素認証', () => {
|
||||||
token: otpToken(registerResponse.body.secret),
|
token: otpToken(registerResponse.body.secret),
|
||||||
}, alice);
|
}, alice);
|
||||||
assert.strictEqual(doneResponse.status, 204);
|
assert.strictEqual(doneResponse.status, 204);
|
||||||
|
|
||||||
const registerKeyResponse = await api('/i/2fa/register-key', {
|
const registerKeyResponse = await api('/i/2fa/register-key', {
|
||||||
password,
|
password,
|
||||||
}, alice);
|
}, alice);
|
||||||
|
@ -381,7 +382,7 @@ describe('2要素認証', () => {
|
||||||
credentialId,
|
credentialId,
|
||||||
}), alice);
|
}), alice);
|
||||||
assert.strictEqual(keyDoneResponse.status, 200);
|
assert.strictEqual(keyDoneResponse.status, 200);
|
||||||
|
|
||||||
// テストの実行順によっては複数残ってるので全部消す
|
// テストの実行順によっては複数残ってるので全部消す
|
||||||
const iResponse = await api('/i', {
|
const iResponse = await api('/i', {
|
||||||
}, alice);
|
}, alice);
|
||||||
|
@ -400,14 +401,14 @@ describe('2要素認証', () => {
|
||||||
assert.strictEqual(usersShowResponse.status, 200);
|
assert.strictEqual(usersShowResponse.status, 200);
|
||||||
assert.strictEqual(usersShowResponse.body.securityKeys, false);
|
assert.strictEqual(usersShowResponse.body.securityKeys, false);
|
||||||
|
|
||||||
const signinResponse = await api('/signin', {
|
const signinResponse = await api('/signin', {
|
||||||
...signinParam(),
|
...signinParam(),
|
||||||
token: otpToken(registerResponse.body.secret),
|
token: otpToken(registerResponse.body.secret),
|
||||||
});
|
});
|
||||||
assert.strictEqual(signinResponse.status, 200);
|
assert.strictEqual(signinResponse.status, 200);
|
||||||
assert.notEqual(signinResponse.body.i, undefined);
|
assert.notEqual(signinResponse.body.i, undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('が設定でき、設定解除できる。(パスワードのみでログインできる。)', async () => {
|
test('が設定でき、設定解除できる。(パスワードのみでログインできる。)', async () => {
|
||||||
const registerResponse = await api('/i/2fa/register', {
|
const registerResponse = await api('/i/2fa/register', {
|
||||||
password,
|
password,
|
||||||
|
@ -418,7 +419,7 @@ describe('2要素認証', () => {
|
||||||
token: otpToken(registerResponse.body.secret),
|
token: otpToken(registerResponse.body.secret),
|
||||||
}, alice);
|
}, alice);
|
||||||
assert.strictEqual(doneResponse.status, 204);
|
assert.strictEqual(doneResponse.status, 204);
|
||||||
|
|
||||||
const usersShowResponse = await api('/users/show', {
|
const usersShowResponse = await api('/users/show', {
|
||||||
username,
|
username,
|
||||||
});
|
});
|
||||||
|
|
|
@ -32,7 +32,7 @@ describe('アンテナ', () => {
|
||||||
// - srcのenumにgroupが残っている
|
// - srcのenumにgroupが残っている
|
||||||
// - userGroupIdが残っている, isActiveがない
|
// - userGroupIdが残っている, isActiveがない
|
||||||
type Antenna = misskey.entities.Antenna | Packed<'Antenna'>;
|
type Antenna = misskey.entities.Antenna | Packed<'Antenna'>;
|
||||||
type User = misskey.entities.MeDetailed & { token: string };
|
type User = misskey.entities.MeSignup;
|
||||||
type Note = misskey.entities.Note;
|
type Note = misskey.entities.Note;
|
||||||
|
|
||||||
// アンテナを作成できる最小のパラメタ
|
// アンテナを作成できる最小のパラメタ
|
||||||
|
|
|
@ -3,6 +3,7 @@ process.env.NODE_ENV = 'test';
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import { signup, api, post, startServer } from '../utils.js';
|
import { signup, api, post, startServer } from '../utils.js';
|
||||||
import type { INestApplicationContext } from '@nestjs/common';
|
import type { INestApplicationContext } from '@nestjs/common';
|
||||||
|
import type * as misskey from 'misskey-js';
|
||||||
|
|
||||||
describe('API visibility', () => {
|
describe('API visibility', () => {
|
||||||
let app: INestApplicationContext;
|
let app: INestApplicationContext;
|
||||||
|
@ -18,15 +19,15 @@ describe('API visibility', () => {
|
||||||
describe('Note visibility', () => {
|
describe('Note visibility', () => {
|
||||||
//#region vars
|
//#region vars
|
||||||
/** ヒロイン */
|
/** ヒロイン */
|
||||||
let alice: any;
|
let alice: misskey.entities.MeSignup;
|
||||||
/** フォロワー */
|
/** フォロワー */
|
||||||
let follower: any;
|
let follower: misskey.entities.MeSignup;
|
||||||
/** 非フォロワー */
|
/** 非フォロワー */
|
||||||
let other: any;
|
let other: misskey.entities.MeSignup;
|
||||||
/** 非フォロワーでもリプライやメンションをされた人 */
|
/** 非フォロワーでもリプライやメンションをされた人 */
|
||||||
let target: any;
|
let target: misskey.entities.MeSignup;
|
||||||
/** specified mentionでmentionを飛ばされる人 */
|
/** specified mentionでmentionを飛ばされる人 */
|
||||||
let target2: any;
|
let target2: misskey.entities.MeSignup;
|
||||||
|
|
||||||
/** public-post */
|
/** public-post */
|
||||||
let pub: any;
|
let pub: any;
|
||||||
|
|
|
@ -3,12 +3,13 @@ process.env.NODE_ENV = 'test';
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import { signup, api, startServer } from '../utils.js';
|
import { signup, api, startServer } from '../utils.js';
|
||||||
import type { INestApplicationContext } from '@nestjs/common';
|
import type { INestApplicationContext } from '@nestjs/common';
|
||||||
|
import type * as misskey from 'misskey-js';
|
||||||
|
|
||||||
describe('API', () => {
|
describe('API', () => {
|
||||||
let app: INestApplicationContext;
|
let app: INestApplicationContext;
|
||||||
let alice: any;
|
let alice: misskey.entities.MeSignup;
|
||||||
let bob: any;
|
let bob: misskey.entities.MeSignup;
|
||||||
let carol: any;
|
let carol: misskey.entities.MeSignup;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
app = await startServer();
|
app = await startServer();
|
||||||
|
|
|
@ -3,14 +3,15 @@ process.env.NODE_ENV = 'test';
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import { signup, api, post, startServer } from '../utils.js';
|
import { signup, api, post, startServer } from '../utils.js';
|
||||||
import type { INestApplicationContext } from '@nestjs/common';
|
import type { INestApplicationContext } from '@nestjs/common';
|
||||||
|
import type * as misskey from 'misskey-js';
|
||||||
|
|
||||||
describe('Block', () => {
|
describe('Block', () => {
|
||||||
let app: INestApplicationContext;
|
let app: INestApplicationContext;
|
||||||
|
|
||||||
// alice blocks bob
|
// alice blocks bob
|
||||||
let alice: any;
|
let alice: misskey.entities.MeSignup;
|
||||||
let bob: any;
|
let bob: misskey.entities.MeSignup;
|
||||||
let carol: any;
|
let carol: misskey.entities.MeSignup;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
app = await startServer();
|
app = await startServer();
|
||||||
|
|
|
@ -13,12 +13,12 @@ import { paramDef as UnfavoriteParamDef } from '@/server/api/endpoints/clips/unf
|
||||||
import { paramDef as AddNoteParamDef } from '@/server/api/endpoints/clips/add-note.js';
|
import { paramDef as AddNoteParamDef } from '@/server/api/endpoints/clips/add-note.js';
|
||||||
import { paramDef as RemoveNoteParamDef } from '@/server/api/endpoints/clips/remove-note.js';
|
import { paramDef as RemoveNoteParamDef } from '@/server/api/endpoints/clips/remove-note.js';
|
||||||
import { paramDef as NotesParamDef } from '@/server/api/endpoints/clips/notes.js';
|
import { paramDef as NotesParamDef } from '@/server/api/endpoints/clips/notes.js';
|
||||||
import {
|
import {
|
||||||
signup,
|
signup,
|
||||||
post,
|
post,
|
||||||
startServer,
|
startServer,
|
||||||
api,
|
api,
|
||||||
successfulApiCall,
|
successfulApiCall,
|
||||||
failedApiCall,
|
failedApiCall,
|
||||||
ApiRequest,
|
ApiRequest,
|
||||||
hiddenNote,
|
hiddenNote,
|
||||||
|
@ -82,14 +82,14 @@ describe('クリップ', () => {
|
||||||
const update = async (parameters: Partial<UpdateParam>, request: Partial<ApiRequest> = {}): Promise<Clip> => {
|
const update = async (parameters: Partial<UpdateParam>, request: Partial<ApiRequest> = {}): Promise<Clip> => {
|
||||||
const clip = await successfulApiCall<Clip>({
|
const clip = await successfulApiCall<Clip>({
|
||||||
endpoint: '/clips/update',
|
endpoint: '/clips/update',
|
||||||
parameters: {
|
parameters: {
|
||||||
name: 'updated',
|
name: 'updated',
|
||||||
...parameters,
|
...parameters,
|
||||||
},
|
},
|
||||||
user: alice,
|
user: alice,
|
||||||
...request,
|
...request,
|
||||||
});
|
});
|
||||||
|
|
||||||
// 入力が結果として入っていること。clipIdはidになるので消しておく
|
// 入力が結果として入っていること。clipIdはidになるので消しておく
|
||||||
delete (parameters as { clipId?: string }).clipId;
|
delete (parameters as { clipId?: string }).clipId;
|
||||||
assert.deepStrictEqual(clip, {
|
assert.deepStrictEqual(clip, {
|
||||||
|
@ -98,7 +98,7 @@ describe('クリップ', () => {
|
||||||
});
|
});
|
||||||
return clip;
|
return clip;
|
||||||
};
|
};
|
||||||
|
|
||||||
type DeleteParam = JTDDataType<typeof DeleteParamDef>;
|
type DeleteParam = JTDDataType<typeof DeleteParamDef>;
|
||||||
const deleteClip = async (parameters: DeleteParam, request: Partial<ApiRequest> = {}): Promise<void> => {
|
const deleteClip = async (parameters: DeleteParam, request: Partial<ApiRequest> = {}): Promise<void> => {
|
||||||
return await successfulApiCall<void>({
|
return await successfulApiCall<void>({
|
||||||
|
@ -129,7 +129,7 @@ describe('クリップ', () => {
|
||||||
...request,
|
...request,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const usersClips = async (request: Partial<ApiRequest>): Promise<Clip[]> => {
|
const usersClips = async (request: Partial<ApiRequest>): Promise<Clip[]> => {
|
||||||
return await successfulApiCall<Clip[]>({
|
return await successfulApiCall<Clip[]>({
|
||||||
endpoint: '/users/clips',
|
endpoint: '/users/clips',
|
||||||
|
@ -145,14 +145,14 @@ describe('クリップ', () => {
|
||||||
bob = await signup({ username: 'bob' });
|
bob = await signup({ username: 'bob' });
|
||||||
|
|
||||||
// FIXME: misskey-jsのNoteはoutdatedなので直接変換できない
|
// FIXME: misskey-jsのNoteはoutdatedなので直接変換できない
|
||||||
aliceNote = await post(alice, { text: 'test' }) as any;
|
aliceNote = await post(alice, { text: 'test' }) as any;
|
||||||
aliceHomeNote = await post(alice, { text: 'home only', visibility: 'home' }) as any;
|
aliceHomeNote = await post(alice, { text: 'home only', visibility: 'home' }) as any;
|
||||||
aliceFollowersNote = await post(alice, { text: 'followers only', visibility: 'followers' }) as any;
|
aliceFollowersNote = await post(alice, { text: 'followers only', visibility: 'followers' }) as any;
|
||||||
aliceSpecifiedNote = await post(alice, { text: 'specified only', visibility: 'specified' }) as any;
|
aliceSpecifiedNote = await post(alice, { text: 'specified only', visibility: 'specified' }) as any;
|
||||||
bobNote = await post(bob, { text: 'test' }) as any;
|
bobNote = await post(bob, { text: 'test' }) as any;
|
||||||
bobHomeNote = await post(bob, { text: 'home only', visibility: 'home' }) as any;
|
bobHomeNote = await post(bob, { text: 'home only', visibility: 'home' }) as any;
|
||||||
bobFollowersNote = await post(bob, { text: 'followers only', visibility: 'followers' }) as any;
|
bobFollowersNote = await post(bob, { text: 'followers only', visibility: 'followers' }) as any;
|
||||||
bobSpecifiedNote = await post(bob, { text: 'specified only', visibility: 'specified' }) as any;
|
bobSpecifiedNote = await post(bob, { text: 'specified only', visibility: 'specified' }) as any;
|
||||||
}, 1000 * 60 * 2);
|
}, 1000 * 60 * 2);
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
|
@ -172,7 +172,7 @@ describe('クリップ', () => {
|
||||||
test('の作成ができる', async () => {
|
test('の作成ができる', async () => {
|
||||||
const res = await create();
|
const res = await create();
|
||||||
// ISO 8601で日付が返ってくること
|
// ISO 8601で日付が返ってくること
|
||||||
assert.strictEqual(res.createdAt, new Date(res.createdAt).toISOString());
|
assert.strictEqual(res.createdAt, new Date(res.createdAt).toISOString());
|
||||||
assert.strictEqual(res.lastClippedAt, null);
|
assert.strictEqual(res.lastClippedAt, null);
|
||||||
assert.strictEqual(res.name, 'test');
|
assert.strictEqual(res.name, 'test');
|
||||||
assert.strictEqual(res.description, null);
|
assert.strictEqual(res.description, null);
|
||||||
|
@ -217,7 +217,7 @@ describe('クリップ', () => {
|
||||||
];
|
];
|
||||||
test.each(createClipDenyPattern)('の作成は$labelならできない', async ({ parameters }) => failedApiCall({
|
test.each(createClipDenyPattern)('の作成は$labelならできない', async ({ parameters }) => failedApiCall({
|
||||||
endpoint: '/clips/create',
|
endpoint: '/clips/create',
|
||||||
parameters: {
|
parameters: {
|
||||||
...defaultCreate(),
|
...defaultCreate(),
|
||||||
...parameters,
|
...parameters,
|
||||||
},
|
},
|
||||||
|
@ -229,7 +229,7 @@ describe('クリップ', () => {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
test('の更新ができる', async () => {
|
test('の更新ができる', async () => {
|
||||||
const res = await update({
|
const res = await update({
|
||||||
clipId: (await create()).id,
|
clipId: (await create()).id,
|
||||||
name: 'updated',
|
name: 'updated',
|
||||||
description: 'new description',
|
description: 'new description',
|
||||||
|
@ -237,7 +237,7 @@ describe('クリップ', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
// ISO 8601で日付が返ってくること
|
// ISO 8601で日付が返ってくること
|
||||||
assert.strictEqual(res.createdAt, new Date(res.createdAt).toISOString());
|
assert.strictEqual(res.createdAt, new Date(res.createdAt).toISOString());
|
||||||
assert.strictEqual(res.lastClippedAt, null);
|
assert.strictEqual(res.lastClippedAt, null);
|
||||||
assert.strictEqual(res.name, 'updated');
|
assert.strictEqual(res.name, 'updated');
|
||||||
assert.strictEqual(res.description, 'new description');
|
assert.strictEqual(res.description, 'new description');
|
||||||
|
@ -251,7 +251,7 @@ describe('クリップ', () => {
|
||||||
name: 'updated',
|
name: 'updated',
|
||||||
...parameters,
|
...parameters,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
test.each([
|
test.each([
|
||||||
{ label: 'clipIdがnull', parameters: { clipId: null } },
|
{ label: 'clipIdがnull', parameters: { clipId: null } },
|
||||||
{ label: '存在しないクリップ', parameters: { clipId: 'xxxxxx' }, assertion: {
|
{ label: '存在しないクリップ', parameters: { clipId: 'xxxxxx' }, assertion: {
|
||||||
|
@ -265,7 +265,7 @@ describe('クリップ', () => {
|
||||||
...createClipDenyPattern as any,
|
...createClipDenyPattern as any,
|
||||||
])('の更新は$labelならできない', async ({ parameters, user, assertion }) => failedApiCall({
|
])('の更新は$labelならできない', async ({ parameters, user, assertion }) => failedApiCall({
|
||||||
endpoint: '/clips/update',
|
endpoint: '/clips/update',
|
||||||
parameters: {
|
parameters: {
|
||||||
clipId: (await create({}, { user: (user ?? ((): User => alice))() })).id,
|
clipId: (await create({}, { user: (user ?? ((): User => alice))() })).id,
|
||||||
name: 'updated',
|
name: 'updated',
|
||||||
...parameters,
|
...parameters,
|
||||||
|
@ -279,7 +279,7 @@ describe('クリップ', () => {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
test('の削除ができる', async () => {
|
test('の削除ができる', async () => {
|
||||||
await deleteClip({
|
await deleteClip({
|
||||||
clipId: (await create()).id,
|
clipId: (await create()).id,
|
||||||
});
|
});
|
||||||
assert.deepStrictEqual(await list({}), []);
|
assert.deepStrictEqual(await list({}), []);
|
||||||
|
@ -297,7 +297,7 @@ describe('クリップ', () => {
|
||||||
} },
|
} },
|
||||||
])('の削除は$labelならできない', async ({ parameters, user, assertion }) => failedApiCall({
|
])('の削除は$labelならできない', async ({ parameters, user, assertion }) => failedApiCall({
|
||||||
endpoint: '/clips/delete',
|
endpoint: '/clips/delete',
|
||||||
parameters: {
|
parameters: {
|
||||||
clipId: (await create({}, { user: (user ?? ((): User => alice))() })).id,
|
clipId: (await create({}, { user: (user ?? ((): User => alice))() })).id,
|
||||||
...parameters,
|
...parameters,
|
||||||
},
|
},
|
||||||
|
@ -329,14 +329,14 @@ describe('クリップ', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([
|
test.each([
|
||||||
{ label: 'clipId未指定', parameters: { clipId: undefined } },
|
{ label: 'clipId未指定', parameters: { clipId: undefined } },
|
||||||
{ label: '存在しないクリップ', parameters: { clipId: 'xxxxxx' }, assetion: {
|
{ label: '存在しないクリップ', parameters: { clipId: 'xxxxxx' }, assetion: {
|
||||||
code: 'NO_SUCH_CLIP',
|
code: 'NO_SUCH_CLIP',
|
||||||
id: 'c3c5fe33-d62c-44d2-9ea5-d997703f5c20',
|
id: 'c3c5fe33-d62c-44d2-9ea5-d997703f5c20',
|
||||||
} },
|
} },
|
||||||
])('のID指定取得は$labelならできない', async ({ parameters, assetion }) => failedApiCall({
|
])('のID指定取得は$labelならできない', async ({ parameters, assetion }) => failedApiCall({
|
||||||
endpoint: '/clips/show',
|
endpoint: '/clips/show',
|
||||||
parameters: {
|
parameters: {
|
||||||
...parameters,
|
...parameters,
|
||||||
},
|
},
|
||||||
user: alice,
|
user: alice,
|
||||||
|
@ -361,14 +361,14 @@ describe('クリップ', () => {
|
||||||
|
|
||||||
// 返ってくる配列には順序保障がないのでidでソートして厳密比較
|
// 返ってくる配列には順序保障がないのでidでソートして厳密比較
|
||||||
assert.deepStrictEqual(
|
assert.deepStrictEqual(
|
||||||
res.sort(compareBy(s => s.id)),
|
res.sort(compareBy(s => s.id)),
|
||||||
clips.sort(compareBy(s => s.id)),
|
clips.sort(compareBy(s => s.id)),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('の一覧が取得できる(空)', async () => {
|
test('の一覧が取得できる(空)', async () => {
|
||||||
const res = await usersClips({
|
const res = await usersClips({
|
||||||
parameters: {
|
parameters: {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -381,14 +381,14 @@ describe('クリップ', () => {
|
||||||
])('の一覧が$label取得できる', async () => {
|
])('の一覧が$label取得できる', async () => {
|
||||||
const clips = await createMany({ isPublic: true });
|
const clips = await createMany({ isPublic: true });
|
||||||
const res = await usersClips({
|
const res = await usersClips({
|
||||||
parameters: {
|
parameters: {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// 返ってくる配列には順序保障がないのでidでソートして厳密比較
|
// 返ってくる配列には順序保障がないのでidでソートして厳密比較
|
||||||
assert.deepStrictEqual(
|
assert.deepStrictEqual(
|
||||||
res.sort(compareBy<Clip>(s => s.id)),
|
res.sort(compareBy<Clip>(s => s.id)),
|
||||||
clips.sort(compareBy(s => s.id)));
|
clips.sort(compareBy(s => s.id)));
|
||||||
|
|
||||||
// 認証状態で見たときだけisFavoritedが入っている
|
// 認証状態で見たときだけisFavoritedが入っている
|
||||||
|
@ -421,7 +421,7 @@ describe('クリップ', () => {
|
||||||
await create({ isPublic: false });
|
await create({ isPublic: false });
|
||||||
const aliceClip = await create({ isPublic: true });
|
const aliceClip = await create({ isPublic: true });
|
||||||
const res = await usersClips({
|
const res = await usersClips({
|
||||||
parameters: {
|
parameters: {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
limit: 2,
|
limit: 2,
|
||||||
},
|
},
|
||||||
|
@ -433,7 +433,7 @@ describe('クリップ', () => {
|
||||||
const clips = await createMany({ isPublic: true }, 7);
|
const clips = await createMany({ isPublic: true }, 7);
|
||||||
clips.sort(compareBy(s => s.id));
|
clips.sort(compareBy(s => s.id));
|
||||||
const res = await usersClips({
|
const res = await usersClips({
|
||||||
parameters: {
|
parameters: {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
sinceId: clips[1].id,
|
sinceId: clips[1].id,
|
||||||
untilId: clips[5].id,
|
untilId: clips[5].id,
|
||||||
|
@ -443,7 +443,7 @@ describe('クリップ', () => {
|
||||||
|
|
||||||
// Promise.allで返ってくる配列には順序保障がないのでidでソートして厳密比較
|
// Promise.allで返ってくる配列には順序保障がないのでidでソートして厳密比較
|
||||||
assert.deepStrictEqual(
|
assert.deepStrictEqual(
|
||||||
res.sort(compareBy<Clip>(s => s.id)),
|
res.sort(compareBy<Clip>(s => s.id)),
|
||||||
[clips[2], clips[3], clips[4]], // sinceIdとuntilId自体は結果に含まれない
|
[clips[2], clips[3], clips[4]], // sinceIdとuntilId自体は結果に含まれない
|
||||||
clips[1].id + ' ... ' + clips[3].id + ' with ' + clips.map(s => s.id) + ' vs. ' + res.map(s => s.id));
|
clips[1].id + ' ... ' + clips[3].id + ' with ' + clips.map(s => s.id) + ' vs. ' + res.map(s => s.id));
|
||||||
});
|
});
|
||||||
|
@ -454,7 +454,7 @@ describe('クリップ', () => {
|
||||||
{ label: 'limit最大+1', parameters: { limit: 101 } },
|
{ label: 'limit最大+1', parameters: { limit: 101 } },
|
||||||
])('の一覧は$labelだと取得できない', async ({ parameters }) => failedApiCall({
|
])('の一覧は$labelだと取得できない', async ({ parameters }) => failedApiCall({
|
||||||
endpoint: '/users/clips',
|
endpoint: '/users/clips',
|
||||||
parameters: {
|
parameters: {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
...parameters,
|
...parameters,
|
||||||
},
|
},
|
||||||
|
@ -520,7 +520,7 @@ describe('クリップ', () => {
|
||||||
...request,
|
...request,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
aliceClip = await create();
|
aliceClip = await create();
|
||||||
});
|
});
|
||||||
|
@ -544,7 +544,7 @@ describe('クリップ', () => {
|
||||||
assert.strictEqual(clip2.favoritedCount, 1);
|
assert.strictEqual(clip2.favoritedCount, 1);
|
||||||
assert.strictEqual(clip2.isFavorited, false);
|
assert.strictEqual(clip2.isFavorited, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('は1つのクリップに対して複数人が設定できる。', async () => {
|
test('は1つのクリップに対して複数人が設定できる。', async () => {
|
||||||
const publicClip = await create({ isPublic: true });
|
const publicClip = await create({ isPublic: true });
|
||||||
await favorite({ clipId: publicClip.id }, { user: bob });
|
await favorite({ clipId: publicClip.id }, { user: bob });
|
||||||
|
@ -552,7 +552,7 @@ describe('クリップ', () => {
|
||||||
const clip = await show({ clipId: publicClip.id }, { user: bob });
|
const clip = await show({ clipId: publicClip.id }, { user: bob });
|
||||||
assert.strictEqual(clip.favoritedCount, 2);
|
assert.strictEqual(clip.favoritedCount, 2);
|
||||||
assert.strictEqual(clip.isFavorited, true);
|
assert.strictEqual(clip.isFavorited, true);
|
||||||
|
|
||||||
const clip2 = await show({ clipId: publicClip.id });
|
const clip2 = await show({ clipId: publicClip.id });
|
||||||
assert.strictEqual(clip2.favoritedCount, 2);
|
assert.strictEqual(clip2.favoritedCount, 2);
|
||||||
assert.strictEqual(clip2.isFavorited, true);
|
assert.strictEqual(clip2.isFavorited, true);
|
||||||
|
@ -581,7 +581,7 @@ describe('クリップ', () => {
|
||||||
await favorite({ clipId: aliceClip.id });
|
await favorite({ clipId: aliceClip.id });
|
||||||
await failedApiCall({
|
await failedApiCall({
|
||||||
endpoint: '/clips/favorite',
|
endpoint: '/clips/favorite',
|
||||||
parameters: {
|
parameters: {
|
||||||
clipId: aliceClip.id,
|
clipId: aliceClip.id,
|
||||||
},
|
},
|
||||||
user: alice,
|
user: alice,
|
||||||
|
@ -604,7 +604,7 @@ describe('クリップ', () => {
|
||||||
} },
|
} },
|
||||||
])('の設定は$labelならできない', async ({ parameters, user, assertion }) => failedApiCall({
|
])('の設定は$labelならできない', async ({ parameters, user, assertion }) => failedApiCall({
|
||||||
endpoint: '/clips/favorite',
|
endpoint: '/clips/favorite',
|
||||||
parameters: {
|
parameters: {
|
||||||
clipId: (await create({}, { user: (user ?? ((): User => alice))() })).id,
|
clipId: (await create({}, { user: (user ?? ((): User => alice))() })).id,
|
||||||
...parameters,
|
...parameters,
|
||||||
},
|
},
|
||||||
|
@ -615,7 +615,7 @@ describe('クリップ', () => {
|
||||||
id: '3d81ceae-475f-4600-b2a8-2bc116157532',
|
id: '3d81ceae-475f-4600-b2a8-2bc116157532',
|
||||||
...assertion,
|
...assertion,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
test('を設定解除できる。', async () => {
|
test('を設定解除できる。', async () => {
|
||||||
await favorite({ clipId: aliceClip.id });
|
await favorite({ clipId: aliceClip.id });
|
||||||
await unfavorite({ clipId: aliceClip.id });
|
await unfavorite({ clipId: aliceClip.id });
|
||||||
|
@ -641,7 +641,7 @@ describe('クリップ', () => {
|
||||||
} },
|
} },
|
||||||
])('の設定解除は$labelならできない', async ({ parameters, user, assertion }) => failedApiCall({
|
])('の設定解除は$labelならできない', async ({ parameters, user, assertion }) => failedApiCall({
|
||||||
endpoint: '/clips/unfavorite',
|
endpoint: '/clips/unfavorite',
|
||||||
parameters: {
|
parameters: {
|
||||||
clipId: (await create({}, { user: (user ?? ((): User => alice))() })).id,
|
clipId: (await create({}, { user: (user ?? ((): User => alice))() })).id,
|
||||||
...parameters,
|
...parameters,
|
||||||
},
|
},
|
||||||
|
@ -652,7 +652,7 @@ describe('クリップ', () => {
|
||||||
id: '3d81ceae-475f-4600-b2a8-2bc116157532',
|
id: '3d81ceae-475f-4600-b2a8-2bc116157532',
|
||||||
...assertion,
|
...assertion,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
test('を取得できる。', async () => {
|
test('を取得できる。', async () => {
|
||||||
await favorite({ clipId: aliceClip.id });
|
await favorite({ clipId: aliceClip.id });
|
||||||
const favorited = await myFavorites();
|
const favorited = await myFavorites();
|
||||||
|
@ -717,7 +717,7 @@ describe('クリップ', () => {
|
||||||
const res = await show({ clipId: aliceClip.id });
|
const res = await show({ clipId: aliceClip.id });
|
||||||
assert.strictEqual(res.lastClippedAt, new Date(res.lastClippedAt ?? '').toISOString());
|
assert.strictEqual(res.lastClippedAt, new Date(res.lastClippedAt ?? '').toISOString());
|
||||||
assert.deepStrictEqual(await notes({ clipId: aliceClip.id }), [aliceNote]);
|
assert.deepStrictEqual(await notes({ clipId: aliceClip.id }), [aliceNote]);
|
||||||
|
|
||||||
// 他人の非公開ノートも突っ込める
|
// 他人の非公開ノートも突っ込める
|
||||||
await addNote({ clipId: aliceClip.id, noteId: bobHomeNote.id });
|
await addNote({ clipId: aliceClip.id, noteId: bobHomeNote.id });
|
||||||
await addNote({ clipId: aliceClip.id, noteId: bobFollowersNote.id });
|
await addNote({ clipId: aliceClip.id, noteId: bobFollowersNote.id });
|
||||||
|
@ -728,7 +728,7 @@ describe('クリップ', () => {
|
||||||
await addNote({ clipId: aliceClip.id, noteId: aliceNote.id });
|
await addNote({ clipId: aliceClip.id, noteId: aliceNote.id });
|
||||||
await failedApiCall({
|
await failedApiCall({
|
||||||
endpoint: '/clips/add-note',
|
endpoint: '/clips/add-note',
|
||||||
parameters: {
|
parameters: {
|
||||||
clipId: aliceClip.id,
|
clipId: aliceClip.id,
|
||||||
noteId: aliceNote.id,
|
noteId: aliceNote.id,
|
||||||
},
|
},
|
||||||
|
@ -747,10 +747,10 @@ describe('クリップ', () => {
|
||||||
text: `test ${i}`,
|
text: `test ${i}`,
|
||||||
}) as unknown)) as Note[];
|
}) as unknown)) as Note[];
|
||||||
await Promise.all(noteList.map(s => addNote({ clipId: aliceClip.id, noteId: s.id })));
|
await Promise.all(noteList.map(s => addNote({ clipId: aliceClip.id, noteId: s.id })));
|
||||||
|
|
||||||
await failedApiCall({
|
await failedApiCall({
|
||||||
endpoint: '/clips/add-note',
|
endpoint: '/clips/add-note',
|
||||||
parameters: {
|
parameters: {
|
||||||
clipId: aliceClip.id,
|
clipId: aliceClip.id,
|
||||||
noteId: aliceNote.id,
|
noteId: aliceNote.id,
|
||||||
},
|
},
|
||||||
|
@ -764,7 +764,7 @@ describe('クリップ', () => {
|
||||||
|
|
||||||
test('は他人のクリップへ追加できない。', async () => await failedApiCall({
|
test('は他人のクリップへ追加できない。', async () => await failedApiCall({
|
||||||
endpoint: '/clips/add-note',
|
endpoint: '/clips/add-note',
|
||||||
parameters: {
|
parameters: {
|
||||||
clipId: aliceClip.id,
|
clipId: aliceClip.id,
|
||||||
noteId: aliceNote.id,
|
noteId: aliceNote.id,
|
||||||
},
|
},
|
||||||
|
@ -776,9 +776,9 @@ describe('クリップ', () => {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
test.each([
|
test.each([
|
||||||
{ label: 'clipId未指定', parameters: { clipId: undefined } },
|
{ label: 'clipId未指定', parameters: { clipId: undefined } },
|
||||||
{ label: 'noteId未指定', parameters: { noteId: undefined } },
|
{ label: 'noteId未指定', parameters: { noteId: undefined } },
|
||||||
{ label: '存在しないクリップ', parameters: { clipId: 'xxxxxx' }, assetion: {
|
{ label: '存在しないクリップ', parameters: { clipId: 'xxxxxx' }, assetion: {
|
||||||
code: 'NO_SUCH_CLIP',
|
code: 'NO_SUCH_CLIP',
|
||||||
id: 'd6e76cc0-a1b5-4c7c-a287-73fa9c716dcf',
|
id: 'd6e76cc0-a1b5-4c7c-a287-73fa9c716dcf',
|
||||||
} },
|
} },
|
||||||
|
@ -792,7 +792,7 @@ describe('クリップ', () => {
|
||||||
} },
|
} },
|
||||||
])('の追加は$labelだとできない', async ({ parameters, user, assetion }) => failedApiCall({
|
])('の追加は$labelだとできない', async ({ parameters, user, assetion }) => failedApiCall({
|
||||||
endpoint: '/clips/add-note',
|
endpoint: '/clips/add-note',
|
||||||
parameters: {
|
parameters: {
|
||||||
clipId: aliceClip.id,
|
clipId: aliceClip.id,
|
||||||
noteId: aliceNote.id,
|
noteId: aliceNote.id,
|
||||||
...parameters,
|
...parameters,
|
||||||
|
@ -810,11 +810,11 @@ describe('クリップ', () => {
|
||||||
await removeNote({ clipId: aliceClip.id, noteId: aliceNote.id });
|
await removeNote({ clipId: aliceClip.id, noteId: aliceNote.id });
|
||||||
assert.deepStrictEqual(await notes({ clipId: aliceClip.id }), []);
|
assert.deepStrictEqual(await notes({ clipId: aliceClip.id }), []);
|
||||||
});
|
});
|
||||||
|
|
||||||
test.each([
|
test.each([
|
||||||
{ label: 'clipId未指定', parameters: { clipId: undefined } },
|
{ label: 'clipId未指定', parameters: { clipId: undefined } },
|
||||||
{ label: 'noteId未指定', parameters: { noteId: undefined } },
|
{ label: 'noteId未指定', parameters: { noteId: undefined } },
|
||||||
{ label: '存在しないクリップ', parameters: { clipId: 'xxxxxx' }, assetion: {
|
{ label: '存在しないクリップ', parameters: { clipId: 'xxxxxx' }, assetion: {
|
||||||
code: 'NO_SUCH_CLIP',
|
code: 'NO_SUCH_CLIP',
|
||||||
id: 'b80525c6-97f7-49d7-a42d-ebccd49cfd52', // add-noteと異なる
|
id: 'b80525c6-97f7-49d7-a42d-ebccd49cfd52', // add-noteと異なる
|
||||||
} },
|
} },
|
||||||
|
@ -828,7 +828,7 @@ describe('クリップ', () => {
|
||||||
} },
|
} },
|
||||||
])('の削除は$labelだとできない', async ({ parameters, user, assetion }) => failedApiCall({
|
])('の削除は$labelだとできない', async ({ parameters, user, assetion }) => failedApiCall({
|
||||||
endpoint: '/clips/remove-note',
|
endpoint: '/clips/remove-note',
|
||||||
parameters: {
|
parameters: {
|
||||||
clipId: aliceClip.id,
|
clipId: aliceClip.id,
|
||||||
noteId: aliceNote.id,
|
noteId: aliceNote.id,
|
||||||
...parameters,
|
...parameters,
|
||||||
|
@ -848,12 +848,12 @@ describe('クリップ', () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await notes({ clipId: aliceClip.id });
|
const res = await notes({ clipId: aliceClip.id });
|
||||||
|
|
||||||
// 自分のノートは非公開でも入れられるし、見える
|
// 自分のノートは非公開でも入れられるし、見える
|
||||||
// 他人の非公開ノートは入れられるけど、除外される
|
// 他人の非公開ノートは入れられるけど、除外される
|
||||||
const expects = [
|
const expects = [
|
||||||
aliceNote, aliceHomeNote, aliceFollowersNote, aliceSpecifiedNote,
|
aliceNote, aliceHomeNote, aliceFollowersNote, aliceSpecifiedNote,
|
||||||
bobNote, bobHomeNote,
|
bobNote, bobHomeNote,
|
||||||
];
|
];
|
||||||
assert.deepStrictEqual(
|
assert.deepStrictEqual(
|
||||||
res.sort(compareBy(s => s.id)),
|
res.sort(compareBy(s => s.id)),
|
||||||
|
@ -867,7 +867,7 @@ describe('クリップ', () => {
|
||||||
await addNote({ clipId: aliceClip.id, noteId: note.id });
|
await addNote({ clipId: aliceClip.id, noteId: note.id });
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await notes({
|
const res = await notes({
|
||||||
clipId: aliceClip.id,
|
clipId: aliceClip.id,
|
||||||
sinceId: noteList[2].id,
|
sinceId: noteList[2].id,
|
||||||
limit: 3,
|
limit: 3,
|
||||||
|
@ -892,7 +892,7 @@ describe('クリップ', () => {
|
||||||
sinceId: noteList[1].id,
|
sinceId: noteList[1].id,
|
||||||
untilId: noteList[4].id,
|
untilId: noteList[4].id,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Promise.allで返ってくる配列はID順で並んでないのでソートして厳密比較
|
// Promise.allで返ってくる配列はID順で並んでないのでソートして厳密比較
|
||||||
const expects = [noteList[2], noteList[3]];
|
const expects = [noteList[2], noteList[3]];
|
||||||
assert.deepStrictEqual(
|
assert.deepStrictEqual(
|
||||||
|
@ -918,7 +918,7 @@ describe('クリップ', () => {
|
||||||
|
|
||||||
const res = await notes({ clipId: publicClip.id }, { user: undefined });
|
const res = await notes({ clipId: publicClip.id }, { user: undefined });
|
||||||
const expects = [
|
const expects = [
|
||||||
aliceNote, aliceHomeNote,
|
aliceNote, aliceHomeNote,
|
||||||
// 認証なしだと非公開ノートは結果には含むけどhideされる。
|
// 認証なしだと非公開ノートは結果には含むけどhideされる。
|
||||||
hiddenNote(aliceFollowersNote), hiddenNote(aliceSpecifiedNote),
|
hiddenNote(aliceFollowersNote), hiddenNote(aliceSpecifiedNote),
|
||||||
];
|
];
|
||||||
|
@ -926,7 +926,7 @@ describe('クリップ', () => {
|
||||||
res.sort(compareBy(s => s.id)),
|
res.sort(compareBy(s => s.id)),
|
||||||
expects.sort(compareBy(s => s.id)));
|
expects.sort(compareBy(s => s.id)));
|
||||||
});
|
});
|
||||||
|
|
||||||
test.todo('ブロック、ミュートされたユーザーからの設定&取得etc.');
|
test.todo('ブロック、ミュートされたユーザーからの設定&取得etc.');
|
||||||
|
|
||||||
test.each([
|
test.each([
|
||||||
|
@ -947,7 +947,7 @@ describe('クリップ', () => {
|
||||||
} },
|
} },
|
||||||
])('は$labelだと取得できない', async ({ parameters, user, assertion }) => failedApiCall({
|
])('は$labelだと取得できない', async ({ parameters, user, assertion }) => failedApiCall({
|
||||||
endpoint: '/clips/notes',
|
endpoint: '/clips/notes',
|
||||||
parameters: {
|
parameters: {
|
||||||
clipId: aliceClip.id,
|
clipId: aliceClip.id,
|
||||||
...parameters,
|
...parameters,
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,17 +4,18 @@ import * as assert from 'assert';
|
||||||
// node-fetch only supports it's own Blob yet
|
// node-fetch only supports it's own Blob yet
|
||||||
// https://github.com/node-fetch/node-fetch/pull/1664
|
// https://github.com/node-fetch/node-fetch/pull/1664
|
||||||
import { Blob } from 'node-fetch';
|
import { Blob } from 'node-fetch';
|
||||||
|
import { User } from '@/models/index.js';
|
||||||
import { startServer, signup, post, api, uploadFile, simpleGet, initTestDb } from '../utils.js';
|
import { startServer, signup, post, api, uploadFile, simpleGet, initTestDb } from '../utils.js';
|
||||||
import type { INestApplicationContext } from '@nestjs/common';
|
import type { INestApplicationContext } from '@nestjs/common';
|
||||||
import { User } from '@/models/index.js';
|
import type * as misskey from 'misskey-js';
|
||||||
|
|
||||||
describe('Endpoints', () => {
|
describe('Endpoints', () => {
|
||||||
let app: INestApplicationContext;
|
let app: INestApplicationContext;
|
||||||
|
|
||||||
let alice: any;
|
let alice: misskey.entities.MeSignup;
|
||||||
let bob: any;
|
let bob: misskey.entities.MeSignup;
|
||||||
let carol: any;
|
let carol: misskey.entities.MeSignup;
|
||||||
let dave: any;
|
let dave: misskey.entities.MeSignup;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
app = await startServer();
|
app = await startServer();
|
||||||
|
|
|
@ -4,6 +4,7 @@ import * as assert from 'assert';
|
||||||
import { startServer, channel, clip, cookie, galleryPost, signup, page, play, post, simpleGet, uploadFile } from '../utils.js';
|
import { startServer, channel, clip, cookie, galleryPost, signup, page, play, post, simpleGet, uploadFile } from '../utils.js';
|
||||||
import type { SimpleGetResponse } from '../utils.js';
|
import type { SimpleGetResponse } from '../utils.js';
|
||||||
import type { INestApplicationContext } from '@nestjs/common';
|
import type { INestApplicationContext } from '@nestjs/common';
|
||||||
|
import type * as misskey from 'misskey-js';
|
||||||
|
|
||||||
// Request Accept
|
// Request Accept
|
||||||
const ONLY_AP = 'application/activity+json';
|
const ONLY_AP = 'application/activity+json';
|
||||||
|
@ -19,7 +20,7 @@ const JSON_UTF8 = 'application/json; charset=utf-8';
|
||||||
describe('Webリソース', () => {
|
describe('Webリソース', () => {
|
||||||
let app: INestApplicationContext;
|
let app: INestApplicationContext;
|
||||||
|
|
||||||
let alice: any;
|
let alice: misskey.entities.MeSignup;
|
||||||
let aliceUploadedFile: any;
|
let aliceUploadedFile: any;
|
||||||
let alicesPost: any;
|
let alicesPost: any;
|
||||||
let alicePage: any;
|
let alicePage: any;
|
||||||
|
@ -28,8 +29,8 @@ describe('Webリソース', () => {
|
||||||
let aliceGalleryPost: any;
|
let aliceGalleryPost: any;
|
||||||
let aliceChannel: any;
|
let aliceChannel: any;
|
||||||
|
|
||||||
type Request = {
|
type Request = {
|
||||||
path: string,
|
path: string,
|
||||||
accept?: string,
|
accept?: string,
|
||||||
cookie?: string,
|
cookie?: string,
|
||||||
};
|
};
|
||||||
|
@ -46,7 +47,7 @@ describe('Webリソース', () => {
|
||||||
const notOk = async (param: Request & {
|
const notOk = async (param: Request & {
|
||||||
status?: number,
|
status?: number,
|
||||||
code?: string,
|
code?: string,
|
||||||
}): Promise<SimpleGetResponse> => {
|
}): Promise<SimpleGetResponse> => {
|
||||||
const { path, accept, cookie, status, code } = param;
|
const { path, accept, cookie, status, code } = param;
|
||||||
const res = await simpleGet(path, accept, cookie);
|
const res = await simpleGet(path, accept, cookie);
|
||||||
assert.notStrictEqual(res.status, 200);
|
assert.notStrictEqual(res.status, 200);
|
||||||
|
@ -58,8 +59,8 @@ describe('Webリソース', () => {
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
const notFound = async (param: Request): Promise<SimpleGetResponse> => {
|
const notFound = async (param: Request): Promise<SimpleGetResponse> => {
|
||||||
return await notOk({
|
return await notOk({
|
||||||
...param,
|
...param,
|
||||||
status: 404,
|
status: 404,
|
||||||
|
@ -94,23 +95,23 @@ describe('Webリソース', () => {
|
||||||
{ path: '/', type: HTML },
|
{ path: '/', type: HTML },
|
||||||
{ path: '/docs/ja-JP/about', type: HTML }, // "指定されたURLに該当するページはありませんでした。"
|
{ path: '/docs/ja-JP/about', type: HTML }, // "指定されたURLに該当するページはありませんでした。"
|
||||||
// fastify-static gives charset=UTF-8 instead of utf-8 and that's okay
|
// fastify-static gives charset=UTF-8 instead of utf-8 and that's okay
|
||||||
{ path: '/api-doc', type: 'text/html; charset=UTF-8' },
|
{ path: '/api-doc', type: 'text/html; charset=UTF-8' },
|
||||||
{ path: '/api.json', type: JSON_UTF8 },
|
{ path: '/api.json', type: JSON_UTF8 },
|
||||||
{ path: '/api-console', type: HTML },
|
{ path: '/api-console', type: HTML },
|
||||||
{ path: '/_info_card_', type: HTML },
|
{ path: '/_info_card_', type: HTML },
|
||||||
{ path: '/bios', type: HTML },
|
{ path: '/bios', type: HTML },
|
||||||
{ path: '/cli', type: HTML },
|
{ path: '/cli', type: HTML },
|
||||||
{ path: '/flush', type: HTML },
|
{ path: '/flush', type: HTML },
|
||||||
{ path: '/robots.txt', type: 'text/plain; charset=UTF-8' },
|
{ path: '/robots.txt', type: 'text/plain; charset=UTF-8' },
|
||||||
{ path: '/favicon.ico', type: 'image/vnd.microsoft.icon' },
|
{ path: '/favicon.ico', type: 'image/vnd.microsoft.icon' },
|
||||||
{ path: '/opensearch.xml', type: 'application/opensearchdescription+xml' },
|
{ path: '/opensearch.xml', type: 'application/opensearchdescription+xml' },
|
||||||
{ path: '/apple-touch-icon.png', type: 'image/png' },
|
{ path: '/apple-touch-icon.png', type: 'image/png' },
|
||||||
{ path: '/twemoji/2764.svg', type: 'image/svg+xml' },
|
{ path: '/twemoji/2764.svg', type: 'image/svg+xml' },
|
||||||
{ path: '/twemoji/2764-fe0f-200d-1f525.svg', type: 'image/svg+xml' },
|
{ path: '/twemoji/2764-fe0f-200d-1f525.svg', type: 'image/svg+xml' },
|
||||||
{ path: '/twemoji-badge/2764.png', type: 'image/png' },
|
{ path: '/twemoji-badge/2764.png', type: 'image/png' },
|
||||||
{ path: '/twemoji-badge/2764-fe0f-200d-1f525.png', type: 'image/png' },
|
{ path: '/twemoji-badge/2764-fe0f-200d-1f525.png', type: 'image/png' },
|
||||||
{ path: '/fluent-emoji/2764.png', type: 'image/png' },
|
{ path: '/fluent-emoji/2764.png', type: 'image/png' },
|
||||||
{ path: '/fluent-emoji/2764-fe0f-200d-1f525.png', type: 'image/png' },
|
{ path: '/fluent-emoji/2764-fe0f-200d-1f525.png', type: 'image/png' },
|
||||||
])('$path', (p) => {
|
])('$path', (p) => {
|
||||||
test('がGETできる。', async () => await ok({ ...p }));
|
test('がGETできる。', async () => await ok({ ...p }));
|
||||||
|
|
||||||
|
@ -120,58 +121,58 @@ describe('Webリソース', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe.each([
|
describe.each([
|
||||||
{ path: '/twemoji/2764.png' },
|
{ path: '/twemoji/2764.png' },
|
||||||
{ path: '/twemoji/2764-fe0f-200d-1f525.png' },
|
{ path: '/twemoji/2764-fe0f-200d-1f525.png' },
|
||||||
{ path: '/twemoji-badge/2764.svg' },
|
{ path: '/twemoji-badge/2764.svg' },
|
||||||
{ path: '/twemoji-badge/2764-fe0f-200d-1f525.svg' },
|
{ path: '/twemoji-badge/2764-fe0f-200d-1f525.svg' },
|
||||||
{ path: '/fluent-emoji/2764.svg' },
|
{ path: '/fluent-emoji/2764.svg' },
|
||||||
{ path: '/fluent-emoji/2764-fe0f-200d-1f525.svg' },
|
{ path: '/fluent-emoji/2764-fe0f-200d-1f525.svg' },
|
||||||
])('$path', ({ path }) => {
|
])('$path', ({ path }) => {
|
||||||
test('はGETできない。', async () => await notFound({ path }));
|
test('はGETできない。', async () => await notFound({ path }));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe.each([
|
describe.each([
|
||||||
{ ext: 'rss', type: 'application/rss+xml; charset=utf-8' },
|
{ ext: 'rss', type: 'application/rss+xml; charset=utf-8' },
|
||||||
{ ext: 'atom', type: 'application/atom+xml; charset=utf-8' },
|
{ ext: 'atom', type: 'application/atom+xml; charset=utf-8' },
|
||||||
{ ext: 'json', type: 'application/json; charset=utf-8' },
|
{ ext: 'json', type: 'application/json; charset=utf-8' },
|
||||||
])('/@:username.$ext', ({ ext, type }) => {
|
])('/@:username.$ext', ({ ext, type }) => {
|
||||||
const path = (username: string): string => `/@${username}.${ext}`;
|
const path = (username: string): string => `/@${username}.${ext}`;
|
||||||
|
|
||||||
test('がGETできる。', async () => await ok({
|
test('がGETできる。', async () => await ok({
|
||||||
path: path(alice.username),
|
path: path(alice.username),
|
||||||
type,
|
type,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
test('は存在しないユーザーはGETできない。', async () => await notOk({
|
test('は存在しないユーザーはGETできない。', async () => await notOk({
|
||||||
path: path('nonexisting'),
|
path: path('nonexisting'),
|
||||||
status: 404,
|
status: 404,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe.each([{ path: '/api/foo' }])('$path', ({ path }) => {
|
describe.each([{ path: '/api/foo' }])('$path', ({ path }) => {
|
||||||
test('はGETできない。', async () => await notOk({
|
test('はGETできない。', async () => await notOk({
|
||||||
path,
|
path,
|
||||||
status: 404,
|
status: 404,
|
||||||
code: 'UNKNOWN_API_ENDPOINT',
|
code: 'UNKNOWN_API_ENDPOINT',
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe.each([{ path: '/queue' }])('$path', ({ path }) => {
|
describe.each([{ path: '/queue' }])('$path', ({ path }) => {
|
||||||
test('はadminでなければGETできない。', async () => await notOk({
|
test('はadminでなければGETできない。', async () => await notOk({
|
||||||
path,
|
path,
|
||||||
status: 500, // FIXME? 403ではない。
|
status: 500, // FIXME? 403ではない。
|
||||||
}));
|
}));
|
||||||
|
|
||||||
test('はadminならGETできる。', async () => await ok({
|
test('はadminならGETできる。', async () => await ok({
|
||||||
path,
|
path,
|
||||||
cookie: cookie(alice),
|
cookie: cookie(alice),
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe.each([{ path: '/streaming' }])('$path', ({ path }) => {
|
describe.each([{ path: '/streaming' }])('$path', ({ path }) => {
|
||||||
test('はGETできない。', async () => await notOk({
|
test('はGETできない。', async () => await notOk({
|
||||||
path,
|
path,
|
||||||
status: 503,
|
status: 503,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -183,21 +184,21 @@ describe('Webリソース', () => {
|
||||||
{ accept: UNSPECIFIED },
|
{ accept: UNSPECIFIED },
|
||||||
])('(Acceptヘッダ: $accept)', ({ accept }) => {
|
])('(Acceptヘッダ: $accept)', ({ accept }) => {
|
||||||
test('はHTMLとしてGETできる。', async () => {
|
test('はHTMLとしてGETできる。', async () => {
|
||||||
const res = await ok({
|
const res = await ok({
|
||||||
path: path(alice.username),
|
path: path(alice.username),
|
||||||
accept,
|
accept,
|
||||||
type: HTML,
|
type: HTML,
|
||||||
});
|
});
|
||||||
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
||||||
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
||||||
|
|
||||||
// TODO ogタグの検証
|
// TODO ogタグの検証
|
||||||
// TODO profile.noCrawleの検証
|
// TODO profile.noCrawleの検証
|
||||||
// TODO twitter:creatorの検証
|
// TODO twitter:creatorの検証
|
||||||
// TODO <link rel="me" ...>の検証
|
// TODO <link rel="me" ...>の検証
|
||||||
});
|
});
|
||||||
test('はHTMLとしてGETできる。(存在しないIDでも。)', async () => await ok({
|
test('はHTMLとしてGETできる。(存在しないIDでも。)', async () => await ok({
|
||||||
path: path('xxxxxxxxxx'),
|
path: path('xxxxxxxxxx'),
|
||||||
type: HTML,
|
type: HTML,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
@ -207,22 +208,22 @@ describe('Webリソース', () => {
|
||||||
{ accept: PREFER_AP },
|
{ accept: PREFER_AP },
|
||||||
])('(Acceptヘッダ: $accept)', ({ accept }) => {
|
])('(Acceptヘッダ: $accept)', ({ accept }) => {
|
||||||
test('はActivityPubとしてGETできる。', async () => {
|
test('はActivityPubとしてGETできる。', async () => {
|
||||||
const res = await ok({
|
const res = await ok({
|
||||||
path: path(alice.username),
|
path: path(alice.username),
|
||||||
accept,
|
accept,
|
||||||
type: AP,
|
type: AP,
|
||||||
});
|
});
|
||||||
assert.strictEqual(res.body.type, 'Person');
|
assert.strictEqual(res.body.type, 'Person');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('は存在しないIDのときActivityPubとしてGETできない。', async () => await notFound({
|
test('は存在しないIDのときActivityPubとしてGETできない。', async () => await notFound({
|
||||||
path: path('xxxxxxxxxx'),
|
path: path('xxxxxxxxxx'),
|
||||||
accept,
|
accept,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe.each([
|
describe.each([
|
||||||
// 実際のハンドルはフロントエンド(index.vue)で行われる
|
// 実際のハンドルはフロントエンド(index.vue)で行われる
|
||||||
{ sub: 'home' },
|
{ sub: 'home' },
|
||||||
{ sub: 'notes' },
|
{ sub: 'notes' },
|
||||||
|
@ -236,32 +237,32 @@ describe('Webリソース', () => {
|
||||||
const path = (username: string): string => `/@${username}/${sub}`;
|
const path = (username: string): string => `/@${username}/${sub}`;
|
||||||
|
|
||||||
test('はHTMLとしてGETできる。', async () => {
|
test('はHTMLとしてGETできる。', async () => {
|
||||||
const res = await ok({
|
const res = await ok({
|
||||||
path: path(alice.username),
|
path: path(alice.username),
|
||||||
});
|
});
|
||||||
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
||||||
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('/@:user/pages/:page', () => {
|
describe('/@:user/pages/:page', () => {
|
||||||
const path = (username: string, pagename: string): string => `/@${username}/pages/${pagename}`;
|
const path = (username: string, pagename: string): string => `/@${username}/pages/${pagename}`;
|
||||||
|
|
||||||
test('はHTMLとしてGETできる。', async () => {
|
test('はHTMLとしてGETできる。', async () => {
|
||||||
const res = await ok({
|
const res = await ok({
|
||||||
path: path(alice.username, alicePage.name),
|
path: path(alice.username, alicePage.name),
|
||||||
});
|
});
|
||||||
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
||||||
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
||||||
assert.strictEqual(metaTag(res, 'misskey:page-id'), alicePage.id);
|
assert.strictEqual(metaTag(res, 'misskey:page-id'), alicePage.id);
|
||||||
|
|
||||||
// TODO ogタグの検証
|
// TODO ogタグの検証
|
||||||
// TODO profile.noCrawleの検証
|
// TODO profile.noCrawleの検証
|
||||||
// TODO twitter:creatorの検証
|
// TODO twitter:creatorの検証
|
||||||
});
|
});
|
||||||
|
|
||||||
test('はGETできる。(存在しないIDでも。)', async () => await ok({
|
test('はGETできる。(存在しないIDでも。)', async () => await ok({
|
||||||
path: path(alice.username, 'xxxxxxxxxx'),
|
path: path(alice.username, 'xxxxxxxxxx'),
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -278,7 +279,7 @@ describe('Webリソース', () => {
|
||||||
assert.strictEqual(res.location, `/@${alice.username}`);
|
assert.strictEqual(res.location, `/@${alice.username}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('は存在しないユーザーはGETできない。', async () => await notFound({
|
test('は存在しないユーザーはGETできない。', async () => await notFound({
|
||||||
path: path('xxxxxxxx'),
|
path: path('xxxxxxxx'),
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
@ -288,24 +289,24 @@ describe('Webリソース', () => {
|
||||||
{ accept: PREFER_AP },
|
{ accept: PREFER_AP },
|
||||||
])('(Acceptヘッダ: $accept)', ({ accept }) => {
|
])('(Acceptヘッダ: $accept)', ({ accept }) => {
|
||||||
test('はActivityPubとしてGETできる。', async () => {
|
test('はActivityPubとしてGETできる。', async () => {
|
||||||
const res = await ok({
|
const res = await ok({
|
||||||
path: path(alice.id),
|
path: path(alice.id),
|
||||||
accept,
|
accept,
|
||||||
type: AP,
|
type: AP,
|
||||||
});
|
});
|
||||||
assert.strictEqual(res.body.type, 'Person');
|
assert.strictEqual(res.body.type, 'Person');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('は存在しないIDのときActivityPubとしてGETできない。', async () => await notOk({
|
test('は存在しないIDのときActivityPubとしてGETできない。', async () => await notOk({
|
||||||
path: path('xxxxxxxx'),
|
path: path('xxxxxxxx'),
|
||||||
accept,
|
accept,
|
||||||
status: 404,
|
status: 404,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('/users/inbox', () => {
|
describe('/users/inbox', () => {
|
||||||
test('がGETできる。(POST専用だけど4xx/5xxにならずHTMLが返ってくる)', async () => await ok({
|
test('がGETできる。(POST専用だけど4xx/5xxにならずHTMLが返ってくる)', async () => await ok({
|
||||||
path: '/inbox',
|
path: '/inbox',
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -315,7 +316,7 @@ describe('Webリソース', () => {
|
||||||
describe('/users/:id/inbox', () => {
|
describe('/users/:id/inbox', () => {
|
||||||
const path = (id: string): string => `/users/${id}/inbox`;
|
const path = (id: string): string => `/users/${id}/inbox`;
|
||||||
|
|
||||||
test('がGETできる。(POST専用だけど4xx/5xxにならずHTMLが返ってくる)', async () => await ok({
|
test('がGETできる。(POST専用だけど4xx/5xxにならずHTMLが返ってくる)', async () => await ok({
|
||||||
path: path(alice.id),
|
path: path(alice.id),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -326,14 +327,14 @@ describe('Webリソース', () => {
|
||||||
const path = (id: string): string => `/users/${id}/outbox`;
|
const path = (id: string): string => `/users/${id}/outbox`;
|
||||||
|
|
||||||
test('がGETできる。', async () => {
|
test('がGETできる。', async () => {
|
||||||
const res = await ok({
|
const res = await ok({
|
||||||
path: path(alice.id),
|
path: path(alice.id),
|
||||||
type: AP,
|
type: AP,
|
||||||
});
|
});
|
||||||
assert.strictEqual(res.body.type, 'OrderedCollection');
|
assert.strictEqual(res.body.type, 'OrderedCollection');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('/notes/:id', () => {
|
describe('/notes/:id', () => {
|
||||||
const path = (noteId: string): string => `/notes/${noteId}`;
|
const path = (noteId: string): string => `/notes/${noteId}`;
|
||||||
|
|
||||||
|
@ -342,22 +343,22 @@ describe('Webリソース', () => {
|
||||||
{ accept: UNSPECIFIED },
|
{ accept: UNSPECIFIED },
|
||||||
])('(Acceptヘッダ: $accept)', ({ accept }) => {
|
])('(Acceptヘッダ: $accept)', ({ accept }) => {
|
||||||
test('はHTMLとしてGETできる。', async () => {
|
test('はHTMLとしてGETできる。', async () => {
|
||||||
const res = await ok({
|
const res = await ok({
|
||||||
path: path(alicesPost.id),
|
path: path(alicesPost.id),
|
||||||
accept,
|
accept,
|
||||||
type: HTML,
|
type: HTML,
|
||||||
});
|
});
|
||||||
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
||||||
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
||||||
assert.strictEqual(metaTag(res, 'misskey:note-id'), alicesPost.id);
|
assert.strictEqual(metaTag(res, 'misskey:note-id'), alicesPost.id);
|
||||||
|
|
||||||
// TODO ogタグの検証
|
// TODO ogタグの検証
|
||||||
// TODO profile.noCrawleの検証
|
// TODO profile.noCrawleの検証
|
||||||
// TODO twitter:creatorの検証
|
// TODO twitter:creatorの検証
|
||||||
});
|
});
|
||||||
|
|
||||||
test('はHTMLとしてGETできる。(存在しないIDでも。)', async () => await ok({
|
test('はHTMLとしてGETできる。(存在しないIDでも。)', async () => await ok({
|
||||||
path: path('xxxxxxxxxx'),
|
path: path('xxxxxxxxxx'),
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -366,48 +367,48 @@ describe('Webリソース', () => {
|
||||||
{ accept: PREFER_AP },
|
{ accept: PREFER_AP },
|
||||||
])('(Acceptヘッダ: $accept)', ({ accept }) => {
|
])('(Acceptヘッダ: $accept)', ({ accept }) => {
|
||||||
test('はActivityPubとしてGETできる。', async () => {
|
test('はActivityPubとしてGETできる。', async () => {
|
||||||
const res = await ok({
|
const res = await ok({
|
||||||
path: path(alicesPost.id),
|
path: path(alicesPost.id),
|
||||||
accept,
|
accept,
|
||||||
type: AP,
|
type: AP,
|
||||||
});
|
});
|
||||||
assert.strictEqual(res.body.type, 'Note');
|
assert.strictEqual(res.body.type, 'Note');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('は存在しないIDのときActivityPubとしてGETできない。', async () => await notFound({
|
test('は存在しないIDのときActivityPubとしてGETできない。', async () => await notFound({
|
||||||
path: path('xxxxxxxxxx'),
|
path: path('xxxxxxxxxx'),
|
||||||
accept,
|
accept,
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('/play/:id', () => {
|
describe('/play/:id', () => {
|
||||||
const path = (playid: string): string => `/play/${playid}`;
|
const path = (playid: string): string => `/play/${playid}`;
|
||||||
|
|
||||||
test('がGETできる。', async () => {
|
test('がGETできる。', async () => {
|
||||||
const res = await ok({
|
const res = await ok({
|
||||||
path: path(alicePlay.id),
|
path: path(alicePlay.id),
|
||||||
});
|
});
|
||||||
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
||||||
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
||||||
assert.strictEqual(metaTag(res, 'misskey:flash-id'), alicePlay.id);
|
assert.strictEqual(metaTag(res, 'misskey:flash-id'), alicePlay.id);
|
||||||
|
|
||||||
// TODO ogタグの検証
|
// TODO ogタグの検証
|
||||||
// TODO profile.noCrawleの検証
|
// TODO profile.noCrawleの検証
|
||||||
// TODO twitter:creatorの検証
|
// TODO twitter:creatorの検証
|
||||||
});
|
});
|
||||||
|
|
||||||
test('がGETできる。(存在しないIDでも。)', async () => await ok({
|
test('がGETできる。(存在しないIDでも。)', async () => await ok({
|
||||||
path: path('xxxxxxxxxx'),
|
path: path('xxxxxxxxxx'),
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('/clips/:clip', () => {
|
describe('/clips/:clip', () => {
|
||||||
const path = (clip: string): string => `/clips/${clip}`;
|
const path = (clip: string): string => `/clips/${clip}`;
|
||||||
|
|
||||||
test('がGETできる。', async () => {
|
test('がGETできる。', async () => {
|
||||||
const res = await ok({
|
const res = await ok({
|
||||||
path: path(aliceClip.id),
|
path: path(aliceClip.id),
|
||||||
});
|
});
|
||||||
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
||||||
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
||||||
|
@ -416,9 +417,9 @@ describe('Webリソース', () => {
|
||||||
// TODO ogタグの検証
|
// TODO ogタグの検証
|
||||||
// TODO profile.noCrawleの検証
|
// TODO profile.noCrawleの検証
|
||||||
});
|
});
|
||||||
|
|
||||||
test('がGETできる。(存在しないIDでも。)', async () => await ok({
|
test('がGETできる。(存在しないIDでも。)', async () => await ok({
|
||||||
path: path('xxxxxxxxxx'),
|
path: path('xxxxxxxxxx'),
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -426,8 +427,8 @@ describe('Webリソース', () => {
|
||||||
const path = (post: string): string => `/gallery/${post}`;
|
const path = (post: string): string => `/gallery/${post}`;
|
||||||
|
|
||||||
test('がGETできる。', async () => {
|
test('がGETできる。', async () => {
|
||||||
const res = await ok({
|
const res = await ok({
|
||||||
path: path(aliceGalleryPost.id),
|
path: path(aliceGalleryPost.id),
|
||||||
});
|
});
|
||||||
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
assert.strictEqual(metaTag(res, 'misskey:user-username'), alice.username);
|
||||||
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
assert.strictEqual(metaTag(res, 'misskey:user-id'), alice.id);
|
||||||
|
@ -436,26 +437,26 @@ describe('Webリソース', () => {
|
||||||
// TODO profile.noCrawleの検証
|
// TODO profile.noCrawleの検証
|
||||||
// TODO twitter:creatorの検証
|
// TODO twitter:creatorの検証
|
||||||
});
|
});
|
||||||
|
|
||||||
test('がGETできる。(存在しないIDでも。)', async () => await ok({
|
test('がGETできる。(存在しないIDでも。)', async () => await ok({
|
||||||
path: path('xxxxxxxxxx'),
|
path: path('xxxxxxxxxx'),
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('/channels/:channel', () => {
|
describe('/channels/:channel', () => {
|
||||||
const path = (channel: string): string => `/channels/${channel}`;
|
const path = (channel: string): string => `/channels/${channel}`;
|
||||||
|
|
||||||
test('はGETできる。', async () => {
|
test('はGETできる。', async () => {
|
||||||
const res = await ok({
|
const res = await ok({
|
||||||
path: path(aliceChannel.id),
|
path: path(aliceChannel.id),
|
||||||
});
|
});
|
||||||
|
|
||||||
// FIXME: misskey関連のmetaタグの設定がない
|
// FIXME: misskey関連のmetaタグの設定がない
|
||||||
// TODO ogタグの検証
|
// TODO ogタグの検証
|
||||||
});
|
});
|
||||||
|
|
||||||
test('がGETできる。(存在しないIDでも。)', async () => await ok({
|
test('がGETできる。(存在しないIDでも。)', async () => await ok({
|
||||||
path: path('xxxxxxxxxx'),
|
path: path('xxxxxxxxxx'),
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,12 +3,13 @@ process.env.NODE_ENV = 'test';
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import { signup, api, startServer, simpleGet } from '../utils.js';
|
import { signup, api, startServer, simpleGet } from '../utils.js';
|
||||||
import type { INestApplicationContext } from '@nestjs/common';
|
import type { INestApplicationContext } from '@nestjs/common';
|
||||||
|
import type * as misskey from 'misskey-js';
|
||||||
|
|
||||||
describe('FF visibility', () => {
|
describe('FF visibility', () => {
|
||||||
let app: INestApplicationContext;
|
let app: INestApplicationContext;
|
||||||
|
|
||||||
let alice: any;
|
let alice: misskey.entities.MeSignup;
|
||||||
let bob: any;
|
let bob: misskey.entities.MeSignup;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
app = await startServer();
|
app = await startServer();
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
process.env.NODE_ENV = 'test';
|
process.env.NODE_ENV = 'test';
|
||||||
|
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import rndstr from 'rndstr';
|
|
||||||
import { loadConfig } from '@/config.js';
|
import { loadConfig } from '@/config.js';
|
||||||
import { User, UsersRepository } from '@/models/index.js';
|
import { User, UsersRepository } from '@/models/index.js';
|
||||||
import { jobQueue } from '@/boot/common.js';
|
import { jobQueue } from '@/boot/common.js';
|
||||||
|
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||||
import { uploadFile, signup, startServer, initTestDb, api, sleep, successfulApiCall } from '../utils.js';
|
import { uploadFile, signup, startServer, initTestDb, api, sleep, successfulApiCall } from '../utils.js';
|
||||||
import type { INestApplicationContext } from '@nestjs/common';
|
import type { INestApplicationContext } from '@nestjs/common';
|
||||||
|
import type * as misskey from 'misskey-js';
|
||||||
|
|
||||||
describe('Account Move', () => {
|
describe('Account Move', () => {
|
||||||
let app: INestApplicationContext;
|
let app: INestApplicationContext;
|
||||||
|
@ -14,12 +15,12 @@ describe('Account Move', () => {
|
||||||
let url: URL;
|
let url: URL;
|
||||||
|
|
||||||
let root: any;
|
let root: any;
|
||||||
let alice: any;
|
let alice: misskey.entities.MeSignup;
|
||||||
let bob: any;
|
let bob: misskey.entities.MeSignup;
|
||||||
let carol: any;
|
let carol: misskey.entities.MeSignup;
|
||||||
let dave: any;
|
let dave: misskey.entities.MeSignup;
|
||||||
let eve: any;
|
let eve: misskey.entities.MeSignup;
|
||||||
let frank: any;
|
let frank: misskey.entities.MeSignup;
|
||||||
|
|
||||||
let Users: UsersRepository;
|
let Users: UsersRepository;
|
||||||
|
|
||||||
|
@ -162,7 +163,7 @@ describe('Account Move', () => {
|
||||||
alsoKnownAs: [`@alice@${url.hostname}`],
|
alsoKnownAs: [`@alice@${url.hostname}`],
|
||||||
}, root);
|
}, root);
|
||||||
const listRoot = await api('/users/lists/create', {
|
const listRoot = await api('/users/lists/create', {
|
||||||
name: rndstr('0-9a-z', 8),
|
name: secureRndstr(8),
|
||||||
}, root);
|
}, root);
|
||||||
await api('/users/lists/push', {
|
await api('/users/lists/push', {
|
||||||
listId: listRoot.body.id,
|
listId: listRoot.body.id,
|
||||||
|
@ -176,9 +177,9 @@ describe('Account Move', () => {
|
||||||
userId: eve.id,
|
userId: eve.id,
|
||||||
}, alice);
|
}, alice);
|
||||||
const antenna = await api('/antennas/create', {
|
const antenna = await api('/antennas/create', {
|
||||||
name: rndstr('0-9a-z', 8),
|
name: secureRndstr(8),
|
||||||
src: 'home',
|
src: 'home',
|
||||||
keywords: [rndstr('0-9a-z', 8)],
|
keywords: [secureRndstr(8)],
|
||||||
excludeKeywords: [],
|
excludeKeywords: [],
|
||||||
users: [],
|
users: [],
|
||||||
caseSensitive: false,
|
caseSensitive: false,
|
||||||
|
@ -210,7 +211,7 @@ describe('Account Move', () => {
|
||||||
userId: dave.id,
|
userId: dave.id,
|
||||||
}, eve);
|
}, eve);
|
||||||
const listEve = await api('/users/lists/create', {
|
const listEve = await api('/users/lists/create', {
|
||||||
name: rndstr('0-9a-z', 8),
|
name: secureRndstr(8),
|
||||||
}, eve);
|
}, eve);
|
||||||
await api('/users/lists/push', {
|
await api('/users/lists/push', {
|
||||||
listId: listEve.body.id,
|
listId: listEve.body.id,
|
||||||
|
@ -419,9 +420,9 @@ describe('Account Move', () => {
|
||||||
test('Prohibit access after moving: /antennas/update', async () => {
|
test('Prohibit access after moving: /antennas/update', async () => {
|
||||||
const res = await api('/antennas/update', {
|
const res = await api('/antennas/update', {
|
||||||
antennaId,
|
antennaId,
|
||||||
name: rndstr('0-9a-z', 8),
|
name: secureRndstr(8),
|
||||||
src: 'users',
|
src: 'users',
|
||||||
keywords: [rndstr('0-9a-z', 8)],
|
keywords: [secureRndstr(8)],
|
||||||
excludeKeywords: [],
|
excludeKeywords: [],
|
||||||
users: [eve.id],
|
users: [eve.id],
|
||||||
caseSensitive: false,
|
caseSensitive: false,
|
||||||
|
|
|
@ -3,14 +3,15 @@ process.env.NODE_ENV = 'test';
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import { signup, api, post, react, startServer, waitFire } from '../utils.js';
|
import { signup, api, post, react, startServer, waitFire } from '../utils.js';
|
||||||
import type { INestApplicationContext } from '@nestjs/common';
|
import type { INestApplicationContext } from '@nestjs/common';
|
||||||
|
import type * as misskey from 'misskey-js';
|
||||||
|
|
||||||
describe('Mute', () => {
|
describe('Mute', () => {
|
||||||
let app: INestApplicationContext;
|
let app: INestApplicationContext;
|
||||||
|
|
||||||
// alice mutes carol
|
// alice mutes carol
|
||||||
let alice: any;
|
let alice: misskey.entities.MeSignup;
|
||||||
let bob: any;
|
let bob: misskey.entities.MeSignup;
|
||||||
let carol: any;
|
let carol: misskey.entities.MeSignup;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
app = await startServer();
|
app = await startServer();
|
||||||
|
|
|
@ -4,13 +4,14 @@ import * as assert from 'assert';
|
||||||
import { Note } from '@/models/entities/Note.js';
|
import { Note } from '@/models/entities/Note.js';
|
||||||
import { signup, post, uploadUrl, startServer, initTestDb, api, uploadFile } from '../utils.js';
|
import { signup, post, uploadUrl, startServer, initTestDb, api, uploadFile } from '../utils.js';
|
||||||
import type { INestApplicationContext } from '@nestjs/common';
|
import type { INestApplicationContext } from '@nestjs/common';
|
||||||
|
import type * as misskey from 'misskey-js';
|
||||||
|
|
||||||
describe('Note', () => {
|
describe('Note', () => {
|
||||||
let app: INestApplicationContext;
|
let app: INestApplicationContext;
|
||||||
let Notes: any;
|
let Notes: any;
|
||||||
|
|
||||||
let alice: any;
|
let alice: misskey.entities.MeSignup;
|
||||||
let bob: any;
|
let bob: misskey.entities.MeSignup;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
app = await startServer();
|
app = await startServer();
|
||||||
|
@ -378,7 +379,7 @@ describe('Note', () => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, alice);
|
}, alice);
|
||||||
|
|
||||||
assert.strictEqual(res.status, 200);
|
assert.strictEqual(res.status, 200);
|
||||||
|
|
||||||
const assign = await api('admin/roles/assign', {
|
const assign = await api('admin/roles/assign', {
|
||||||
|
|
|
@ -3,14 +3,15 @@ process.env.NODE_ENV = 'test';
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import { signup, api, post, react, startServer, waitFire } from '../utils.js';
|
import { signup, api, post, react, startServer, waitFire } from '../utils.js';
|
||||||
import type { INestApplicationContext } from '@nestjs/common';
|
import type { INestApplicationContext } from '@nestjs/common';
|
||||||
|
import type * as misskey from 'misskey-js';
|
||||||
|
|
||||||
describe('Renote Mute', () => {
|
describe('Renote Mute', () => {
|
||||||
let app: INestApplicationContext;
|
let app: INestApplicationContext;
|
||||||
|
|
||||||
// alice mutes carol
|
// alice mutes carol
|
||||||
let alice: any;
|
let alice: misskey.entities.MeSignup;
|
||||||
let bob: any;
|
let bob: misskey.entities.MeSignup;
|
||||||
let carol: any;
|
let carol: misskey.entities.MeSignup;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
app = await startServer();
|
app = await startServer();
|
||||||
|
|
|
@ -4,6 +4,7 @@ import * as assert from 'assert';
|
||||||
import { Following } from '@/models/entities/Following.js';
|
import { Following } from '@/models/entities/Following.js';
|
||||||
import { connectStream, signup, api, post, startServer, initTestDb, waitFire } from '../utils.js';
|
import { connectStream, signup, api, post, startServer, initTestDb, waitFire } from '../utils.js';
|
||||||
import type { INestApplicationContext } from '@nestjs/common';
|
import type { INestApplicationContext } from '@nestjs/common';
|
||||||
|
import type * as misskey from 'misskey-js';
|
||||||
|
|
||||||
describe('Streaming', () => {
|
describe('Streaming', () => {
|
||||||
let app: INestApplicationContext;
|
let app: INestApplicationContext;
|
||||||
|
@ -26,13 +27,13 @@ describe('Streaming', () => {
|
||||||
|
|
||||||
describe('Streaming', () => {
|
describe('Streaming', () => {
|
||||||
// Local users
|
// Local users
|
||||||
let ayano: any;
|
let ayano: misskey.entities.MeSignup;
|
||||||
let kyoko: any;
|
let kyoko: misskey.entities.MeSignup;
|
||||||
let chitose: any;
|
let chitose: misskey.entities.MeSignup;
|
||||||
|
|
||||||
// Remote users
|
// Remote users
|
||||||
let akari: any;
|
let akari: misskey.entities.MeSignup;
|
||||||
let chinatsu: any;
|
let chinatsu: misskey.entities.MeSignup;
|
||||||
|
|
||||||
let kyokoNote: any;
|
let kyokoNote: any;
|
||||||
let list: any;
|
let list: any;
|
||||||
|
|
|
@ -3,13 +3,14 @@ process.env.NODE_ENV = 'test';
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import { signup, api, post, connectStream, startServer } from '../utils.js';
|
import { signup, api, post, connectStream, startServer } from '../utils.js';
|
||||||
import type { INestApplicationContext } from '@nestjs/common';
|
import type { INestApplicationContext } from '@nestjs/common';
|
||||||
|
import type * as misskey from 'misskey-js';
|
||||||
|
|
||||||
describe('Note thread mute', () => {
|
describe('Note thread mute', () => {
|
||||||
let app: INestApplicationContext;
|
let app: INestApplicationContext;
|
||||||
|
|
||||||
let alice: any;
|
let alice: misskey.entities.MeSignup;
|
||||||
let bob: any;
|
let bob: misskey.entities.MeSignup;
|
||||||
let carol: any;
|
let carol: misskey.entities.MeSignup;
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
app = await startServer();
|
app = await startServer();
|
||||||
|
|
|
@ -3,11 +3,12 @@ process.env.NODE_ENV = 'test';
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import { signup, api, post, uploadUrl, startServer } from '../utils.js';
|
import { signup, api, post, uploadUrl, startServer } from '../utils.js';
|
||||||
import type { INestApplicationContext } from '@nestjs/common';
|
import type { INestApplicationContext } from '@nestjs/common';
|
||||||
|
import type * as misskey from 'misskey-js';
|
||||||
|
|
||||||
describe('users/notes', () => {
|
describe('users/notes', () => {
|
||||||
let app: INestApplicationContext;
|
let app: INestApplicationContext;
|
||||||
|
|
||||||
let alice: any;
|
let alice: misskey.entities.MeSignup;
|
||||||
let jpgNote: any;
|
let jpgNote: any;
|
||||||
let pngNote: any;
|
let pngNote: any;
|
||||||
let jpgPngNote: any;
|
let jpgPngNote: any;
|
||||||
|
|
|
@ -4,14 +4,14 @@ import * as assert from 'assert';
|
||||||
import { inspect } from 'node:util';
|
import { inspect } from 'node:util';
|
||||||
import { DEFAULT_POLICIES } from '@/core/RoleService.js';
|
import { DEFAULT_POLICIES } from '@/core/RoleService.js';
|
||||||
import type { Packed } from '@/misc/json-schema.js';
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
import {
|
import {
|
||||||
signup,
|
signup,
|
||||||
post,
|
post,
|
||||||
page,
|
page,
|
||||||
role,
|
role,
|
||||||
startServer,
|
startServer,
|
||||||
api,
|
api,
|
||||||
successfulApiCall,
|
successfulApiCall,
|
||||||
failedApiCall,
|
failedApiCall,
|
||||||
uploadFile,
|
uploadFile,
|
||||||
} from '../utils.js';
|
} from '../utils.js';
|
||||||
|
@ -36,19 +36,19 @@ describe('ユーザー', () => {
|
||||||
badgeRoles: any[],
|
badgeRoles: any[],
|
||||||
};
|
};
|
||||||
|
|
||||||
type UserDetailedNotMe = UserLite &
|
type UserDetailedNotMe = UserLite &
|
||||||
misskey.entities.UserDetailed & {
|
misskey.entities.UserDetailed & {
|
||||||
roles: any[],
|
roles: any[],
|
||||||
};
|
};
|
||||||
|
|
||||||
type MeDetailed = UserDetailedNotMe &
|
type MeDetailed = UserDetailedNotMe &
|
||||||
misskey.entities.MeDetailed & {
|
misskey.entities.MeDetailed & {
|
||||||
achievements: object[],
|
achievements: object[],
|
||||||
loggedInDays: number,
|
loggedInDays: number,
|
||||||
policies: object,
|
policies: object,
|
||||||
};
|
};
|
||||||
|
|
||||||
type User = MeDetailed & { token: string };
|
type User = MeDetailed & { token: string };
|
||||||
|
|
||||||
const show = async (id: string, me = root): Promise<MeDetailed | UserDetailedNotMe> => {
|
const show = async (id: string, me = root): Promise<MeDetailed | UserDetailedNotMe> => {
|
||||||
return successfulApiCall({ endpoint: 'users/show', parameters: { userId: id }, user: me }) as any;
|
return successfulApiCall({ endpoint: 'users/show', parameters: { userId: id }, user: me }) as any;
|
||||||
|
@ -159,7 +159,7 @@ describe('ユーザー', () => {
|
||||||
mutedInstances: user.mutedInstances,
|
mutedInstances: user.mutedInstances,
|
||||||
mutingNotificationTypes: user.mutingNotificationTypes,
|
mutingNotificationTypes: user.mutingNotificationTypes,
|
||||||
emailNotificationTypes: user.emailNotificationTypes,
|
emailNotificationTypes: user.emailNotificationTypes,
|
||||||
achievements: user.achievements,
|
achievements: user.achievements,
|
||||||
loggedInDays: user.loggedInDays,
|
loggedInDays: user.loggedInDays,
|
||||||
policies: user.policies,
|
policies: user.policies,
|
||||||
...(security ? {
|
...(security ? {
|
||||||
|
@ -222,11 +222,11 @@ describe('ユーザー', () => {
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
root = await signup({ username: 'root' });
|
root = await signup({ username: 'root' });
|
||||||
alice = await signup({ username: 'alice' });
|
alice = await signup({ username: 'alice' });
|
||||||
aliceNote = await post(alice, { text: 'test' }) as any;
|
aliceNote = await post(alice, { text: 'test' }) as any;
|
||||||
alicePage = await page(alice);
|
alicePage = await page(alice);
|
||||||
aliceList = (await api('users/list/create', { name: 'aliceList' }, alice)).body;
|
aliceList = (await api('users/list/create', { name: 'aliceList' }, alice)).body;
|
||||||
bob = await signup({ username: 'bob' });
|
bob = await signup({ username: 'bob' });
|
||||||
bobNote = await post(bob, { text: 'test' }) as any;
|
bobNote = await post(bob, { text: 'test' }) as any;
|
||||||
carol = await signup({ username: 'carol' });
|
carol = await signup({ username: 'carol' });
|
||||||
dave = await signup({ username: 'dave' });
|
dave = await signup({ username: 'dave' });
|
||||||
ellen = await signup({ username: 'ellen' });
|
ellen = await signup({ username: 'ellen' });
|
||||||
|
@ -236,10 +236,10 @@ describe('ユーザー', () => {
|
||||||
usersReplying = await [...Array(10)].map((_, i) => i).reduce(async (acc, i) => {
|
usersReplying = await [...Array(10)].map((_, i) => i).reduce(async (acc, i) => {
|
||||||
const u = await signup({ username: `replying${i}` });
|
const u = await signup({ username: `replying${i}` });
|
||||||
for (let j = 0; j < 10 - i; j++) {
|
for (let j = 0; j < 10 - i; j++) {
|
||||||
const p = await post(u, { text: `test${j}` });
|
const p = await post(u, { text: `test${j}` });
|
||||||
await post(alice, { text: `@${u.username} test${j}`, replyId: p.id });
|
await post(alice, { text: `@${u.username} test${j}`, replyId: p.id });
|
||||||
}
|
}
|
||||||
|
|
||||||
return (await acc).concat(u);
|
return (await acc).concat(u);
|
||||||
}, Promise.resolve([] as User[]));
|
}, Promise.resolve([] as User[]));
|
||||||
|
|
||||||
|
@ -376,7 +376,7 @@ describe('ユーザー', () => {
|
||||||
assert.strictEqual(response.securityKeys, false);
|
assert.strictEqual(response.securityKeys, false);
|
||||||
assert.deepStrictEqual(response.roles, []);
|
assert.deepStrictEqual(response.roles, []);
|
||||||
assert.strictEqual(response.memo, null);
|
assert.strictEqual(response.memo, null);
|
||||||
|
|
||||||
// MeDetailedOnly
|
// MeDetailedOnly
|
||||||
assert.strictEqual(response.avatarId, null);
|
assert.strictEqual(response.avatarId, null);
|
||||||
assert.strictEqual(response.bannerId, null);
|
assert.strictEqual(response.bannerId, null);
|
||||||
|
@ -406,7 +406,7 @@ describe('ユーザー', () => {
|
||||||
assert.deepStrictEqual(response.emailNotificationTypes, ['follow', 'receiveFollowRequest']);
|
assert.deepStrictEqual(response.emailNotificationTypes, ['follow', 'receiveFollowRequest']);
|
||||||
assert.deepStrictEqual(response.achievements, []);
|
assert.deepStrictEqual(response.achievements, []);
|
||||||
assert.deepStrictEqual(response.loggedInDays, 0);
|
assert.deepStrictEqual(response.loggedInDays, 0);
|
||||||
assert.deepStrictEqual(response.policies, DEFAULT_POLICIES);
|
assert.deepStrictEqual(response.policies, DEFAULT_POLICIES);
|
||||||
assert.notStrictEqual(response.email, undefined);
|
assert.notStrictEqual(response.email, undefined);
|
||||||
assert.strictEqual(response.emailVerified, false);
|
assert.strictEqual(response.emailVerified, false);
|
||||||
assert.deepStrictEqual(response.securityKeysList, []);
|
assert.deepStrictEqual(response.securityKeysList, []);
|
||||||
|
@ -499,8 +499,8 @@ describe('ユーザー', () => {
|
||||||
const response = await successfulApiCall({ endpoint: 'i/update', parameters: parameters, user: alice });
|
const response = await successfulApiCall({ endpoint: 'i/update', parameters: parameters, user: alice });
|
||||||
assert.match(response.avatarUrl ?? '.', /^[-a-zA-Z0-9@:%._\+~#&?=\/]+$/);
|
assert.match(response.avatarUrl ?? '.', /^[-a-zA-Z0-9@:%._\+~#&?=\/]+$/);
|
||||||
assert.match(response.avatarBlurhash ?? '.', /[ -~]{54}/);
|
assert.match(response.avatarBlurhash ?? '.', /[ -~]{54}/);
|
||||||
const expected = {
|
const expected = {
|
||||||
...meDetailed(alice, true),
|
...meDetailed(alice, true),
|
||||||
avatarId: aliceFile.id,
|
avatarId: aliceFile.id,
|
||||||
avatarBlurhash: response.avatarBlurhash,
|
avatarBlurhash: response.avatarBlurhash,
|
||||||
avatarUrl: response.avatarUrl,
|
avatarUrl: response.avatarUrl,
|
||||||
|
@ -509,8 +509,8 @@ describe('ユーザー', () => {
|
||||||
|
|
||||||
const parameters2 = { avatarId: null };
|
const parameters2 = { avatarId: null };
|
||||||
const response2 = await successfulApiCall({ endpoint: 'i/update', parameters: parameters2, user: alice });
|
const response2 = await successfulApiCall({ endpoint: 'i/update', parameters: parameters2, user: alice });
|
||||||
const expected2 = {
|
const expected2 = {
|
||||||
...meDetailed(alice, true),
|
...meDetailed(alice, true),
|
||||||
avatarId: null,
|
avatarId: null,
|
||||||
avatarBlurhash: null,
|
avatarBlurhash: null,
|
||||||
avatarUrl: alice.avatarUrl, // 解除した場合、identiconになる
|
avatarUrl: alice.avatarUrl, // 解除した場合、identiconになる
|
||||||
|
@ -524,8 +524,8 @@ describe('ユーザー', () => {
|
||||||
const response = await successfulApiCall({ endpoint: 'i/update', parameters: parameters, user: alice });
|
const response = await successfulApiCall({ endpoint: 'i/update', parameters: parameters, user: alice });
|
||||||
assert.match(response.bannerUrl ?? '.', /^[-a-zA-Z0-9@:%._\+~#&?=\/]+$/);
|
assert.match(response.bannerUrl ?? '.', /^[-a-zA-Z0-9@:%._\+~#&?=\/]+$/);
|
||||||
assert.match(response.bannerBlurhash ?? '.', /[ -~]{54}/);
|
assert.match(response.bannerBlurhash ?? '.', /[ -~]{54}/);
|
||||||
const expected = {
|
const expected = {
|
||||||
...meDetailed(alice, true),
|
...meDetailed(alice, true),
|
||||||
bannerId: aliceFile.id,
|
bannerId: aliceFile.id,
|
||||||
bannerBlurhash: response.bannerBlurhash,
|
bannerBlurhash: response.bannerBlurhash,
|
||||||
bannerUrl: response.bannerUrl,
|
bannerUrl: response.bannerUrl,
|
||||||
|
@ -534,8 +534,8 @@ describe('ユーザー', () => {
|
||||||
|
|
||||||
const parameters2 = { bannerId: null };
|
const parameters2 = { bannerId: null };
|
||||||
const response2 = await successfulApiCall({ endpoint: 'i/update', parameters: parameters2, user: alice });
|
const response2 = await successfulApiCall({ endpoint: 'i/update', parameters: parameters2, user: alice });
|
||||||
const expected2 = {
|
const expected2 = {
|
||||||
...meDetailed(alice, true),
|
...meDetailed(alice, true),
|
||||||
bannerId: null,
|
bannerId: null,
|
||||||
bannerBlurhash: null,
|
bannerBlurhash: null,
|
||||||
bannerUrl: null,
|
bannerUrl: null,
|
||||||
|
@ -551,7 +551,7 @@ describe('ユーザー', () => {
|
||||||
const response = await successfulApiCall({ endpoint: 'i/pin', parameters, user: alice });
|
const response = await successfulApiCall({ endpoint: 'i/pin', parameters, user: alice });
|
||||||
const expected = { ...meDetailed(alice, false), pinnedNoteIds: [aliceNote.id], pinnedNotes: [aliceNote] };
|
const expected = { ...meDetailed(alice, false), pinnedNoteIds: [aliceNote.id], pinnedNotes: [aliceNote] };
|
||||||
assert.deepStrictEqual(response, expected);
|
assert.deepStrictEqual(response, expected);
|
||||||
|
|
||||||
const response2 = await successfulApiCall({ endpoint: 'i/unpin', parameters, user: alice });
|
const response2 = await successfulApiCall({ endpoint: 'i/unpin', parameters, user: alice });
|
||||||
const expected2 = meDetailed(alice, false);
|
const expected2 = meDetailed(alice, false);
|
||||||
assert.deepStrictEqual(response2, expected2);
|
assert.deepStrictEqual(response2, expected2);
|
||||||
|
@ -612,7 +612,7 @@ describe('ユーザー', () => {
|
||||||
});
|
});
|
||||||
test.todo('をリスト形式で取得することができる(リモート, hostname指定)');
|
test.todo('をリスト形式で取得することができる(リモート, hostname指定)');
|
||||||
test.todo('をリスト形式で取得することができる(pagenation)');
|
test.todo('をリスト形式で取得することができる(pagenation)');
|
||||||
|
|
||||||
//#endregion
|
//#endregion
|
||||||
//#region ユーザー情報(users/show)
|
//#region ユーザー情報(users/show)
|
||||||
|
|
||||||
|
@ -684,9 +684,9 @@ describe('ユーザー', () => {
|
||||||
const parameters = { userIds: [bob.id, alice.id, carol.id] };
|
const parameters = { userIds: [bob.id, alice.id, carol.id] };
|
||||||
const response = await successfulApiCall({ endpoint: 'users/show', parameters, user: alice });
|
const response = await successfulApiCall({ endpoint: 'users/show', parameters, user: alice });
|
||||||
const expected = [
|
const expected = [
|
||||||
await successfulApiCall({ endpoint: 'users/show', parameters: { userId: bob.id }, user: alice }),
|
await successfulApiCall({ endpoint: 'users/show', parameters: { userId: bob.id }, user: alice }),
|
||||||
await successfulApiCall({ endpoint: 'users/show', parameters: { userId: alice.id }, user: alice }),
|
await successfulApiCall({ endpoint: 'users/show', parameters: { userId: alice.id }, user: alice }),
|
||||||
await successfulApiCall({ endpoint: 'users/show', parameters: { userId: carol.id }, user: alice }),
|
await successfulApiCall({ endpoint: 'users/show', parameters: { userId: carol.id }, user: alice }),
|
||||||
];
|
];
|
||||||
assert.deepStrictEqual(response, expected);
|
assert.deepStrictEqual(response, expected);
|
||||||
});
|
});
|
||||||
|
@ -701,7 +701,7 @@ describe('ユーザー', () => {
|
||||||
// BUG サスペンドユーザーを一般ユーザーから見るとrootユーザーが返ってくる
|
// BUG サスペンドユーザーを一般ユーザーから見るとrootユーザーが返ってくる
|
||||||
//{ label: 'サスペンドユーザーが(一般ユーザーが見るときは)含まれない', user: (): User => userSuspended, me: (): User => bob, excluded: true },
|
//{ label: 'サスペンドユーザーが(一般ユーザーが見るときは)含まれない', user: (): User => userSuspended, me: (): User => bob, excluded: true },
|
||||||
{ label: '削除済ユーザーが含まれる', user: (): User => userDeletedBySelf },
|
{ label: '削除済ユーザーが含まれる', user: (): User => userDeletedBySelf },
|
||||||
{ label: '削除済(byAdmin)ユーザーが含まれる', user: (): User => userDeletedByAdmin },
|
{ label: '削除済(byAdmin)ユーザーが含まれる', user: (): User => userDeletedByAdmin },
|
||||||
] as const)('をID指定のリスト形式で取得することができ、結果に$label', async ({ user, me, excluded }) => {
|
] as const)('をID指定のリスト形式で取得することができ、結果に$label', async ({ user, me, excluded }) => {
|
||||||
const parameters = { userIds: [user().id] };
|
const parameters = { userIds: [user().id] };
|
||||||
const response = await successfulApiCall({ endpoint: 'users/show', parameters, user: me?.() ?? alice });
|
const response = await successfulApiCall({ endpoint: 'users/show', parameters, user: me?.() ?? alice });
|
||||||
|
@ -734,7 +734,7 @@ describe('ユーザー', () => {
|
||||||
{ label: 'サイレンスユーザーが含まれる', user: (): User => userSilenced },
|
{ label: 'サイレンスユーザーが含まれる', user: (): User => userSilenced },
|
||||||
{ label: 'サスペンドユーザーが含まれない', user: (): User => userSuspended, excluded: true },
|
{ label: 'サスペンドユーザーが含まれない', user: (): User => userSuspended, excluded: true },
|
||||||
{ label: '削除済ユーザーが含まれる', user: (): User => userDeletedBySelf },
|
{ label: '削除済ユーザーが含まれる', user: (): User => userDeletedBySelf },
|
||||||
{ label: '削除済(byAdmin)ユーザーが含まれる', user: (): User => userDeletedByAdmin },
|
{ label: '削除済(byAdmin)ユーザーが含まれる', user: (): User => userDeletedByAdmin },
|
||||||
] as const)('を検索することができ、結果に$labelが含まれる', async ({ user, excluded }) => {
|
] as const)('を検索することができ、結果に$labelが含まれる', async ({ user, excluded }) => {
|
||||||
const parameters = { query: user().username, limit: 1 };
|
const parameters = { query: user().username, limit: 1 };
|
||||||
const response = await successfulApiCall({ endpoint: 'users/search', parameters, user: alice });
|
const response = await successfulApiCall({ endpoint: 'users/search', parameters, user: alice });
|
||||||
|
@ -747,7 +747,7 @@ describe('ユーザー', () => {
|
||||||
//#endregion
|
//#endregion
|
||||||
//#region ID指定検索(users/search-by-username-and-host)
|
//#region ID指定検索(users/search-by-username-and-host)
|
||||||
|
|
||||||
test.each([
|
test.each([
|
||||||
{ label: '自分', parameters: { username: 'alice' }, user: (): User[] => [alice] },
|
{ label: '自分', parameters: { username: 'alice' }, user: (): User[] => [alice] },
|
||||||
{ label: '自分かつusernameが大文字', parameters: { username: 'ALICE' }, user: (): User[] => [alice] },
|
{ label: '自分かつusernameが大文字', parameters: { username: 'ALICE' }, user: (): User[] => [alice] },
|
||||||
{ label: 'ローカルのフォロイーでノートなし', parameters: { username: 'userFollowedByAlice' }, user: (): User[] => [userFollowedByAlice] },
|
{ label: 'ローカルのフォロイーでノートなし', parameters: { username: 'userFollowedByAlice' }, user: (): User[] => [userFollowedByAlice] },
|
||||||
|
@ -786,7 +786,7 @@ describe('ユーザー', () => {
|
||||||
test('がよくリプライをするユーザーのリストを取得できる', async () => {
|
test('がよくリプライをするユーザーのリストを取得できる', async () => {
|
||||||
const parameters = { userId: alice.id, limit: 5 };
|
const parameters = { userId: alice.id, limit: 5 };
|
||||||
const response = await successfulApiCall({ endpoint: 'users/get-frequently-replied-users', parameters, user: alice });
|
const response = await successfulApiCall({ endpoint: 'users/get-frequently-replied-users', parameters, user: alice });
|
||||||
const expected = await Promise.all(usersReplying.slice(0, parameters.limit).map(async (s, i) => ({
|
const expected = await Promise.all(usersReplying.slice(0, parameters.limit).map(async (s, i) => ({
|
||||||
user: await show(s.id, alice),
|
user: await show(s.id, alice),
|
||||||
weight: (usersReplying.length - i) / usersReplying.length,
|
weight: (usersReplying.length - i) / usersReplying.length,
|
||||||
})));
|
})));
|
||||||
|
|
|
@ -4,7 +4,6 @@ import { jest } from '@jest/globals';
|
||||||
import { ModuleMocker } from 'jest-mock';
|
import { ModuleMocker } from 'jest-mock';
|
||||||
import { Test } from '@nestjs/testing';
|
import { Test } from '@nestjs/testing';
|
||||||
import * as lolex from '@sinonjs/fake-timers';
|
import * as lolex from '@sinonjs/fake-timers';
|
||||||
import rndstr from 'rndstr';
|
|
||||||
import { GlobalModule } from '@/GlobalModule.js';
|
import { GlobalModule } from '@/GlobalModule.js';
|
||||||
import { RoleService } from '@/core/RoleService.js';
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
import type { Role, RolesRepository, RoleAssignmentsRepository, UsersRepository, User } from '@/models/index.js';
|
import type { Role, RolesRepository, RoleAssignmentsRepository, UsersRepository, User } from '@/models/index.js';
|
||||||
|
@ -14,6 +13,7 @@ import { genAid } from '@/misc/id/aid.js';
|
||||||
import { CacheService } from '@/core/CacheService.js';
|
import { CacheService } from '@/core/CacheService.js';
|
||||||
import { IdService } from '@/core/IdService.js';
|
import { IdService } from '@/core/IdService.js';
|
||||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||||
|
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||||
import { sleep } from '../utils.js';
|
import { sleep } from '../utils.js';
|
||||||
import type { TestingModule } from '@nestjs/testing';
|
import type { TestingModule } from '@nestjs/testing';
|
||||||
import type { MockFunctionMetadata } from 'jest-mock';
|
import type { MockFunctionMetadata } from 'jest-mock';
|
||||||
|
@ -30,7 +30,7 @@ describe('RoleService', () => {
|
||||||
let clock: lolex.InstalledClock;
|
let clock: lolex.InstalledClock;
|
||||||
|
|
||||||
function createUser(data: Partial<User> = {}) {
|
function createUser(data: Partial<User> = {}) {
|
||||||
const un = rndstr('a-z0-9', 16);
|
const un = secureRndstr(16);
|
||||||
return usersRepository.insert({
|
return usersRepository.insert({
|
||||||
id: genAid(new Date()),
|
id: genAid(new Date()),
|
||||||
createdAt: new Date(),
|
createdAt: new Date(),
|
||||||
|
@ -106,19 +106,19 @@ describe('RoleService', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getUserPolicies', () => {
|
describe('getUserPolicies', () => {
|
||||||
test('instance default policies', async () => {
|
test('instance default policies', async () => {
|
||||||
const user = await createUser();
|
const user = await createUser();
|
||||||
metaService.fetch.mockResolvedValue({
|
metaService.fetch.mockResolvedValue({
|
||||||
policies: {
|
policies: {
|
||||||
canManageCustomEmojis: false,
|
canManageCustomEmojis: false,
|
||||||
},
|
},
|
||||||
} as any);
|
} as any);
|
||||||
|
|
||||||
const result = await roleService.getUserPolicies(user.id);
|
const result = await roleService.getUserPolicies(user.id);
|
||||||
|
|
||||||
expect(result.canManageCustomEmojis).toBe(false);
|
expect(result.canManageCustomEmojis).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('instance default policies 2', async () => {
|
test('instance default policies 2', async () => {
|
||||||
const user = await createUser();
|
const user = await createUser();
|
||||||
metaService.fetch.mockResolvedValue({
|
metaService.fetch.mockResolvedValue({
|
||||||
|
@ -126,12 +126,12 @@ describe('RoleService', () => {
|
||||||
canManageCustomEmojis: true,
|
canManageCustomEmojis: true,
|
||||||
},
|
},
|
||||||
} as any);
|
} as any);
|
||||||
|
|
||||||
const result = await roleService.getUserPolicies(user.id);
|
const result = await roleService.getUserPolicies(user.id);
|
||||||
|
|
||||||
expect(result.canManageCustomEmojis).toBe(true);
|
expect(result.canManageCustomEmojis).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('with role', async () => {
|
test('with role', async () => {
|
||||||
const user = await createUser();
|
const user = await createUser();
|
||||||
const role = await createRole({
|
const role = await createRole({
|
||||||
|
@ -150,9 +150,9 @@ describe('RoleService', () => {
|
||||||
canManageCustomEmojis: false,
|
canManageCustomEmojis: false,
|
||||||
},
|
},
|
||||||
} as any);
|
} as any);
|
||||||
|
|
||||||
const result = await roleService.getUserPolicies(user.id);
|
const result = await roleService.getUserPolicies(user.id);
|
||||||
|
|
||||||
expect(result.canManageCustomEmojis).toBe(true);
|
expect(result.canManageCustomEmojis).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -185,9 +185,9 @@ describe('RoleService', () => {
|
||||||
driveCapacityMb: 50,
|
driveCapacityMb: 50,
|
||||||
},
|
},
|
||||||
} as any);
|
} as any);
|
||||||
|
|
||||||
const result = await roleService.getUserPolicies(user.id);
|
const result = await roleService.getUserPolicies(user.id);
|
||||||
|
|
||||||
expect(result.driveCapacityMb).toBe(100);
|
expect(result.driveCapacityMb).toBe(100);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -226,7 +226,7 @@ describe('RoleService', () => {
|
||||||
canManageCustomEmojis: false,
|
canManageCustomEmojis: false,
|
||||||
},
|
},
|
||||||
} as any);
|
} as any);
|
||||||
|
|
||||||
const user1Policies = await roleService.getUserPolicies(user1.id);
|
const user1Policies = await roleService.getUserPolicies(user1.id);
|
||||||
const user2Policies = await roleService.getUserPolicies(user2.id);
|
const user2Policies = await roleService.getUserPolicies(user2.id);
|
||||||
expect(user1Policies.canManageCustomEmojis).toBe(false);
|
expect(user1Policies.canManageCustomEmojis).toBe(false);
|
||||||
|
@ -251,7 +251,7 @@ describe('RoleService', () => {
|
||||||
canManageCustomEmojis: false,
|
canManageCustomEmojis: false,
|
||||||
},
|
},
|
||||||
} as any);
|
} as any);
|
||||||
|
|
||||||
const result = await roleService.getUserPolicies(user.id);
|
const result = await roleService.getUserPolicies(user.id);
|
||||||
expect(result.canManageCustomEmojis).toBe(true);
|
expect(result.canManageCustomEmojis).toBe(true);
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
process.env.NODE_ENV = 'test';
|
process.env.NODE_ENV = 'test';
|
||||||
|
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import rndstr from 'rndstr';
|
|
||||||
import { Test } from '@nestjs/testing';
|
import { Test } from '@nestjs/testing';
|
||||||
import { jest } from '@jest/globals';
|
import { jest } from '@jest/globals';
|
||||||
|
|
||||||
|
@ -13,13 +12,14 @@ import { CoreModule } from '@/core/CoreModule.js';
|
||||||
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
||||||
import { LoggerService } from '@/core/LoggerService.js';
|
import { LoggerService } from '@/core/LoggerService.js';
|
||||||
import type { IActor } from '@/core/activitypub/type.js';
|
import type { IActor } from '@/core/activitypub/type.js';
|
||||||
import { MockResolver } from '../misc/mock-resolver.js';
|
|
||||||
import { Note } from '@/models/index.js';
|
import { Note } from '@/models/index.js';
|
||||||
|
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||||
|
import { MockResolver } from '../misc/mock-resolver.js';
|
||||||
|
|
||||||
const host = 'https://host1.test';
|
const host = 'https://host1.test';
|
||||||
|
|
||||||
function createRandomActor(): IActor & { id: string } {
|
function createRandomActor(): IActor & { id: string } {
|
||||||
const preferredUsername = `${rndstr('A-Z', 4)}${rndstr('a-z', 4)}`;
|
const preferredUsername = secureRndstr(8);
|
||||||
const actorId = `${host}/users/${preferredUsername.toLowerCase()}`;
|
const actorId = `${host}/users/${preferredUsername.toLowerCase()}`;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -61,7 +61,7 @@ describe('ActivityPub', () => {
|
||||||
|
|
||||||
const post = {
|
const post = {
|
||||||
'@context': 'https://www.w3.org/ns/activitystreams',
|
'@context': 'https://www.w3.org/ns/activitystreams',
|
||||||
id: `${host}/users/${rndstr('0-9a-z', 8)}`,
|
id: `${host}/users/${secureRndstr(8)}`,
|
||||||
type: 'Note',
|
type: 'Note',
|
||||||
attributedTo: actor.id,
|
attributedTo: actor.id,
|
||||||
to: 'https://www.w3.org/ns/activitystreams#Public',
|
to: 'https://www.w3.org/ns/activitystreams#Public',
|
||||||
|
@ -94,7 +94,7 @@ describe('ActivityPub', () => {
|
||||||
test('Truncate long name', async () => {
|
test('Truncate long name', async () => {
|
||||||
const actor = {
|
const actor = {
|
||||||
...createRandomActor(),
|
...createRandomActor(),
|
||||||
name: rndstr('0-9a-z', 129),
|
name: secureRndstr(129),
|
||||||
};
|
};
|
||||||
|
|
||||||
resolver._register(actor.id, actor);
|
resolver._register(actor.id, actor);
|
||||||
|
|
|
@ -83,7 +83,7 @@ const relativeFetch = async (path: string, init?: RequestInit | undefined) => {
|
||||||
return await fetch(new URL(path, `http://127.0.0.1:${port}/`).toString(), init);
|
return await fetch(new URL(path, `http://127.0.0.1:${port}/`).toString(), init);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const signup = async (params?: any): Promise<any> => {
|
export const signup = async (params?: Partial<misskey.Endpoints['signup']['req']>): Promise<NonNullable<misskey.Endpoints['signup']['res']>> => {
|
||||||
const q = Object.assign({
|
const q = Object.assign({
|
||||||
username: 'test',
|
username: 'test',
|
||||||
password: 'test',
|
password: 'test',
|
||||||
|
@ -213,8 +213,8 @@ export const role = async (user: any, role: any = {}, policies: any = {}): Promi
|
||||||
isPublic: false,
|
isPublic: false,
|
||||||
name: 'New Role',
|
name: 'New Role',
|
||||||
target: 'manual',
|
target: 'manual',
|
||||||
policies: {
|
policies: {
|
||||||
...Object.entries(DEFAULT_POLICIES).map(([k, v]) => [k, {
|
...Object.entries(DEFAULT_POLICIES).map(([k, v]) => [k, {
|
||||||
priority: 0,
|
priority: 0,
|
||||||
useDefault: true,
|
useDefault: true,
|
||||||
value: v,
|
value: v,
|
||||||
|
@ -351,11 +351,11 @@ export const waitFire = async (user: any, channel: string, trgr: () => any, cond
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export type SimpleGetResponse = {
|
export type SimpleGetResponse = {
|
||||||
status: number,
|
status: number,
|
||||||
body: any | JSDOM | null,
|
body: any | JSDOM | null,
|
||||||
type: string | null,
|
type: string | null,
|
||||||
location: string | null
|
location: string | null
|
||||||
};
|
};
|
||||||
export const simpleGet = async (path: string, accept = '*/*', cookie: any = undefined): Promise<SimpleGetResponse> => {
|
export const simpleGet = async (path: string, accept = '*/*', cookie: any = undefined): Promise<SimpleGetResponse> => {
|
||||||
const res = await relativeFetch(path, {
|
const res = await relativeFetch(path, {
|
||||||
|
@ -374,9 +374,9 @@ export const simpleGet = async (path: string, accept = '*/*', cookie: any = unde
|
||||||
'text/html; charset=utf-8',
|
'text/html; charset=utf-8',
|
||||||
];
|
];
|
||||||
|
|
||||||
const body =
|
const body =
|
||||||
jsonTypes.includes(res.headers.get('content-type') ?? '') ? await res.json() :
|
jsonTypes.includes(res.headers.get('content-type') ?? '') ? await res.json() :
|
||||||
htmlTypes.includes(res.headers.get('content-type') ?? '') ? new JSDOM(await res.text()) :
|
htmlTypes.includes(res.headers.get('content-type') ?? '') ? new JSDOM(await res.text()) :
|
||||||
null;
|
null;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -20,29 +20,29 @@
|
||||||
"@rollup/plugin-replace": "5.0.2",
|
"@rollup/plugin-replace": "5.0.2",
|
||||||
"@rollup/pluginutils": "5.0.2",
|
"@rollup/pluginutils": "5.0.2",
|
||||||
"@syuilo/aiscript": "0.13.3",
|
"@syuilo/aiscript": "0.13.3",
|
||||||
"@tabler/icons-webfont": "2.21.0",
|
"@tabler/icons-webfont": "2.22.0",
|
||||||
"@vitejs/plugin-vue": "4.2.3",
|
"@vitejs/plugin-vue": "4.2.3",
|
||||||
"@vue-macros/reactivity-transform": "0.3.9",
|
"@vue-macros/reactivity-transform": "0.3.10",
|
||||||
"@vue/compiler-sfc": "3.3.4",
|
"@vue/compiler-sfc": "3.3.4",
|
||||||
"astring": "1.8.6",
|
"astring": "1.8.6",
|
||||||
"autosize": "6.0.1",
|
"autosize": "6.0.1",
|
||||||
"broadcast-channel": "5.1.0",
|
"broadcast-channel": "5.1.0",
|
||||||
"browser-image-resizer": "github:misskey-dev/browser-image-resizer#v2.2.1-misskey.3",
|
"browser-image-resizer": "github:misskey-dev/browser-image-resizer#v2.2.1-misskey.3",
|
||||||
"buraha": "github:misskey-dev/buraha",
|
"buraha": "0.0.1",
|
||||||
"canvas-confetti": "1.6.0",
|
"canvas-confetti": "1.6.0",
|
||||||
"chart.js": "4.3.0",
|
"chart.js": "4.3.0",
|
||||||
"chartjs-adapter-date-fns": "3.0.0",
|
"chartjs-adapter-date-fns": "3.0.0",
|
||||||
"chartjs-chart-matrix": "2.0.1",
|
"chartjs-chart-matrix": "2.0.1",
|
||||||
"chartjs-plugin-gradient": "0.6.1",
|
"chartjs-plugin-gradient": "0.6.1",
|
||||||
"chartjs-plugin-zoom": "2.0.1",
|
"chartjs-plugin-zoom": "2.0.1",
|
||||||
"chromatic": "6.18.0",
|
"chromatic": "6.19.9",
|
||||||
"compare-versions": "5.0.3",
|
"compare-versions": "5.0.3",
|
||||||
"cropperjs": "2.0.0-beta.2",
|
"cropperjs": "2.0.0-beta.3",
|
||||||
"date-fns": "2.30.0",
|
"date-fns": "2.30.0",
|
||||||
"escape-regexp": "0.0.1",
|
"escape-regexp": "0.0.1",
|
||||||
"estree-walker": "^3.0.3",
|
"estree-walker": "^3.0.3",
|
||||||
"eventemitter3": "5.0.1",
|
"eventemitter3": "5.0.1",
|
||||||
"gsap": "3.11.5",
|
"gsap": "3.12.1",
|
||||||
"idb-keyval": "6.2.1",
|
"idb-keyval": "6.2.1",
|
||||||
"insert-text-at-cursor": "0.3.0",
|
"insert-text-at-cursor": "0.3.0",
|
||||||
"is-file-animated": "1.0.2",
|
"is-file-animated": "1.0.2",
|
||||||
|
@ -55,10 +55,10 @@
|
||||||
"punycode": "2.3.0",
|
"punycode": "2.3.0",
|
||||||
"querystring": "0.2.1",
|
"querystring": "0.2.1",
|
||||||
"rndstr": "1.0.0",
|
"rndstr": "1.0.0",
|
||||||
"rollup": "3.23.0",
|
"rollup": "3.25.1",
|
||||||
"s-age": "1.1.2",
|
"s-age": "1.1.2",
|
||||||
"sanitize-html": "2.10.0",
|
"sanitize-html": "2.11.0",
|
||||||
"sass": "1.62.1",
|
"sass": "1.63.6",
|
||||||
"seedrandom": "3.0.5",
|
"seedrandom": "3.0.5",
|
||||||
"strict-event-emitter-types": "2.0.0",
|
"strict-event-emitter-types": "2.0.0",
|
||||||
"syuilo-password-strength": "0.0.1",
|
"syuilo-password-strength": "0.0.1",
|
||||||
|
@ -104,31 +104,31 @@
|
||||||
"@types/gulp-rename": "2.0.2",
|
"@types/gulp-rename": "2.0.2",
|
||||||
"@types/matter-js": "0.18.5",
|
"@types/matter-js": "0.18.5",
|
||||||
"@types/micromatch": "4.0.2",
|
"@types/micromatch": "4.0.2",
|
||||||
"@types/node": "20.2.5",
|
"@types/node": "20.3.1",
|
||||||
"@types/punycode": "2.1.0",
|
"@types/punycode": "2.1.0",
|
||||||
"@types/sanitize-html": "2.9.0",
|
"@types/sanitize-html": "2.9.0",
|
||||||
"@types/seedrandom": "3.0.5",
|
"@types/seedrandom": "3.0.5",
|
||||||
"@types/testing-library__jest-dom": "^5.14.6",
|
"@types/testing-library__jest-dom": "^5.14.6",
|
||||||
"@types/throttle-debounce": "5.0.0",
|
"@types/throttle-debounce": "5.0.0",
|
||||||
"@types/tinycolor2": "1.4.3",
|
"@types/tinycolor2": "1.4.3",
|
||||||
"@types/uuid": "9.0.1",
|
"@types/uuid": "9.0.2",
|
||||||
"@types/websocket": "1.0.5",
|
"@types/websocket": "1.0.5",
|
||||||
"@types/ws": "8.5.4",
|
"@types/ws": "8.5.5",
|
||||||
"@typescript-eslint/eslint-plugin": "5.59.8",
|
"@typescript-eslint/eslint-plugin": "5.60.0",
|
||||||
"@typescript-eslint/parser": "5.59.8",
|
"@typescript-eslint/parser": "5.60.0",
|
||||||
"@vitest/coverage-c8": "0.31.4",
|
"@vitest/coverage-v8": "0.32.2",
|
||||||
"@vue/runtime-core": "3.3.4",
|
"@vue/runtime-core": "3.3.4",
|
||||||
"acorn": "^8.8.2",
|
"acorn": "8.9.0",
|
||||||
"chokidar-cli": "3.0.0",
|
"chokidar-cli": "3.0.0",
|
||||||
"cross-env": "7.0.3",
|
"cross-env": "7.0.3",
|
||||||
"cypress": "12.13.0",
|
"cypress": "12.15.0",
|
||||||
"eslint": "8.41.0",
|
"eslint": "8.43.0",
|
||||||
"eslint-plugin-import": "2.27.5",
|
"eslint-plugin-import": "2.27.5",
|
||||||
"eslint-plugin-vue": "9.14.1",
|
"eslint-plugin-vue": "9.15.0",
|
||||||
"fast-glob": "3.2.12",
|
"fast-glob": "3.2.12",
|
||||||
"happy-dom": "9.20.3",
|
"happy-dom": "9.20.3",
|
||||||
"micromatch": "3.1.10",
|
"micromatch": "3.1.10",
|
||||||
"msw": "1.2.1",
|
"msw": "1.2.2",
|
||||||
"msw-storybook-addon": "1.8.0",
|
"msw-storybook-addon": "1.8.0",
|
||||||
"prettier": "2.8.8",
|
"prettier": "2.8.8",
|
||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
|
@ -138,9 +138,9 @@
|
||||||
"storybook-addon-misskey-theme": "github:misskey-dev/storybook-addon-misskey-theme",
|
"storybook-addon-misskey-theme": "github:misskey-dev/storybook-addon-misskey-theme",
|
||||||
"summaly": "github:misskey-dev/summaly",
|
"summaly": "github:misskey-dev/summaly",
|
||||||
"vite-plugin-turbosnap": "1.0.2",
|
"vite-plugin-turbosnap": "1.0.2",
|
||||||
"vitest": "0.31.4",
|
"vitest": "0.32.2",
|
||||||
"vitest-fetch-mock": "0.2.2",
|
"vitest-fetch-mock": "0.2.2",
|
||||||
"vue-eslint-parser": "9.3.0",
|
"vue-eslint-parser": "9.3.1",
|
||||||
"vue-tsc": "1.6.5"
|
"vue-tsc": "1.8.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,146 +0,0 @@
|
||||||
<template>
|
|
||||||
<div class="_gaps_m">
|
|
||||||
<FormSection v-if="stats" first>
|
|
||||||
<template #label>{{ i18n.ts.statistics }}</template>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.notesCount }}</template>
|
|
||||||
<template #value>{{ number(stats.notesCount) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.repliesCount }}</template>
|
|
||||||
<template #value>{{ number(stats.repliesCount) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.renotesCount }}</template>
|
|
||||||
<template #value>{{ number(stats.renotesCount) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.repliedCount }}</template>
|
|
||||||
<template #value>{{ number(stats.repliedCount) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.renotedCount }}</template>
|
|
||||||
<template #value>{{ number(stats.renotedCount) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.pollVotesCount }}</template>
|
|
||||||
<template #value>{{ number(stats.pollVotesCount) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.pollVotedCount }}</template>
|
|
||||||
<template #value>{{ number(stats.pollVotedCount) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.sentReactionsCount }}</template>
|
|
||||||
<template #value>{{ number(stats.sentReactionsCount) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.receivedReactionsCount }}</template>
|
|
||||||
<template #value>{{ number(stats.receivedReactionsCount) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.noteFavoritesCount }}</template>
|
|
||||||
<template #value>{{ number(stats.noteFavoritesCount) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.followingCount }}</template>
|
|
||||||
<template #value>{{ number(stats.followingCount) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.followingCount }} ({{ i18n.ts.local }})</template>
|
|
||||||
<template #value>{{ number(stats.localFollowingCount) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.followingCount }} ({{ i18n.ts.remote }})</template>
|
|
||||||
<template #value>{{ number(stats.remoteFollowingCount) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.followersCount }}</template>
|
|
||||||
<template #value>{{ number(stats.followersCount) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.followersCount }} ({{ i18n.ts.local }})</template>
|
|
||||||
<template #value>{{ number(stats.localFollowersCount) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.followersCount }} ({{ i18n.ts.remote }})</template>
|
|
||||||
<template #value>{{ number(stats.remoteFollowersCount) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.pageLikesCount }}</template>
|
|
||||||
<template #value>{{ number(stats.pageLikesCount) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.pageLikedCount }}</template>
|
|
||||||
<template #value>{{ number(stats.pageLikedCount) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.driveFilesCount }}</template>
|
|
||||||
<template #value>{{ number(stats.driveFilesCount) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>{{ i18n.ts.driveUsage }}</template>
|
|
||||||
<template #value>{{ bytes(stats.driveUsage) }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
</FormSection>
|
|
||||||
|
|
||||||
<FormSection>
|
|
||||||
<template #label>{{ i18n.ts.other }}</template>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>emailVerified</template>
|
|
||||||
<template #value>{{ $i.emailVerified ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>twoFactorEnabled</template>
|
|
||||||
<template #value>{{ $i.twoFactorEnabled ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>securityKeys</template>
|
|
||||||
<template #value>{{ $i.securityKeys ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>usePasswordLessLogin</template>
|
|
||||||
<template #value>{{ $i.usePasswordLessLogin ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>isModerator</template>
|
|
||||||
<template #value>{{ $i.isModerator ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
<MkKeyValue oneline style="margin: 1em 0;">
|
|
||||||
<template #key>isAdmin</template>
|
|
||||||
<template #value>{{ $i.isAdmin ? i18n.ts.yes : i18n.ts.no }}</template>
|
|
||||||
</MkKeyValue>
|
|
||||||
</FormSection>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script lang="ts" setup>
|
|
||||||
import { onMounted, ref } from 'vue';
|
|
||||||
import FormSection from '@/components/form/section.vue';
|
|
||||||
import MkKeyValue from '@/components/MkKeyValue.vue';
|
|
||||||
import * as os from '@/os';
|
|
||||||
import number from '@/filters/number';
|
|
||||||
import bytes from '@/filters/bytes';
|
|
||||||
import { $i } from '@/account';
|
|
||||||
import { i18n } from '@/i18n';
|
|
||||||
import { definePageMetadata } from '@/scripts/page-metadata';
|
|
||||||
|
|
||||||
const stats = ref<any>({});
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
os.api('users/stats', {
|
|
||||||
userId: $i!.id,
|
|
||||||
}).then(response => {
|
|
||||||
stats.value = response;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
const headerActions = $computed(() => []);
|
|
||||||
|
|
||||||
const headerTabs = $computed(() => []);
|
|
||||||
|
|
||||||
definePageMetadata({
|
|
||||||
title: i18n.ts.accountInfo,
|
|
||||||
icon: 'ti ti-info-circle',
|
|
||||||
});
|
|
||||||
</script>
|
|
|
@ -26,8 +26,6 @@
|
||||||
<template #key>{{ i18n.ts.registeredDate }}</template>
|
<template #key>{{ i18n.ts.registeredDate }}</template>
|
||||||
<template #value><MkTime :time="$i.createdAt" mode="detail"/></template>
|
<template #value><MkTime :time="$i.createdAt" mode="detail"/></template>
|
||||||
</MkKeyValue>
|
</MkKeyValue>
|
||||||
|
|
||||||
<FormLink to="/settings/account-stats"><template #icon><i class="ti ti-info-circle"></i></template>{{ i18n.ts.statistics }}</FormLink>
|
|
||||||
</div>
|
</div>
|
||||||
</MkFolder>
|
</MkFolder>
|
||||||
|
|
||||||
|
|
|
@ -44,8 +44,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div v-if="user.roles.length > 0" class="roles">
|
<div v-if="user.roles.length > 0" class="roles">
|
||||||
<span v-for="role in user.roles" :key="role.id" v-tooltip="role.description" class="role" :style="{ '--color': role.color }">
|
<span v-for="role in user.roles" :key="role.id" v-tooltip="role.description" class="role" :style="{ '--color': role.color }">
|
||||||
<img v-if="role.iconUrl" style="height: 1.3em; vertical-align: -22%;" :src="role.iconUrl"/>
|
<MkA v-adaptive-bg :to="`/roles/${role.id}`">
|
||||||
{{ role.name }}
|
<img v-if="role.iconUrl" style="height: 1.3em; vertical-align: -22%;" :src="role.iconUrl"/>
|
||||||
|
{{ role.name }}
|
||||||
|
</MkA>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="iAmModerator" class="moderationNote">
|
<div v-if="iAmModerator" class="moderationNote">
|
||||||
|
|
|
@ -177,10 +177,6 @@ export const routes = [{
|
||||||
path: '/accounts',
|
path: '/accounts',
|
||||||
name: 'profile',
|
name: 'profile',
|
||||||
component: page(() => import('./pages/settings/accounts.vue')),
|
component: page(() => import('./pages/settings/accounts.vue')),
|
||||||
}, {
|
|
||||||
path: '/account-stats',
|
|
||||||
name: 'other',
|
|
||||||
component: page(() => import('./pages/settings/account-stats.vue')),
|
|
||||||
}, {
|
}, {
|
||||||
path: '/other',
|
path: '/other',
|
||||||
name: 'other',
|
name: 'other',
|
||||||
|
|
|
@ -4,12 +4,13 @@
|
||||||
|
|
||||||
<div :class="$style.main">
|
<div :class="$style.main">
|
||||||
<XStatusBars/>
|
<XStatusBars/>
|
||||||
<div ref="columnsEl" :class="[$style.sections, { [$style.center]: deckStore.reactiveState.columnAlign.value === 'center', [$style.snapScroll]: snapScroll }]" @contextmenu.self.prevent="onContextmenu">
|
<div ref="columnsEl" :class="[$style.sections, { [$style.center]: deckStore.reactiveState.columnAlign.value === 'center', [$style.snapScroll]: snapScroll }]" @contextmenu.self.prevent="onContextmenu" @wheel.self="onWheel">
|
||||||
<!-- sectionを利用しているのは、deck.vue側でcolumnに対してfirst-of-typeを効かせるため -->
|
<!-- sectionを利用しているのは、deck.vue側でcolumnに対してfirst-of-typeを効かせるため -->
|
||||||
<section
|
<section
|
||||||
v-for="ids in layout"
|
v-for="ids in layout"
|
||||||
:class="$style.section"
|
:class="$style.section"
|
||||||
:style="columns.filter(c => ids.includes(c.id)).some(c => c.flexible) ? { flex: 1, minWidth: '350px' } : { width: Math.max(...columns.filter(c => ids.includes(c.id)).map(c => c.width)) + 'px' }"
|
:style="columns.filter(c => ids.includes(c.id)).some(c => c.flexible) ? { flex: 1, minWidth: '350px' } : { width: Math.max(...columns.filter(c => ids.includes(c.id)).map(c => c.width)) + 'px' }"
|
||||||
|
@wheel.self="onWheel"
|
||||||
>
|
>
|
||||||
<component
|
<component
|
||||||
:is="columnComponents[columns.find(c => c.id === id)!.type] ?? XTlColumn"
|
:is="columnComponents[columns.find(c => c.id === id)!.type] ?? XTlColumn"
|
||||||
|
@ -19,6 +20,7 @@
|
||||||
:class="$style.column"
|
:class="$style.column"
|
||||||
:column="columns.find(c => c.id === id)"
|
:column="columns.find(c => c.id === id)"
|
||||||
:isStacked="ids.length > 1"
|
:isStacked="ids.length > 1"
|
||||||
|
@headerWheel="onWheel"
|
||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
<div v-if="layout.length === 0" class="_panel" :class="$style.onboarding">
|
<div v-if="layout.length === 0" class="_panel" :class="$style.onboarding">
|
||||||
|
@ -196,15 +198,14 @@ const onContextmenu = (ev) => {
|
||||||
}], ev);
|
}], ev);
|
||||||
};
|
};
|
||||||
|
|
||||||
document.documentElement.style.overflowY = 'hidden';
|
function onWheel(ev: WheelEvent) {
|
||||||
document.documentElement.style.scrollBehavior = 'auto';
|
if (ev.deltaX === 0) {
|
||||||
window.addEventListener('wheel', (ev) => {
|
|
||||||
if (ev.target === columnsEl && ev.deltaX === 0) {
|
|
||||||
columnsEl.scrollLeft += ev.deltaY;
|
|
||||||
} else if (getScrollContainer(ev.target as HTMLElement) == null && ev.deltaX === 0) {
|
|
||||||
columnsEl.scrollLeft += ev.deltaY;
|
columnsEl.scrollLeft += ev.deltaY;
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
document.documentElement.style.overflowY = 'hidden';
|
||||||
|
document.documentElement.style.scrollBehavior = 'auto';
|
||||||
|
|
||||||
loadDeck();
|
loadDeck();
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
@dragstart="onDragstart"
|
@dragstart="onDragstart"
|
||||||
@dragend="onDragend"
|
@dragend="onDragend"
|
||||||
@contextmenu.prevent.stop="onContextmenu"
|
@contextmenu.prevent.stop="onContextmenu"
|
||||||
|
@wheel="emit('headerWheel', $event)"
|
||||||
>
|
>
|
||||||
<svg viewBox="0 0 256 128" :class="$style.tabShape">
|
<svg viewBox="0 0 256 128" :class="$style.tabShape">
|
||||||
<g transform="matrix(6.2431,0,0,6.2431,-677.417,-29.3839)">
|
<g transform="matrix(6.2431,0,0,6.2431,-677.417,-29.3839)">
|
||||||
|
@ -56,6 +57,10 @@ const props = withDefaults(defineProps<{
|
||||||
naked: false,
|
naked: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits<{
|
||||||
|
(ev: 'headerWheel', ctx: WheelEvent): void;
|
||||||
|
}>();
|
||||||
|
|
||||||
let body = $shallowRef<HTMLDivElement | null>();
|
let body = $shallowRef<HTMLDivElement | null>();
|
||||||
|
|
||||||
let dragging = $ref(false);
|
let dragging = $ref(false);
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
:stroke-dashoffset="strokeDashoffset"
|
:stroke-dashoffset="strokeDashoffset"
|
||||||
fill="none"
|
fill="none"
|
||||||
stroke-width="0.1"
|
stroke-width="0.1"
|
||||||
|
:class="$style.circle"
|
||||||
:stroke="color"
|
:stroke="color"
|
||||||
/>
|
/>
|
||||||
<text x="50%" y="50%" dy="0.05" text-anchor="middle" :class="$style.text">{{ (value * 100).toFixed(0) }}%</text>
|
<text x="50%" y="50%" dy="0.05" text-anchor="middle" :class="$style.text">{{ (value * 100).toFixed(0) }}%</text>
|
||||||
|
|
|
@ -23,12 +23,12 @@
|
||||||
"useDefineForClassFields": true,
|
"useDefineForClassFields": true,
|
||||||
"baseUrl": ".",
|
"baseUrl": ".",
|
||||||
"paths": {
|
"paths": {
|
||||||
"@/*": ["./src/*"],
|
"@/*": ["./src/*"]
|
||||||
},
|
},
|
||||||
"typeRoots": [
|
"typeRoots": [
|
||||||
"node_modules/@types",
|
"node_modules/@types",
|
||||||
"node_modules/@vue-macros",
|
"node_modules/@vue-macros",
|
||||||
"@types",
|
"@types"
|
||||||
],
|
],
|
||||||
"types": [
|
"types": [
|
||||||
"vite/client",
|
"vite/client",
|
||||||
|
@ -47,6 +47,6 @@
|
||||||
"./**/*.vue"
|
"./**/*.vue"
|
||||||
],
|
],
|
||||||
"exclude": [
|
"exclude": [
|
||||||
".storybook/**/*",
|
".storybook/**/*"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -1958,6 +1958,19 @@ export type Endpoints = {
|
||||||
req: TODO;
|
req: TODO;
|
||||||
res: TODO;
|
res: TODO;
|
||||||
};
|
};
|
||||||
|
'signup': {
|
||||||
|
req: {
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
host?: string;
|
||||||
|
invitationCode?: string;
|
||||||
|
emailAddress?: string;
|
||||||
|
'hcaptcha-response'?: string;
|
||||||
|
'g-recaptcha-response'?: string;
|
||||||
|
'turnstile-response'?: string;
|
||||||
|
};
|
||||||
|
res: MeSignup | null;
|
||||||
|
};
|
||||||
'stats': {
|
'stats': {
|
||||||
req: NoParams;
|
req: NoParams;
|
||||||
res: Stats;
|
res: Stats;
|
||||||
|
@ -2163,10 +2176,6 @@ export type Endpoints = {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
'users/stats': {
|
|
||||||
req: TODO;
|
|
||||||
res: TODO;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
declare namespace entities {
|
declare namespace entities {
|
||||||
|
@ -2179,6 +2188,8 @@ declare namespace entities {
|
||||||
UserGroup,
|
UserGroup,
|
||||||
UserList,
|
UserList,
|
||||||
MeDetailed,
|
MeDetailed,
|
||||||
|
MeDetailedWithSecret,
|
||||||
|
MeSignup,
|
||||||
DriveFile,
|
DriveFile,
|
||||||
DriveFolder,
|
DriveFolder,
|
||||||
GalleryPost,
|
GalleryPost,
|
||||||
|
@ -2394,6 +2405,22 @@ type MeDetailed = UserDetailed & {
|
||||||
[other: string]: any;
|
[other: string]: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// @public (undocumented)
|
||||||
|
type MeDetailedWithSecret = MeDetailed & {
|
||||||
|
email: string;
|
||||||
|
emailVerified: boolean;
|
||||||
|
securityKeysList: {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
lastUsed: string;
|
||||||
|
}[];
|
||||||
|
};
|
||||||
|
|
||||||
|
// @public (undocumented)
|
||||||
|
type MeSignup = MeDetailedWithSecret & {
|
||||||
|
token: string;
|
||||||
|
};
|
||||||
|
|
||||||
// @public (undocumented)
|
// @public (undocumented)
|
||||||
type MessagingMessage = {
|
type MessagingMessage = {
|
||||||
id: ID;
|
id: ID;
|
||||||
|
@ -2739,7 +2766,7 @@ type UserSorting = '+follower' | '-follower' | '+createdAt' | '-createdAt' | '+u
|
||||||
//
|
//
|
||||||
// src/api.types.ts:16:32 - (ae-forgotten-export) The symbol "TODO" needs to be exported by the entry point index.d.ts
|
// src/api.types.ts:16:32 - (ae-forgotten-export) The symbol "TODO" needs to be exported by the entry point index.d.ts
|
||||||
// src/api.types.ts:18:25 - (ae-forgotten-export) The symbol "NoParams" needs to be exported by the entry point index.d.ts
|
// src/api.types.ts:18:25 - (ae-forgotten-export) The symbol "NoParams" needs to be exported by the entry point index.d.ts
|
||||||
// src/api.types.ts:600:18 - (ae-forgotten-export) The symbol "ShowUserReq" needs to be exported by the entry point index.d.ts
|
// src/api.types.ts:615:18 - (ae-forgotten-export) The symbol "ShowUserReq" needs to be exported by the entry point index.d.ts
|
||||||
// src/streaming.types.ts:33:4 - (ae-forgotten-export) The symbol "FIXME" needs to be exported by the entry point index.d.ts
|
// src/streaming.types.ts:33:4 - (ae-forgotten-export) The symbol "FIXME" needs to be exported by the entry point index.d.ts
|
||||||
|
|
||||||
// (No @packageDocumentation comment for this package)
|
// (No @packageDocumentation comment for this package)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "misskey-js",
|
"name": "misskey-js",
|
||||||
"version": "0.0.15",
|
"version": "0.0.16",
|
||||||
"description": "Misskey SDK for JavaScript",
|
"description": "Misskey SDK for JavaScript",
|
||||||
"main": "./built/index.js",
|
"main": "./built/index.js",
|
||||||
"types": "./built/index.d.ts",
|
"types": "./built/index.d.ts",
|
||||||
|
@ -20,26 +20,26 @@
|
||||||
"url": "git+https://github.com/misskey-dev/misskey.js.git"
|
"url": "git+https://github.com/misskey-dev/misskey.js.git"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@microsoft/api-extractor": "7.34.7",
|
"@microsoft/api-extractor": "7.36.0",
|
||||||
"@swc/jest": "0.2.26",
|
"@swc/jest": "0.2.26",
|
||||||
"@types/jest": "29.5.1",
|
"@types/jest": "29.5.2",
|
||||||
"@types/node": "18.16.3",
|
"@types/node": "20.3.1",
|
||||||
"@typescript-eslint/eslint-plugin": "5.59.5",
|
"@typescript-eslint/eslint-plugin": "5.60.0",
|
||||||
"@typescript-eslint/parser": "5.59.5",
|
"@typescript-eslint/parser": "5.60.0",
|
||||||
"eslint": "8.40.0",
|
"eslint": "8.43.0",
|
||||||
"jest": "29.5.0",
|
"jest": "29.5.0",
|
||||||
"jest-fetch-mock": "3.0.3",
|
"jest-fetch-mock": "3.0.3",
|
||||||
"jest-websocket-mock": "2.4.0",
|
"jest-websocket-mock": "2.4.0",
|
||||||
"mock-socket": "9.2.1",
|
"mock-socket": "9.2.1",
|
||||||
"tsd": "0.28.1",
|
"tsd": "0.28.1",
|
||||||
"typescript": "5.0.4"
|
"typescript": "5.1.3"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"built"
|
"built"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@swc/cli": "0.1.62",
|
"@swc/cli": "0.1.62",
|
||||||
"@swc/core": "1.3.56",
|
"@swc/core": "1.3.66",
|
||||||
"eventemitter3": "5.0.1",
|
"eventemitter3": "5.0.1",
|
||||||
"reconnecting-websocket": "4.4.0"
|
"reconnecting-websocket": "4.4.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import type {
|
||||||
Ad, Announcement, Antenna, App, AuthSession, Blocking, Channel, Clip, DateString, DetailedInstanceMetadata, DriveFile, DriveFolder, Following, FollowingFolloweePopulated, FollowingFollowerPopulated, FollowRequest, GalleryPost, Instance,
|
Ad, Announcement, Antenna, App, AuthSession, Blocking, Channel, Clip, DateString, DetailedInstanceMetadata, DriveFile, DriveFolder, Following, FollowingFolloweePopulated, FollowingFollowerPopulated, FollowRequest, GalleryPost, Instance,
|
||||||
LiteInstanceMetadata,
|
LiteInstanceMetadata,
|
||||||
MeDetailed,
|
MeDetailed,
|
||||||
Note, NoteFavorite, OriginType, Page, ServerInfo, Stats, User, UserDetailed, UserGroup, UserList, UserSorting, Notification, NoteReaction, Signin, MessagingMessage,
|
Note, NoteFavorite, OriginType, Page, ServerInfo, Stats, User, UserDetailed, MeSignup, UserGroup, UserList, UserSorting, Notification, NoteReaction, Signin, MessagingMessage,
|
||||||
} from './entities.js';
|
} from './entities.js';
|
||||||
|
|
||||||
type TODO = Record<string, any> | null;
|
type TODO = Record<string, any> | null;
|
||||||
|
@ -553,6 +553,21 @@ export type Endpoints = {
|
||||||
'room/show': { req: TODO; res: TODO; };
|
'room/show': { req: TODO; res: TODO; };
|
||||||
'room/update': { req: TODO; res: TODO; };
|
'room/update': { req: TODO; res: TODO; };
|
||||||
|
|
||||||
|
// signup
|
||||||
|
'signup': {
|
||||||
|
req: {
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
host?: string;
|
||||||
|
invitationCode?: string;
|
||||||
|
emailAddress?: string;
|
||||||
|
'hcaptcha-response'?: string;
|
||||||
|
'g-recaptcha-response'?: string;
|
||||||
|
'turnstile-response'?: string;
|
||||||
|
};
|
||||||
|
res: MeSignup | null;
|
||||||
|
};
|
||||||
|
|
||||||
// stats
|
// stats
|
||||||
'stats': { req: NoParams; res: Stats; };
|
'stats': { req: NoParams; res: Stats; };
|
||||||
|
|
||||||
|
@ -606,5 +621,4 @@ export type Endpoints = {
|
||||||
$default: UserDetailed;
|
$default: UserDetailed;
|
||||||
};
|
};
|
||||||
}; };
|
}; };
|
||||||
'users/stats': { req: TODO; res: TODO; };
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -107,6 +107,20 @@ export type MeDetailed = UserDetailed & {
|
||||||
[other: string]: any;
|
[other: string]: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export type MeDetailedWithSecret = MeDetailed & {
|
||||||
|
email: string;
|
||||||
|
emailVerified: boolean;
|
||||||
|
securityKeysList: {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
lastUsed: string;
|
||||||
|
}[];
|
||||||
|
};
|
||||||
|
|
||||||
|
export type MeSignup = MeDetailedWithSecret & {
|
||||||
|
token: string;
|
||||||
|
};
|
||||||
|
|
||||||
export type DriveFile = {
|
export type DriveFile = {
|
||||||
id: ID;
|
id: ID;
|
||||||
createdAt: DateString;
|
createdAt: DateString;
|
||||||
|
|
|
@ -14,10 +14,10 @@
|
||||||
"misskey-js": "workspace:*"
|
"misskey-js": "workspace:*"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@typescript-eslint/parser": "5.59.5",
|
"@typescript-eslint/parser": "5.60.0",
|
||||||
"@typescript/lib-webworker": "npm:@types/serviceworker@0.0.67",
|
"@typescript/lib-webworker": "npm:@types/serviceworker@0.0.67",
|
||||||
"eslint": "8.40.0",
|
"eslint": "8.43.0",
|
||||||
"eslint-plugin-import": "2.27.5",
|
"eslint-plugin-import": "2.27.5",
|
||||||
"typescript": "5.0.4"
|
"typescript": "5.1.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2587
pnpm-lock.yaml
2587
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue