Merge remote-tracking branch 'misskey-dev/develop' into io
This commit is contained in:
commit
acab2bfc72
|
@ -19,7 +19,6 @@
|
|||
"editorconfig.editorconfig",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"Vue.volar",
|
||||
"Vue.vscode-typescript-vue-plugin",
|
||||
"Orta.vscode-jest",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"mrmlnc.vscode-json5"
|
||||
|
|
|
@ -3,9 +3,7 @@
|
|||
"editorconfig.editorconfig",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"Vue.volar",
|
||||
"Vue.vscode-typescript-vue-plugin",
|
||||
"Orta.vscode-jest",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"mrmlnc.vscode-json5"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"*.test.ts": "typescript"
|
||||
},
|
||||
"jest.jestCommandLine": "pnpm run jest",
|
||||
"jest.autoRun": "off",
|
||||
"jest.runMode": "on-demand",
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll": "explicit"
|
||||
},
|
||||
|
|
|
@ -5,12 +5,17 @@
|
|||
|
||||
### Client
|
||||
- Enhance: 自分のノートの添付ファイルから直接ファイルの詳細ページに飛べるように
|
||||
- Enhance: 広告がMisskeyと同一ドメインの場合はRouterで遷移するように
|
||||
- Enhance: リアクション・いいねの総数を表示するように
|
||||
- Enhance: リアクション受け入れが「いいねのみ」の場合はリアクション絵文字一覧を表示しないように
|
||||
- Enhance: 設定>プラグインのページからプラグインの簡易的なログやエラーを見られるように
|
||||
- 実装の都合により、プラグインは1つエラーを起こした時に即時停止するようになりました
|
||||
- Fix: 一部のページ内リンクが正しく動作しない問題を修正
|
||||
- Fix: 周年の実績が閏年を考慮しない問題を修正
|
||||
- Fix: ローカルURLのプレビューポップアップが左上に表示される
|
||||
|
||||
### Server
|
||||
-
|
||||
- Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに
|
||||
|
||||
## 2024.3.1
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
describe('Before setup instance', () => {
|
||||
beforeEach(() => {
|
||||
cy.resetState();
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
describe('Router transition', () => {
|
||||
describe('Redirect', () => {
|
||||
// サーバの初期化。ルートのテストに関しては各describeごとに1度だけ実行で十分だと思う(使いまわした方が早い)
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
/* flaky
|
||||
describe('After user signed in', () => {
|
||||
beforeEach(() => {
|
||||
|
|
|
@ -6973,6 +6973,10 @@ export interface Locale extends ILocale {
|
|||
* ソースを表示
|
||||
*/
|
||||
"viewSource": string;
|
||||
/**
|
||||
* ログを表示
|
||||
*/
|
||||
"viewLog": string;
|
||||
};
|
||||
"_preferencesBackups": {
|
||||
/**
|
||||
|
|
|
@ -1817,6 +1817,7 @@ _plugin:
|
|||
installWarn: "信頼できないプラグインはインストールしないでください。"
|
||||
manage: "プラグインの管理"
|
||||
viewSource: "ソースを表示"
|
||||
viewLog: "ログを表示"
|
||||
|
||||
_preferencesBackups:
|
||||
list: "作成したバックアップ"
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { loadConfig } from './built/config.js'
|
||||
import { genOpenapiSpec } from './built/server/api/openapi/gen-spec.js'
|
||||
import { writeFileSync } from "node:fs";
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class UserBlacklistAnntena1689325027964 {
|
||||
name = 'UserBlacklistAnntena1689325027964'
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class FixRenoteMuting1690417561185 {
|
||||
name = 'FixRenoteMuting1690417561185'
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class ChangeCacheRemoteFilesDefault1690417561186 {
|
||||
name = 'ChangeCacheRemoteFilesDefault1690417561186'
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class Fix1690417561187 {
|
||||
name = 'Fix1690417561187'
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class RefineAnnouncement1691649257651 {
|
||||
name = 'RefineAnnouncement1691649257651'
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class RefineAnnouncement21691657412740 {
|
||||
name = 'RefineAnnouncement21691657412740'
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class VerifiedLinks1695260774117 {
|
||||
name = 'VerifiedLinks1695260774117'
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class FollowingNotify1695288787870 {
|
||||
name = 'FollowingNotify1695288787870'
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class ShortName1695440131671 {
|
||||
name = 'ShortName1695440131671'
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class MutingNotificationTypes1695605508898 {
|
||||
name = 'MutingNotificationTypes1695605508898'
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class NoteUpdatedAt1695901659683 {
|
||||
name = 'NoteUpdatedAt1695901659683'
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class UserListMembership1696323464251 {
|
||||
name = 'UserListMembership1696323464251'
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class Hibernation1696331570827 {
|
||||
name = 'Hibernation1696331570827'
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class Clean1696332072038 {
|
||||
name = 'Clean1696332072038'
|
||||
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export class HardMute1700383825690 {
|
||||
name = 'HardMute1700383825690'
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
"watch": "node watch.mjs",
|
||||
"restart": "pnpm build && pnpm start",
|
||||
"dev": "nodemon -w src -e ts,js,mjs,cjs,json --exec \"cross-env NODE_ENV=development pnpm run restart\"",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"typecheck": "tsc --noEmit && tsc -p test --noEmit",
|
||||
"eslint": "eslint --quiet \"src/**/*.ts\"",
|
||||
"lint": "pnpm typecheck && pnpm eslint",
|
||||
"jest": "cross-env NODE_ENV=test node --experimental-vm-modules --experimental-import-meta-resolve node_modules/jest/bin/jest.js --forceExit --config jest.config.unit.cjs",
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { Inject, Injectable, OnModuleInit } from '@nestjs/common';
|
||||
import Redis from 'ioredis';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
|
|
|
@ -12,7 +12,6 @@ import {
|
|||
verifyRegistrationResponse,
|
||||
} from '@simplewebauthn/server';
|
||||
import { AttestationFormat, isoCBOR } from '@simplewebauthn/server/helpers';
|
||||
import { tinyCbor } from '@simplewebauthn/server/esm/deps.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { UserSecurityKeysRepository } from '@/models/_.js';
|
||||
import type { Config } from '@/config.js';
|
||||
|
@ -199,7 +198,7 @@ export class WebAuthnService {
|
|||
if (cert[0] === 0x04) { // 前の実装ではいつも 0x04 で始まっていた
|
||||
const halfLength = (cert.length - 1) / 2;
|
||||
|
||||
const cborMap = new Map<number, tinyCbor.CBORType>();
|
||||
const cborMap = new Map<number, number | Uint8Array>();
|
||||
cborMap.set(1, 2); // kty, EC2
|
||||
cborMap.set(3, -7); // alg, ES256
|
||||
cborMap.set(-1, 1); // crv, P256
|
||||
|
|
|
@ -135,7 +135,7 @@ export class ApNoteService {
|
|||
object,
|
||||
error: err
|
||||
});
|
||||
throw new Error('invalid note');
|
||||
throw err;
|
||||
}
|
||||
|
||||
const note = object as IPost;
|
||||
|
|
|
@ -7,6 +7,7 @@ import { Inject, Injectable } from '@nestjs/common';
|
|||
import * as Redis from 'ioredis';
|
||||
import _Ajv from 'ajv';
|
||||
import { ModuleRef } from '@nestjs/core';
|
||||
import { In } from 'typeorm';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import type { Config } from '@/config.js';
|
||||
import type { Packed } from '@/misc/json-schema.js';
|
||||
|
@ -14,9 +15,30 @@ import type { Promiseable } from '@/misc/prelude/await-all.js';
|
|||
import { awaitAll } from '@/misc/prelude/await-all.js';
|
||||
import { USER_ACTIVE_THRESHOLD, USER_ONLINE_THRESHOLD } from '@/const.js';
|
||||
import type { MiLocalUser, MiPartialLocalUser, MiPartialRemoteUser, MiRemoteUser, MiUser } from '@/models/User.js';
|
||||
import { birthdaySchema, descriptionSchema, localUsernameSchema, locationSchema, nameSchema, passwordSchema } from '@/models/User.js';
|
||||
import { MiNotification } from '@/models/Notification.js';
|
||||
import type { UsersRepository, UserSecurityKeysRepository, FollowingsRepository, FollowRequestsRepository, BlockingsRepository, MutingsRepository, DriveFilesRepository, NoteUnreadsRepository, UserNotePiningsRepository, UserProfilesRepository, AnnouncementReadsRepository, AnnouncementsRepository, MiUserProfile, RenoteMutingsRepository, UserMemoRepository } from '@/models/_.js';
|
||||
import {
|
||||
birthdaySchema,
|
||||
descriptionSchema,
|
||||
localUsernameSchema,
|
||||
locationSchema,
|
||||
nameSchema,
|
||||
passwordSchema,
|
||||
} from '@/models/User.js';
|
||||
import type {
|
||||
BlockingsRepository,
|
||||
FollowingsRepository,
|
||||
FollowRequestsRepository,
|
||||
MiFollowing,
|
||||
MiUserNotePining,
|
||||
MiUserProfile,
|
||||
MutingsRepository,
|
||||
NoteUnreadsRepository,
|
||||
RenoteMutingsRepository,
|
||||
UserMemoRepository,
|
||||
UserNotePiningsRepository,
|
||||
UserProfilesRepository,
|
||||
UserSecurityKeysRepository,
|
||||
UsersRepository,
|
||||
} from '@/models/_.js';
|
||||
import { bindThis } from '@/decorators.js';
|
||||
import { RoleService } from '@/core/RoleService.js';
|
||||
import { ApPersonService } from '@/core/activitypub/models/ApPersonService.js';
|
||||
|
@ -47,11 +69,23 @@ function isRemoteUser(user: MiUser | { host: MiUser['host'] }): boolean {
|
|||
return !isLocalUser(user);
|
||||
}
|
||||
|
||||
export type UserRelation = {
|
||||
id: MiUser['id']
|
||||
following: MiFollowing | null,
|
||||
isFollowing: boolean
|
||||
isFollowed: boolean
|
||||
hasPendingFollowRequestFromYou: boolean
|
||||
hasPendingFollowRequestToYou: boolean
|
||||
isBlocking: boolean
|
||||
isBlocked: boolean
|
||||
isMuted: boolean
|
||||
isRenoteMuted: boolean
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class UserEntityService implements OnModuleInit {
|
||||
private apPersonService: ApPersonService;
|
||||
private noteEntityService: NoteEntityService;
|
||||
private driveFileEntityService: DriveFileEntityService;
|
||||
private pageEntityService: PageEntityService;
|
||||
private customEmojiService: CustomEmojiService;
|
||||
private announcementService: AnnouncementService;
|
||||
|
@ -90,9 +124,6 @@ export class UserEntityService implements OnModuleInit {
|
|||
@Inject(DI.renoteMutingsRepository)
|
||||
private renoteMutingsRepository: RenoteMutingsRepository,
|
||||
|
||||
@Inject(DI.driveFilesRepository)
|
||||
private driveFilesRepository: DriveFilesRepository,
|
||||
|
||||
@Inject(DI.noteUnreadsRepository)
|
||||
private noteUnreadsRepository: NoteUnreadsRepository,
|
||||
|
||||
|
@ -102,12 +133,6 @@ export class UserEntityService implements OnModuleInit {
|
|||
@Inject(DI.userProfilesRepository)
|
||||
private userProfilesRepository: UserProfilesRepository,
|
||||
|
||||
@Inject(DI.announcementReadsRepository)
|
||||
private announcementReadsRepository: AnnouncementReadsRepository,
|
||||
|
||||
@Inject(DI.announcementsRepository)
|
||||
private announcementsRepository: AnnouncementsRepository,
|
||||
|
||||
@Inject(DI.userMemosRepository)
|
||||
private userMemosRepository: UserMemoRepository,
|
||||
) {
|
||||
|
@ -116,7 +141,6 @@ export class UserEntityService implements OnModuleInit {
|
|||
onModuleInit() {
|
||||
this.apPersonService = this.moduleRef.get('ApPersonService');
|
||||
this.noteEntityService = this.moduleRef.get('NoteEntityService');
|
||||
this.driveFileEntityService = this.moduleRef.get('DriveFileEntityService');
|
||||
this.pageEntityService = this.moduleRef.get('PageEntityService');
|
||||
this.customEmojiService = this.moduleRef.get('CustomEmojiService');
|
||||
this.announcementService = this.moduleRef.get('AnnouncementService');
|
||||
|
@ -139,7 +163,7 @@ export class UserEntityService implements OnModuleInit {
|
|||
public isRemoteUser = isRemoteUser;
|
||||
|
||||
@bindThis
|
||||
public async getRelation(me: MiUser['id'], target: MiUser['id']) {
|
||||
public async getRelation(me: MiUser['id'], target: MiUser['id']): Promise<UserRelation> {
|
||||
const [
|
||||
following,
|
||||
isFollowed,
|
||||
|
@ -212,6 +236,59 @@ export class UserEntityService implements OnModuleInit {
|
|||
};
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async getRelations(me: MiUser['id'], targets: MiUser['id'][]): Promise<Map<MiUser['id'], UserRelation>> {
|
||||
const [
|
||||
followers,
|
||||
followees,
|
||||
followersRequests,
|
||||
followeesRequests,
|
||||
blockers,
|
||||
blockees,
|
||||
muters,
|
||||
renoteMuters,
|
||||
] = await Promise.all([
|
||||
this.followingsRepository.findBy({ followerId: me })
|
||||
.then(f => new Map(f.map(it => [it.followeeId, it]))),
|
||||
this.followingsRepository.findBy({ followeeId: me })
|
||||
.then(it => it.map(it => it.followerId)),
|
||||
this.followRequestsRepository.findBy({ followerId: me })
|
||||
.then(it => it.map(it => it.followeeId)),
|
||||
this.followRequestsRepository.findBy({ followeeId: me })
|
||||
.then(it => it.map(it => it.followerId)),
|
||||
this.blockingsRepository.findBy({ blockerId: me })
|
||||
.then(it => it.map(it => it.blockeeId)),
|
||||
this.blockingsRepository.findBy({ blockeeId: me })
|
||||
.then(it => it.map(it => it.blockerId)),
|
||||
this.mutingsRepository.findBy({ muterId: me })
|
||||
.then(it => it.map(it => it.muteeId)),
|
||||
this.renoteMutingsRepository.findBy({ muterId: me })
|
||||
.then(it => it.map(it => it.muteeId)),
|
||||
]);
|
||||
|
||||
return new Map(
|
||||
targets.map(target => {
|
||||
const following = followers.get(target) ?? null;
|
||||
|
||||
return [
|
||||
target,
|
||||
{
|
||||
id: target,
|
||||
following: following,
|
||||
isFollowing: following != null,
|
||||
isFollowed: followees.includes(target),
|
||||
hasPendingFollowRequestFromYou: followersRequests.includes(target),
|
||||
hasPendingFollowRequestToYou: followeesRequests.includes(target),
|
||||
isBlocking: blockers.includes(target),
|
||||
isBlocked: blockees.includes(target),
|
||||
isMuted: muters.includes(target),
|
||||
isRenoteMuted: renoteMuters.includes(target),
|
||||
},
|
||||
];
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@bindThis
|
||||
public async getHasUnreadAntenna(userId: MiUser['id']): Promise<boolean> {
|
||||
/*
|
||||
|
@ -304,6 +381,9 @@ export class UserEntityService implements OnModuleInit {
|
|||
schema?: S,
|
||||
includeSecrets?: boolean,
|
||||
userProfile?: MiUserProfile,
|
||||
userRelations?: Map<MiUser['id'], UserRelation>,
|
||||
userMemos?: Map<MiUser['id'], string | null>,
|
||||
pinNotes?: Map<MiUser['id'], MiUserNotePining[]>,
|
||||
},
|
||||
): Promise<Packed<S>> {
|
||||
const opts = Object.assign({
|
||||
|
@ -319,13 +399,41 @@ export class UserEntityService implements OnModuleInit {
|
|||
const iAmModerator = me ? await this.roleService.isModerator(me as MiUser) : false;
|
||||
if (user.isSuspended && !iAmModerator) throw new IdentifiableError('85ab9bd7-3a41-4530-959d-f07073900109', `User ${user.id} has been suspended.`);
|
||||
|
||||
const relation = meId && !isMe && isDetailed ? await this.getRelation(meId, user.id) : null;
|
||||
const pins = isDetailed ? await this.userNotePiningsRepository.createQueryBuilder('pin')
|
||||
const profile = isDetailed
|
||||
? (opts.userProfile ?? await this.userProfilesRepository.findOneByOrFail({ userId: user.id }))
|
||||
: null;
|
||||
|
||||
let relation: UserRelation | null = null;
|
||||
if (meId && !isMe && isDetailed) {
|
||||
if (opts.userRelations) {
|
||||
relation = opts.userRelations.get(user.id) ?? null;
|
||||
} else {
|
||||
relation = await this.getRelation(meId, user.id);
|
||||
}
|
||||
}
|
||||
|
||||
let memo: string | null = null;
|
||||
if (isDetailed && meId) {
|
||||
if (opts.userMemos) {
|
||||
memo = opts.userMemos.get(user.id) ?? null;
|
||||
} else {
|
||||
memo = await this.userMemosRepository.findOneBy({ userId: meId, targetUserId: user.id })
|
||||
.then(row => row?.memo ?? null);
|
||||
}
|
||||
}
|
||||
|
||||
let pins: MiUserNotePining[] = [];
|
||||
if (isDetailed) {
|
||||
if (opts.pinNotes) {
|
||||
pins = opts.pinNotes.get(user.id) ?? [];
|
||||
} else {
|
||||
pins = await this.userNotePiningsRepository.createQueryBuilder('pin')
|
||||
.where('pin.userId = :userId', { userId: user.id })
|
||||
.innerJoinAndSelect('pin.note', 'note')
|
||||
.orderBy('pin.id', 'DESC')
|
||||
.getMany() : [];
|
||||
const profile = isDetailed ? (opts.userProfile ?? await this.userProfilesRepository.findOneByOrFail({ userId: user.id })) : null;
|
||||
.getMany();
|
||||
}
|
||||
}
|
||||
|
||||
const followingCount = profile == null ? null :
|
||||
(profile.followingVisibility === 'public') || isMe ? user.followingCount :
|
||||
|
@ -416,9 +524,7 @@ export class UserEntityService implements OnModuleInit {
|
|||
twoFactorEnabled: profile!.twoFactorEnabled,
|
||||
usePasswordLessLogin: profile!.usePasswordLessLogin,
|
||||
securityKeys: profile!.twoFactorEnabled
|
||||
? this.userSecurityKeysRepository.countBy({
|
||||
userId: user.id,
|
||||
}).then(result => result >= 1)
|
||||
? this.userSecurityKeysRepository.countBy({ userId: user.id }).then(result => result >= 1)
|
||||
: false,
|
||||
roles: this.roleService.getUserRoles(user.id).then(roles => roles
|
||||
.filter(role => role.isPublic || iAmModerator)
|
||||
|
@ -434,10 +540,7 @@ export class UserEntityService implements OnModuleInit {
|
|||
displayOrder: role.displayOrder,
|
||||
}))
|
||||
),
|
||||
memo: meId == null ? null : await this.userMemosRepository.findOneBy({
|
||||
userId: meId,
|
||||
targetUserId: user.id,
|
||||
}).then(row => row?.memo ?? null),
|
||||
memo: memo,
|
||||
moderationNote: iAmModerator ? (profile!.moderationNote ?? '') : undefined,
|
||||
} : {}),
|
||||
|
||||
|
@ -525,7 +628,59 @@ export class UserEntityService implements OnModuleInit {
|
|||
includeSecrets?: boolean,
|
||||
},
|
||||
): Promise<Packed<S>[]> {
|
||||
return (await Promise.allSettled(users.map(u => this.pack(u, me, options))))
|
||||
// -- IDのみの要素を補完して完全なエンティティ一覧を作る
|
||||
|
||||
const _users = users.filter((user): user is MiUser => typeof user !== 'string');
|
||||
if (_users.length !== users.length) {
|
||||
_users.push(
|
||||
...await this.usersRepository.findBy({
|
||||
id: In(users.filter((user): user is string => typeof user === 'string')),
|
||||
}),
|
||||
);
|
||||
}
|
||||
const _userIds = _users.map(u => u.id);
|
||||
|
||||
// -- 特に前提条件のない値群を取得
|
||||
|
||||
const profilesMap = await this.userProfilesRepository.findBy({ userId: In(_userIds) })
|
||||
.then(profiles => new Map(profiles.map(p => [p.userId, p])));
|
||||
|
||||
// -- 実行者の有無や指定スキーマの種別によって要否が異なる値群を取得
|
||||
|
||||
let userRelations: Map<MiUser['id'], UserRelation> = new Map();
|
||||
let userMemos: Map<MiUser['id'], string | null> = new Map();
|
||||
let pinNotes: Map<MiUser['id'], MiUserNotePining[]> = new Map();
|
||||
|
||||
if (options?.schema !== 'UserLite') {
|
||||
const meId = me ? me.id : null;
|
||||
if (meId) {
|
||||
userMemos = await this.userMemosRepository.findBy({ userId: meId })
|
||||
.then(memos => new Map(memos.map(memo => [memo.targetUserId, memo.memo])));
|
||||
|
||||
if (_userIds.length > 0) {
|
||||
userRelations = await this.getRelations(meId, _userIds);
|
||||
pinNotes = await this.userNotePiningsRepository.createQueryBuilder('pin')
|
||||
.where('pin.userId IN (:...userIds)', { userIds: _userIds })
|
||||
.innerJoinAndSelect('pin.note', 'note')
|
||||
.getMany()
|
||||
.then(pinsNotes => {
|
||||
const map = new Map<MiUser['id'], MiUserNotePining[]>();
|
||||
for (const note of pinsNotes) {
|
||||
const notes = map.get(note.userId) ?? [];
|
||||
notes.push(note);
|
||||
map.set(note.userId, notes);
|
||||
}
|
||||
for (const [, notes] of map.entries()) {
|
||||
// pack側ではDESCで取得しているので、それに合わせて降順に並び替えておく
|
||||
notes.sort((a, b) => b.id.localeCompare(a.id));
|
||||
}
|
||||
return map;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (await Promise.allSettled(_users.map(u => this.pack(u, me, { ...options, userProfile: profilesMap.get(u.id), userRelations: userRelations, userMemos: userMemos, pinNotes: pinNotes }))))
|
||||
.filter(result => result.status === 'fulfilled')
|
||||
.map(result => (result as PromiseFulfilledResult<Packed<S>>).value);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import type { onRequestHookHandler } from 'fastify';
|
||||
|
||||
export const handleRequestRedirectToOmitSearch: onRequestHookHandler = (request, reply, done) => {
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import type { MiNote } from '@/models/Note.js';
|
||||
|
||||
export function isPureRenote(note: MiNote): note is MiNote & { renoteId: NonNullable<MiNote['renoteId']> } {
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export type FetchFunction<K, V> = (key: K) => Promise<V>;
|
||||
|
||||
type ResolveReject<V> = Parameters<ConstructorParameters<typeof Promise<V>>[0]>;
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { PrimaryColumn, Entity, Index, JoinColumn, Column, ManyToOne } from 'typeorm';
|
||||
import { id } from './util/id.js';
|
||||
import { MiUser } from './User.js';
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export const packedSigninSchema = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
|
|
|
@ -68,7 +68,7 @@ export const paramDef = {
|
|||
withFile: { type: 'boolean' },
|
||||
notify: { type: 'boolean' },
|
||||
},
|
||||
required: ['antennaId', 'name', 'src', 'keywords', 'excludeKeywords', 'users', 'caseSensitive', 'withReplies', 'withFile', 'notify'],
|
||||
required: ['antennaId'],
|
||||
} as const;
|
||||
|
||||
@Injectable()
|
||||
|
@ -84,9 +84,11 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
private globalEventService: GlobalEventService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
if (ps.keywords && ps.excludeKeywords) {
|
||||
if (ps.keywords.flat().every(x => x === '') && ps.excludeKeywords.flat().every(x => x === '')) {
|
||||
throw new Error('either keywords or excludeKeywords is required.');
|
||||
}
|
||||
}
|
||||
// Fetch the antenna
|
||||
const antenna = await this.antennasRepository.findOneBy({
|
||||
id: ps.antennaId,
|
||||
|
@ -99,7 +101,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
|
||||
let userList;
|
||||
|
||||
if (ps.src === 'list' && ps.userListId) {
|
||||
if ((ps.src === 'list' || antenna.src === 'list') && ps.userListId) {
|
||||
userList = await this.userListsRepository.findOneBy({
|
||||
id: ps.userListId,
|
||||
userId: me.id,
|
||||
|
@ -113,7 +115,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
await this.antennasRepository.update(antenna.id, {
|
||||
name: ps.name,
|
||||
src: ps.src,
|
||||
userListId: userList ? userList.id : null,
|
||||
userListId: ps.userListId !== undefined ? userList ? userList.id : null : undefined,
|
||||
keywords: ps.keywords,
|
||||
excludeKeywords: ps.excludeKeywords,
|
||||
users: ps.users,
|
||||
|
|
|
@ -132,11 +132,9 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
private userEntityService: UserEntityService,
|
||||
) {
|
||||
super(meta, paramDef, async (ps, me) => {
|
||||
const ids = Array.isArray(ps.userId) ? ps.userId : [ps.userId];
|
||||
|
||||
const relations = await Promise.all(ids.map(id => this.userEntityService.getRelation(me.id, id)));
|
||||
|
||||
return Array.isArray(ps.userId) ? relations : relations[0];
|
||||
return Array.isArray(ps.userId)
|
||||
? await this.userEntityService.getRelations(me.id, ps.userId).then(it => [...it.values()])
|
||||
: await this.userEntityService.getRelation(me.id, ps.userId).then(it => [it]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,7 +248,7 @@ describe('2要素認証', () => {
|
|||
keyName,
|
||||
credentialId,
|
||||
creationOptions: registerKeyResponse.body,
|
||||
}) as any, alice);
|
||||
}) as FIXME, alice);
|
||||
assert.strictEqual(keyDoneResponse.status, 200);
|
||||
assert.strictEqual(keyDoneResponse.body.id, credentialId.toString('base64url'));
|
||||
assert.strictEqual(keyDoneResponse.body.name, keyName);
|
||||
|
@ -307,7 +307,7 @@ describe('2要素認証', () => {
|
|||
keyName,
|
||||
credentialId,
|
||||
creationOptions: registerKeyResponse.body,
|
||||
}) as any, alice);
|
||||
}) as FIXME, alice);
|
||||
assert.strictEqual(keyDoneResponse.status, 200);
|
||||
|
||||
const passwordLessResponse = await api('i/2fa/password-less', {
|
||||
|
@ -370,7 +370,7 @@ describe('2要素認証', () => {
|
|||
keyName,
|
||||
credentialId,
|
||||
creationOptions: registerKeyResponse.body,
|
||||
}) as any, alice);
|
||||
}) as FIXME, alice);
|
||||
assert.strictEqual(keyDoneResponse.status, 200);
|
||||
|
||||
const renamedKey = 'other-key';
|
||||
|
@ -419,7 +419,7 @@ describe('2要素認証', () => {
|
|||
keyName,
|
||||
credentialId,
|
||||
creationOptions: registerKeyResponse.body,
|
||||
}) as any, alice);
|
||||
}) as FIXME, alice);
|
||||
assert.strictEqual(keyDoneResponse.status, 200);
|
||||
|
||||
// テストの実行順によっては複数残ってるので全部消す
|
||||
|
|
|
@ -86,7 +86,7 @@ describe('クリップ', () => {
|
|||
...request,
|
||||
}, {
|
||||
status: 204,
|
||||
}) as any as void;
|
||||
}) as FIXME as void;
|
||||
};
|
||||
|
||||
const show = async (parameters: Misskey.entities.ClipsShowRequest, request: Partial<ApiRequest<'clips/show'>> = {}): Promise<Misskey.entities.Clip> => {
|
||||
|
@ -234,7 +234,7 @@ describe('クリップ', () => {
|
|||
code: 'NO_SUCH_CLIP',
|
||||
id: 'b4d92d70-b216-46fa-9a3f-a8c811699257',
|
||||
} },
|
||||
...createClipDenyPattern as any,
|
||||
...createClipDenyPattern as FIXME,
|
||||
])('の更新は$labelならできない', async ({ parameters, user, assertion }) => failedApiCall({
|
||||
endpoint: 'clips/update',
|
||||
parameters: {
|
||||
|
@ -462,7 +462,7 @@ describe('クリップ', () => {
|
|||
...request,
|
||||
}, {
|
||||
status: 204,
|
||||
}) as any as void;
|
||||
}) as FIXME as void;
|
||||
};
|
||||
|
||||
const unfavorite = async (parameters: Misskey.entities.ClipsUnfavoriteRequest, request: Partial<ApiRequest<'clips/unfavorite'>> = {}): Promise<void> => {
|
||||
|
@ -473,7 +473,7 @@ describe('クリップ', () => {
|
|||
...request,
|
||||
}, {
|
||||
status: 204,
|
||||
}) as any as void;
|
||||
}) as FIXME as void;
|
||||
};
|
||||
|
||||
const myFavorites = async (request: Partial<ApiRequest<'clips/my-favorites'>> = {}): Promise<Misskey.entities.Clip[]> => {
|
||||
|
@ -648,7 +648,7 @@ describe('クリップ', () => {
|
|||
...request,
|
||||
}, {
|
||||
status: 204,
|
||||
}) as any as void;
|
||||
}) as FIXME as void;
|
||||
};
|
||||
|
||||
const removeNote = async (parameters: Misskey.entities.ClipsRemoveNoteRequest, request: Partial<ApiRequest<'clips/remove-note'>> = {}): Promise<void> => {
|
||||
|
@ -659,7 +659,7 @@ describe('クリップ', () => {
|
|||
...request,
|
||||
}, {
|
||||
status: 204,
|
||||
}) as any as void;
|
||||
}) as FIXME as void;
|
||||
};
|
||||
|
||||
const notes = async (parameters: Misskey.entities.ClipsNotesRequest, request: Partial<ApiRequest<'clips/notes'>> = {}): Promise<Misskey.entities.Note[]> => {
|
||||
|
|
|
@ -447,8 +447,8 @@ describe('Account Move', () => {
|
|||
const res = await uploadFile(alice);
|
||||
|
||||
assert.strictEqual(res.status, 403);
|
||||
assert.strictEqual((res.body! as any as { error: misskey.api.APIError }).error.code, 'YOUR_ACCOUNT_MOVED');
|
||||
assert.strictEqual((res.body! as any as { error: misskey.api.APIError }).error.id, '56f20ec9-fd06-4fa5-841b-edd6d7d4fa31');
|
||||
assert.strictEqual((res.body! as FIXME as { error: misskey.api.APIError }).error.code, 'YOUR_ACCOUNT_MOVED');
|
||||
assert.strictEqual((res.body! as FIXME as { error: misskey.api.APIError }).error.id, '56f20ec9-fd06-4fa5-841b-edd6d7d4fa31');
|
||||
});
|
||||
|
||||
test('Prohibit updating alsoKnownAs after moving', async () => {
|
||||
|
|
|
@ -14,7 +14,7 @@ describe('nodeinfo', () => {
|
|||
assert.ok(res.ok);
|
||||
assert.strictEqual(res.headers.get('Access-Control-Allow-Origin'), '*');
|
||||
|
||||
const nodeInfo = await res.json() as any;
|
||||
const nodeInfo = await res.json() as FIXME;
|
||||
assert.strictEqual(nodeInfo.software.name, 'misskey');
|
||||
});
|
||||
|
||||
|
@ -23,7 +23,7 @@ describe('nodeinfo', () => {
|
|||
assert.ok(res.ok);
|
||||
assert.strictEqual(res.headers.get('Access-Control-Allow-Origin'), '*');
|
||||
|
||||
const nodeInfo = await res.json() as any;
|
||||
const nodeInfo = await res.json() as FIXME;
|
||||
assert.strictEqual(nodeInfo.software.name, 'misskey');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -474,7 +474,7 @@ describe('Note', () => {
|
|||
priority: 0,
|
||||
value: true,
|
||||
},
|
||||
},
|
||||
} as FIXME,
|
||||
}, alice);
|
||||
|
||||
assert.strictEqual(res.status, 200);
|
||||
|
@ -787,7 +787,7 @@ describe('Note', () => {
|
|||
priority: 1,
|
||||
value: 0,
|
||||
},
|
||||
},
|
||||
} as FIXME,
|
||||
}, alice);
|
||||
|
||||
assert.strictEqual(res.status, 200);
|
||||
|
@ -841,7 +841,7 @@ describe('Note', () => {
|
|||
priority: 1,
|
||||
value: 0,
|
||||
},
|
||||
},
|
||||
} as FIXME,
|
||||
}, alice);
|
||||
|
||||
assert.strictEqual(res.status, 200);
|
||||
|
@ -897,7 +897,7 @@ describe('Note', () => {
|
|||
priority: 1,
|
||||
value: 1,
|
||||
},
|
||||
},
|
||||
} as FIXME,
|
||||
}, alice);
|
||||
|
||||
assert.strictEqual(res.status, 200);
|
||||
|
|
|
@ -890,17 +890,35 @@ describe('Timelines', () => {
|
|||
|
||||
const list = await api('users/lists/create', { name: 'list' }, alice).then(res => res.body);
|
||||
await api('users/lists/push', { listId: list.id, userId: bob.id }, alice);
|
||||
await api('users/lists/update-membership', { listId: list.id, userId: bob.id, withReplies: false }, alice);
|
||||
await sleep(1000);
|
||||
const aliceNote = await post(alice, { text: 'hi' });
|
||||
const bobNote = await post(bob, { text: 'hi', replyId: aliceNote.id });
|
||||
|
||||
await waitForPushToTl();
|
||||
|
||||
const res = await api('notes/user-list-timeline', { listId: list.id, withReplies: false }, alice);
|
||||
const res = await api('notes/user-list-timeline', { listId: list.id }, alice);
|
||||
|
||||
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), true);
|
||||
});
|
||||
|
||||
test.concurrent('withReplies: false でリスインしているフォローしていないユーザーの他人への返信が含まれない', async () => {
|
||||
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
||||
|
||||
const list = await api('users/lists/create', { name: 'list' }, alice).then(res => res.body);
|
||||
await api('users/lists/push', { listId: list.id, userId: bob.id }, alice);
|
||||
await api('users/lists/update-membership', { listId: list.id, userId: bob.id, withReplies: false }, alice);
|
||||
await sleep(1000);
|
||||
const carolNote = await post(carol, { text: 'hi' });
|
||||
const bobNote = await post(bob, { text: 'hi', replyId: carolNote.id });
|
||||
|
||||
await waitForPushToTl();
|
||||
|
||||
const res = await api('notes/user-list-timeline', { listId: list.id }, alice);
|
||||
|
||||
assert.strictEqual(res.body.some((note: any) => note.id === bobNote.id), false);
|
||||
});
|
||||
|
||||
test.concurrent('withReplies: true でリスインしているフォローしていないユーザーの他人への返信が含まれる', async () => {
|
||||
const [alice, bob, carol] = await Promise.all([signup(), signup(), signup()]);
|
||||
|
||||
|
|
|
@ -633,7 +633,7 @@ describe('ユーザー', () => {
|
|||
{ label: 'フォローリクエストされている', user: () => userFollowRequesting, me: () => userFollowRequested, selector: (user: misskey.entities.UserDetailed) => user.hasPendingFollowRequestToYou },
|
||||
] as const)('を取得することができ、$labelこと', async ({ user, me, selector, expected }) => {
|
||||
const response = await successfulApiCall({ endpoint: 'users/show', parameters: { userId: user().id }, user: me?.() ?? alice });
|
||||
assert.strictEqual(selector(response as any), (expected ?? ((): true => true))());
|
||||
assert.strictEqual(selector(response as FIXME), (expected ?? ((): true => true))());
|
||||
});
|
||||
test('を取得することができ、Publicなロールがセットされていること', async () => {
|
||||
const response = await successfulApiCall({ endpoint: 'users/show', parameters: { userId: userRolePublic.id }, user: alice });
|
||||
|
|
|
@ -95,7 +95,7 @@ describe('.well-known', () => {
|
|||
assert.ok(res.ok);
|
||||
assert.strictEqual(res.headers.get('Access-Control-Allow-Origin'), '*');
|
||||
|
||||
const serverInfo = await res.json() as any;
|
||||
const serverInfo = await res.json() as FIXME;
|
||||
assert.strictEqual(serverInfo.issuer, origin);
|
||||
assert.strictEqual(serverInfo.authorization_endpoint, `${origin}/oauth/authorize`);
|
||||
assert.strictEqual(serverInfo.token_endpoint, `${origin}/oauth/token`);
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
type FIXME = any;
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { initTestDb, sendEnvResetRequest } from './utils.js';
|
||||
|
||||
beforeAll(async () => {
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
*/
|
||||
|
||||
import Ajv from 'ajv';
|
||||
import { Schema } from '@/misc/schema';
|
||||
import { Schema } from '@/misc/json-schema.js';
|
||||
|
||||
export const getValidator = (paramDef: Schema) => {
|
||||
const ajv = new Ajv({
|
||||
const ajv = new Ajv.default({
|
||||
useDefaults: true,
|
||||
});
|
||||
ajv.addFormat('misskey:id', /^[a-zA-Z0-9]+$/);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
"noImplicitAny": true,
|
||||
"noImplicitReturns": true,
|
||||
"noUnusedParameters": false,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedLocals": false,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"declaration": false,
|
||||
"sourceMap": true,
|
||||
|
@ -18,6 +18,7 @@
|
|||
"strict": true,
|
||||
"strictNullChecks": true,
|
||||
"strictPropertyInitialization": false,
|
||||
"skipLibCheck": true,
|
||||
"experimentalDecorators": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"resolveJsonModule": true,
|
||||
|
|
|
@ -178,7 +178,7 @@ describe('AnnouncementService', () => {
|
|||
|
||||
expect(globalEventService.publishBroadcastStream).toHaveBeenCalled();
|
||||
expect(globalEventService.publishBroadcastStream.mock.lastCall![0]).toBe('announcementCreated');
|
||||
expect((globalEventService.publishBroadcastStream.mock.lastCall![1] as any).announcement).toBe(result.packed);
|
||||
expect((globalEventService.publishBroadcastStream.mock.lastCall![1] as FIXME).announcement).toBe(result.packed);
|
||||
expect(moderationLogService.log).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
@ -198,7 +198,7 @@ describe('AnnouncementService', () => {
|
|||
expect(globalEventService.publishMainStream).toHaveBeenCalled();
|
||||
expect(globalEventService.publishMainStream.mock.lastCall![0]).toBe(user.id);
|
||||
expect(globalEventService.publishMainStream.mock.lastCall![1]).toBe('announcementCreated');
|
||||
expect((globalEventService.publishMainStream.mock.lastCall![2] as any).announcement).toBe(result.packed);
|
||||
expect((globalEventService.publishMainStream.mock.lastCall![2] as FIXME).announcement).toBe(result.packed);
|
||||
expect(moderationLogService.log).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { Test } from '@nestjs/testing';
|
||||
|
||||
|
@ -21,7 +26,7 @@ describe('ApMfmService', () => {
|
|||
const note: MiNote = {
|
||||
text: 'テキスト #タグ @mention 🍊 :emoji: https://example.com',
|
||||
mentionedRemoteUsers: '[]',
|
||||
} as any;
|
||||
} as FIXME;
|
||||
|
||||
const { content, noMisskeyContent } = apMfmService.getNoteHtml(note);
|
||||
|
||||
|
@ -33,7 +38,7 @@ describe('ApMfmService', () => {
|
|||
const note: MiNote = {
|
||||
text: '$[tada foo]',
|
||||
mentionedRemoteUsers: '[]',
|
||||
} as any;
|
||||
} as FIXME;
|
||||
|
||||
const { content, noMisskeyContent } = apMfmService.getNoteHtml(note);
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ process.env.NODE_ENV = 'test';
|
|||
|
||||
import { jest } from '@jest/globals';
|
||||
import { Test } from '@nestjs/testing';
|
||||
import { Redis } from 'ioredis';
|
||||
import { GlobalModule } from '@/GlobalModule.js';
|
||||
import { FetchInstanceMetadataService } from '@/core/FetchInstanceMetadataService.js';
|
||||
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
||||
|
@ -18,15 +17,16 @@ import { IdService } from '@/core/IdService.js';
|
|||
import { DI } from '@/di-symbols.js';
|
||||
import type { TestingModule } from '@nestjs/testing';
|
||||
|
||||
function mockRedis() {
|
||||
const hash = {} as any;
|
||||
const set = jest.fn((key: string, value) => {
|
||||
// このテストで呼び出すSETにはNXオプションが付いてる
|
||||
if (hash[key]) return null;
|
||||
function mockRedisSetNX() {
|
||||
const hash = {} as FIXME;
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
return jest.fn((key: string, value, secondsToken: 'EX', seconds: number, nx: 'NX', callback?): Promise<'OK' | null> => {
|
||||
return new Promise(resolve => {
|
||||
if (hash[key]) return resolve(null);
|
||||
hash[key] = value;
|
||||
return 'OK';
|
||||
resolve('OK');
|
||||
});
|
||||
});
|
||||
return set;
|
||||
}
|
||||
|
||||
describe('FetchInstanceMetadataService', () => {
|
||||
|
@ -34,7 +34,6 @@ describe('FetchInstanceMetadataService', () => {
|
|||
let fetchInstanceMetadataService: jest.Mocked<FetchInstanceMetadataService>;
|
||||
let federatedInstanceService: jest.Mocked<FederatedInstanceService>;
|
||||
let httpRequestService: jest.Mocked<HttpRequestService>;
|
||||
let redisClient: jest.Mocked<Redis>;
|
||||
|
||||
beforeEach(async () => {
|
||||
app = await Test
|
||||
|
@ -55,7 +54,7 @@ describe('FetchInstanceMetadataService', () => {
|
|||
} else if (token === FederatedInstanceService) {
|
||||
return { fetch: jest.fn() };
|
||||
} else if (token === DI.redis) {
|
||||
return mockRedis;
|
||||
return { set: mockRedisSetNX() };
|
||||
}
|
||||
return null;
|
||||
})
|
||||
|
@ -65,7 +64,6 @@ describe('FetchInstanceMetadataService', () => {
|
|||
|
||||
fetchInstanceMetadataService = app.get<FetchInstanceMetadataService>(FetchInstanceMetadataService) as jest.Mocked<FetchInstanceMetadataService>;
|
||||
federatedInstanceService = app.get<FederatedInstanceService>(FederatedInstanceService) as jest.Mocked<FederatedInstanceService>;
|
||||
redisClient = app.get<Redis>(DI.redis) as jest.Mocked<Redis>;
|
||||
httpRequestService = app.get<HttpRequestService>(HttpRequestService) as jest.Mocked<HttpRequestService>;
|
||||
});
|
||||
|
||||
|
@ -74,14 +72,13 @@ describe('FetchInstanceMetadataService', () => {
|
|||
});
|
||||
|
||||
test('Lock and update', async () => {
|
||||
redisClient.set = mockRedis();
|
||||
const now = Date.now();
|
||||
federatedInstanceService.fetch.mockResolvedValue({ infoUpdatedAt: { getTime: () => { return now - 10 * 1000 * 60 * 60 * 24; } } } as any);
|
||||
federatedInstanceService.fetch.mockResolvedValue({ infoUpdatedAt: { getTime: () => { return now - 10 * 1000 * 60 * 60 * 24; } } } as FIXME);
|
||||
httpRequestService.getJson.mockImplementation(() => { throw Error(); });
|
||||
const tryLockSpy = jest.spyOn(fetchInstanceMetadataService, 'tryLock');
|
||||
const unlockSpy = jest.spyOn(fetchInstanceMetadataService, 'unlock');
|
||||
|
||||
await fetchInstanceMetadataService.fetchInstanceMetadata({ host: 'example.com' } as any);
|
||||
await fetchInstanceMetadataService.fetchInstanceMetadata({ host: 'example.com' } as FIXME);
|
||||
expect(tryLockSpy).toHaveBeenCalledTimes(1);
|
||||
expect(unlockSpy).toHaveBeenCalledTimes(1);
|
||||
expect(federatedInstanceService.fetch).toHaveBeenCalledTimes(1);
|
||||
|
@ -89,14 +86,13 @@ describe('FetchInstanceMetadataService', () => {
|
|||
});
|
||||
|
||||
test('Lock and don\'t update', async () => {
|
||||
redisClient.set = mockRedis();
|
||||
const now = Date.now();
|
||||
federatedInstanceService.fetch.mockResolvedValue({ infoUpdatedAt: { getTime: () => now } } as any);
|
||||
federatedInstanceService.fetch.mockResolvedValue({ infoUpdatedAt: { getTime: () => now } } as FIXME);
|
||||
httpRequestService.getJson.mockImplementation(() => { throw Error(); });
|
||||
const tryLockSpy = jest.spyOn(fetchInstanceMetadataService, 'tryLock');
|
||||
const unlockSpy = jest.spyOn(fetchInstanceMetadataService, 'unlock');
|
||||
|
||||
await fetchInstanceMetadataService.fetchInstanceMetadata({ host: 'example.com' } as any);
|
||||
await fetchInstanceMetadataService.fetchInstanceMetadata({ host: 'example.com' } as FIXME);
|
||||
expect(tryLockSpy).toHaveBeenCalledTimes(1);
|
||||
expect(unlockSpy).toHaveBeenCalledTimes(1);
|
||||
expect(federatedInstanceService.fetch).toHaveBeenCalledTimes(1);
|
||||
|
@ -104,15 +100,14 @@ describe('FetchInstanceMetadataService', () => {
|
|||
});
|
||||
|
||||
test('Do nothing when lock not acquired', async () => {
|
||||
redisClient.set = mockRedis();
|
||||
const now = Date.now();
|
||||
federatedInstanceService.fetch.mockResolvedValue({ infoUpdatedAt: { getTime: () => now - 10 * 1000 * 60 * 60 * 24 } } as any);
|
||||
federatedInstanceService.fetch.mockResolvedValue({ infoUpdatedAt: { getTime: () => now - 10 * 1000 * 60 * 60 * 24 } } as FIXME);
|
||||
httpRequestService.getJson.mockImplementation(() => { throw Error(); });
|
||||
await fetchInstanceMetadataService.tryLock('example.com');
|
||||
const tryLockSpy = jest.spyOn(fetchInstanceMetadataService, 'tryLock');
|
||||
const unlockSpy = jest.spyOn(fetchInstanceMetadataService, 'unlock');
|
||||
|
||||
await fetchInstanceMetadataService.fetchInstanceMetadata({ host: 'example.com' } as any);
|
||||
await fetchInstanceMetadataService.fetchInstanceMetadata({ host: 'example.com' } as FIXME);
|
||||
expect(tryLockSpy).toHaveBeenCalledTimes(1);
|
||||
expect(unlockSpy).toHaveBeenCalledTimes(0);
|
||||
expect(federatedInstanceService.fetch).toHaveBeenCalledTimes(0);
|
||||
|
@ -120,15 +115,14 @@ describe('FetchInstanceMetadataService', () => {
|
|||
});
|
||||
|
||||
test('Do when lock not acquired but forced', async () => {
|
||||
redisClient.set = mockRedis();
|
||||
const now = Date.now();
|
||||
federatedInstanceService.fetch.mockResolvedValue({ infoUpdatedAt: { getTime: () => now - 10 * 1000 * 60 * 60 * 24 } } as any);
|
||||
federatedInstanceService.fetch.mockResolvedValue({ infoUpdatedAt: { getTime: () => now - 10 * 1000 * 60 * 60 * 24 } } as FIXME);
|
||||
httpRequestService.getJson.mockImplementation(() => { throw Error(); });
|
||||
await fetchInstanceMetadataService.tryLock('example.com');
|
||||
const tryLockSpy = jest.spyOn(fetchInstanceMetadataService, 'tryLock');
|
||||
const unlockSpy = jest.spyOn(fetchInstanceMetadataService, 'unlock');
|
||||
|
||||
await fetchInstanceMetadataService.fetchInstanceMetadata({ host: 'example.com' } as any, true);
|
||||
await fetchInstanceMetadataService.fetchInstanceMetadata({ host: 'example.com' } as FIXME, true);
|
||||
expect(tryLockSpy).toHaveBeenCalledTimes(1);
|
||||
expect(unlockSpy).toHaveBeenCalledTimes(1);
|
||||
expect(federatedInstanceService.fetch).toHaveBeenCalledTimes(0);
|
||||
|
|
|
@ -63,7 +63,7 @@ describe('FileInfoService', () => {
|
|||
|
||||
test('Empty file', async () => {
|
||||
const path = `${resources}/emptyfile`;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as FIXME;
|
||||
delete info.warnings;
|
||||
delete info.blurhash;
|
||||
delete info.sensitive;
|
||||
|
@ -84,7 +84,7 @@ describe('FileInfoService', () => {
|
|||
describe('IMAGE', () => {
|
||||
test('Generic JPEG', async () => {
|
||||
const path = `${resources}/Lenna.jpg`;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as FIXME;
|
||||
delete info.warnings;
|
||||
delete info.blurhash;
|
||||
delete info.sensitive;
|
||||
|
@ -104,7 +104,7 @@ describe('FileInfoService', () => {
|
|||
|
||||
test('Generic APNG', async () => {
|
||||
const path = `${resources}/anime.png`;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as FIXME;
|
||||
delete info.warnings;
|
||||
delete info.blurhash;
|
||||
delete info.sensitive;
|
||||
|
@ -124,7 +124,7 @@ describe('FileInfoService', () => {
|
|||
|
||||
test('Generic AGIF', async () => {
|
||||
const path = `${resources}/anime.gif`;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as FIXME;
|
||||
delete info.warnings;
|
||||
delete info.blurhash;
|
||||
delete info.sensitive;
|
||||
|
@ -144,7 +144,7 @@ describe('FileInfoService', () => {
|
|||
|
||||
test('PNG with alpha', async () => {
|
||||
const path = `${resources}/with-alpha.png`;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as FIXME;
|
||||
delete info.warnings;
|
||||
delete info.blurhash;
|
||||
delete info.sensitive;
|
||||
|
@ -164,7 +164,7 @@ describe('FileInfoService', () => {
|
|||
|
||||
test('Generic SVG', async () => {
|
||||
const path = `${resources}/image.svg`;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as FIXME;
|
||||
delete info.warnings;
|
||||
delete info.blurhash;
|
||||
delete info.sensitive;
|
||||
|
@ -185,7 +185,7 @@ describe('FileInfoService', () => {
|
|||
test('SVG with XML definition', async () => {
|
||||
// https://github.com/misskey-dev/misskey/issues/4413
|
||||
const path = `${resources}/with-xml-def.svg`;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as FIXME;
|
||||
delete info.warnings;
|
||||
delete info.blurhash;
|
||||
delete info.sensitive;
|
||||
|
@ -205,7 +205,7 @@ describe('FileInfoService', () => {
|
|||
|
||||
test('Dimension limit', async () => {
|
||||
const path = `${resources}/25000x25000.png`;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as FIXME;
|
||||
delete info.warnings;
|
||||
delete info.blurhash;
|
||||
delete info.sensitive;
|
||||
|
@ -225,7 +225,7 @@ describe('FileInfoService', () => {
|
|||
|
||||
test('Rotate JPEG', async () => {
|
||||
const path = `${resources}/rotate.jpg`;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as FIXME;
|
||||
delete info.warnings;
|
||||
delete info.blurhash;
|
||||
delete info.sensitive;
|
||||
|
@ -247,7 +247,7 @@ describe('FileInfoService', () => {
|
|||
describe('AUDIO', () => {
|
||||
test('MP3', async () => {
|
||||
const path = `${resources}/kick_gaba7.mp3`;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as FIXME;
|
||||
delete info.warnings;
|
||||
delete info.blurhash;
|
||||
delete info.sensitive;
|
||||
|
@ -267,7 +267,7 @@ describe('FileInfoService', () => {
|
|||
|
||||
test('WAV', async () => {
|
||||
const path = `${resources}/kick_gaba7.wav`;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as FIXME;
|
||||
delete info.warnings;
|
||||
delete info.blurhash;
|
||||
delete info.sensitive;
|
||||
|
@ -287,7 +287,7 @@ describe('FileInfoService', () => {
|
|||
|
||||
test('AAC', async () => {
|
||||
const path = `${resources}/kick_gaba7.aac`;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as FIXME;
|
||||
delete info.warnings;
|
||||
delete info.blurhash;
|
||||
delete info.sensitive;
|
||||
|
@ -307,7 +307,7 @@ describe('FileInfoService', () => {
|
|||
|
||||
test('FLAC', async () => {
|
||||
const path = `${resources}/kick_gaba7.flac`;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as FIXME;
|
||||
delete info.warnings;
|
||||
delete info.blurhash;
|
||||
delete info.sensitive;
|
||||
|
@ -329,7 +329,7 @@ describe('FileInfoService', () => {
|
|||
* video/webmとして検出されてしまう
|
||||
test('WEBM AUDIO', async () => {
|
||||
const path = `${resources}/kick_gaba7.webm`;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
|
||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as FIXME;
|
||||
delete info.warnings;
|
||||
delete info.blurhash;
|
||||
delete info.sensitive;
|
||||
|
|
|
@ -90,7 +90,8 @@ describe('RelayService', () => {
|
|||
|
||||
expect(queueService.deliver).toHaveBeenCalled();
|
||||
expect(queueService.deliver.mock.lastCall![1]?.type).toBe('Undo');
|
||||
expect(queueService.deliver.mock.lastCall![1]?.object.type).toBe('Follow');
|
||||
expect(typeof queueService.deliver.mock.lastCall![1]?.object).toBe('object');
|
||||
expect((queueService.deliver.mock.lastCall![1]?.object as FIXME).type).toBe('Follow');
|
||||
expect(queueService.deliver.mock.lastCall![2]).toBe('https://example.com');
|
||||
//expect(queueService.deliver.mock.lastCall![0].username).toBe('relay.actor');
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ describe('RoleService', () => {
|
|||
policies: {
|
||||
canManageCustomEmojis: false,
|
||||
},
|
||||
} as any);
|
||||
} as FIXME);
|
||||
|
||||
const result = await roleService.getUserPolicies(user.id);
|
||||
|
||||
|
@ -143,7 +143,7 @@ describe('RoleService', () => {
|
|||
policies: {
|
||||
canManageCustomEmojis: true,
|
||||
},
|
||||
} as any);
|
||||
} as FIXME);
|
||||
|
||||
const result = await roleService.getUserPolicies(user.id);
|
||||
|
||||
|
@ -167,7 +167,7 @@ describe('RoleService', () => {
|
|||
policies: {
|
||||
canManageCustomEmojis: false,
|
||||
},
|
||||
} as any);
|
||||
} as FIXME);
|
||||
|
||||
const result = await roleService.getUserPolicies(user.id);
|
||||
|
||||
|
@ -202,7 +202,7 @@ describe('RoleService', () => {
|
|||
policies: {
|
||||
driveCapacityMb: 50,
|
||||
},
|
||||
} as any);
|
||||
} as FIXME);
|
||||
|
||||
const result = await roleService.getUserPolicies(user.id);
|
||||
|
||||
|
@ -246,7 +246,7 @@ describe('RoleService', () => {
|
|||
policies: {
|
||||
canManageCustomEmojis: false,
|
||||
},
|
||||
} as any);
|
||||
} as FIXME);
|
||||
|
||||
const user1Policies = await roleService.getUserPolicies(user1.id);
|
||||
const user2Policies = await roleService.getUserPolicies(user2.id);
|
||||
|
@ -299,7 +299,7 @@ describe('RoleService', () => {
|
|||
policies: {
|
||||
canManageCustomEmojis: false,
|
||||
},
|
||||
} as any);
|
||||
} as FIXME);
|
||||
|
||||
const result = await roleService.getUserPolicies(user.id);
|
||||
expect(result.canManageCustomEmojis).toBe(true);
|
||||
|
|
|
@ -0,0 +1,528 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||
import { GlobalModule } from '@/GlobalModule.js';
|
||||
import { CoreModule } from '@/core/CoreModule.js';
|
||||
import type { MiUser } from '@/models/User.js';
|
||||
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||
import { genAidx } from '@/misc/id/aidx.js';
|
||||
import {
|
||||
BlockingsRepository,
|
||||
FollowingsRepository, FollowRequestsRepository,
|
||||
MiUserProfile, MutingsRepository, RenoteMutingsRepository,
|
||||
UserMemoRepository,
|
||||
UserProfilesRepository,
|
||||
UsersRepository,
|
||||
} from '@/models/_.js';
|
||||
import { DI } from '@/di-symbols.js';
|
||||
import { AvatarDecorationService } from '@/core/AvatarDecorationService.js';
|
||||
import { ApPersonService } from '@/core/activitypub/models/ApPersonService.js';
|
||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||
import { PageEntityService } from '@/core/entities/PageEntityService.js';
|
||||
import { CustomEmojiService } from '@/core/CustomEmojiService.js';
|
||||
import { AnnouncementService } from '@/core/AnnouncementService.js';
|
||||
import { RoleService } from '@/core/RoleService.js';
|
||||
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
||||
import { IdService } from '@/core/IdService.js';
|
||||
import { UtilityService } from '@/core/UtilityService.js';
|
||||
import { EmojiEntityService } from '@/core/entities/EmojiEntityService.js';
|
||||
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||
import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js';
|
||||
import { MetaService } from '@/core/MetaService.js';
|
||||
import { FetchInstanceMetadataService } from '@/core/FetchInstanceMetadataService.js';
|
||||
import { CacheService } from '@/core/CacheService.js';
|
||||
import { ApResolverService } from '@/core/activitypub/ApResolverService.js';
|
||||
import { ApNoteService } from '@/core/activitypub/models/ApNoteService.js';
|
||||
import { ApImageService } from '@/core/activitypub/models/ApImageService.js';
|
||||
import { ApMfmService } from '@/core/activitypub/ApMfmService.js';
|
||||
import { MfmService } from '@/core/MfmService.js';
|
||||
import { HashtagService } from '@/core/HashtagService.js';
|
||||
import UsersChart from '@/core/chart/charts/users.js';
|
||||
import { ChartLoggerService } from '@/core/chart/ChartLoggerService.js';
|
||||
import InstanceChart from '@/core/chart/charts/instance.js';
|
||||
import { ApLoggerService } from '@/core/activitypub/ApLoggerService.js';
|
||||
import { AccountMoveService } from '@/core/AccountMoveService.js';
|
||||
import { ReactionService } from '@/core/ReactionService.js';
|
||||
import { NotificationService } from '@/core/NotificationService.js';
|
||||
|
||||
process.env.NODE_ENV = 'test';
|
||||
|
||||
describe('UserEntityService', () => {
|
||||
describe('pack/packMany', () => {
|
||||
let app: TestingModule;
|
||||
let service: UserEntityService;
|
||||
let usersRepository: UsersRepository;
|
||||
let userProfileRepository: UserProfilesRepository;
|
||||
let userMemosRepository: UserMemoRepository;
|
||||
let followingRepository: FollowingsRepository;
|
||||
let followingRequestRepository: FollowRequestsRepository;
|
||||
let blockingRepository: BlockingsRepository;
|
||||
let mutingRepository: MutingsRepository;
|
||||
let renoteMutingsRepository: RenoteMutingsRepository;
|
||||
|
||||
async function createUser(userData: Partial<MiUser> = {}, profileData: Partial<MiUserProfile> = {}) {
|
||||
const un = secureRndstr(16);
|
||||
const user = await usersRepository
|
||||
.insert({
|
||||
...userData,
|
||||
id: genAidx(Date.now()),
|
||||
username: un,
|
||||
usernameLower: un,
|
||||
})
|
||||
.then(x => usersRepository.findOneByOrFail(x.identifiers[0]));
|
||||
|
||||
await userProfileRepository.insert({
|
||||
...profileData,
|
||||
userId: user.id,
|
||||
});
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
async function memo(writer: MiUser, target: MiUser, memo: string) {
|
||||
await userMemosRepository.insert({
|
||||
id: genAidx(Date.now()),
|
||||
userId: writer.id,
|
||||
targetUserId: target.id,
|
||||
memo,
|
||||
});
|
||||
}
|
||||
|
||||
async function follow(follower: MiUser, followee: MiUser) {
|
||||
await followingRepository.insert({
|
||||
id: genAidx(Date.now()),
|
||||
followerId: follower.id,
|
||||
followeeId: followee.id,
|
||||
});
|
||||
}
|
||||
|
||||
async function requestFollow(requester: MiUser, requestee: MiUser) {
|
||||
await followingRequestRepository.insert({
|
||||
id: genAidx(Date.now()),
|
||||
followerId: requester.id,
|
||||
followeeId: requestee.id,
|
||||
});
|
||||
}
|
||||
|
||||
async function block(blocker: MiUser, blockee: MiUser) {
|
||||
await blockingRepository.insert({
|
||||
id: genAidx(Date.now()),
|
||||
blockerId: blocker.id,
|
||||
blockeeId: blockee.id,
|
||||
});
|
||||
}
|
||||
|
||||
async function mute(mutant: MiUser, mutee: MiUser) {
|
||||
await mutingRepository.insert({
|
||||
id: genAidx(Date.now()),
|
||||
muterId: mutant.id,
|
||||
muteeId: mutee.id,
|
||||
});
|
||||
}
|
||||
|
||||
async function muteRenote(mutant: MiUser, mutee: MiUser) {
|
||||
await renoteMutingsRepository.insert({
|
||||
id: genAidx(Date.now()),
|
||||
muterId: mutant.id,
|
||||
muteeId: mutee.id,
|
||||
});
|
||||
}
|
||||
|
||||
function randomIntRange(weight = 10) {
|
||||
return [...Array(Math.floor(Math.random() * weight))].map((it, idx) => idx);
|
||||
}
|
||||
|
||||
beforeAll(async () => {
|
||||
const services = [
|
||||
UserEntityService,
|
||||
ApPersonService,
|
||||
NoteEntityService,
|
||||
PageEntityService,
|
||||
CustomEmojiService,
|
||||
AnnouncementService,
|
||||
RoleService,
|
||||
FederatedInstanceService,
|
||||
IdService,
|
||||
AvatarDecorationService,
|
||||
UtilityService,
|
||||
EmojiEntityService,
|
||||
ModerationLogService,
|
||||
GlobalEventService,
|
||||
DriveFileEntityService,
|
||||
MetaService,
|
||||
FetchInstanceMetadataService,
|
||||
CacheService,
|
||||
ApResolverService,
|
||||
ApNoteService,
|
||||
ApImageService,
|
||||
ApMfmService,
|
||||
MfmService,
|
||||
HashtagService,
|
||||
UsersChart,
|
||||
ChartLoggerService,
|
||||
InstanceChart,
|
||||
ApLoggerService,
|
||||
AccountMoveService,
|
||||
ReactionService,
|
||||
NotificationService,
|
||||
];
|
||||
|
||||
app = await Test.createTestingModule({
|
||||
imports: [GlobalModule, CoreModule],
|
||||
providers: [
|
||||
...services,
|
||||
...services.map(x => ({ provide: x.name, useExisting: x })),
|
||||
],
|
||||
}).compile();
|
||||
await app.init();
|
||||
app.enableShutdownHooks();
|
||||
|
||||
service = app.get<UserEntityService>(UserEntityService);
|
||||
usersRepository = app.get<UsersRepository>(DI.usersRepository);
|
||||
userProfileRepository = app.get<UserProfilesRepository>(DI.userProfilesRepository);
|
||||
userMemosRepository = app.get<UserMemoRepository>(DI.userMemosRepository);
|
||||
followingRepository = app.get<FollowingsRepository>(DI.followingsRepository);
|
||||
followingRequestRepository = app.get<FollowRequestsRepository>(DI.followRequestsRepository);
|
||||
blockingRepository = app.get<BlockingsRepository>(DI.blockingsRepository);
|
||||
mutingRepository = app.get<MutingsRepository>(DI.mutingsRepository);
|
||||
renoteMutingsRepository = app.get<RenoteMutingsRepository>(DI.renoteMutingsRepository);
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
await app.close();
|
||||
});
|
||||
|
||||
test('UserLite', async() => {
|
||||
const me = await createUser();
|
||||
const who = await createUser();
|
||||
|
||||
await memo(me, who, 'memo');
|
||||
|
||||
const actual = await service.pack(who, me, { schema: 'UserLite' }) as FIXME;
|
||||
// no detail
|
||||
expect(actual.memo).toBeUndefined();
|
||||
// no detail and me
|
||||
expect(actual.birthday).toBeUndefined();
|
||||
// no detail and me
|
||||
expect(actual.achievements).toBeUndefined();
|
||||
});
|
||||
|
||||
test('UserDetailedNotMe', async() => {
|
||||
const me = await createUser();
|
||||
const who = await createUser({}, { birthday: '2000-01-01' });
|
||||
|
||||
await memo(me, who, 'memo');
|
||||
|
||||
const actual = await service.pack(who, me, { schema: 'UserDetailedNotMe' }) as FIXME;
|
||||
// is detail
|
||||
expect(actual.memo).toBe('memo');
|
||||
// is detail
|
||||
expect(actual.birthday).toBe('2000-01-01');
|
||||
// no detail and me
|
||||
expect(actual.achievements).toBeUndefined();
|
||||
});
|
||||
|
||||
test('MeDetailed', async() => {
|
||||
const achievements = [{ name: 'achievement', unlockedAt: new Date().getTime() }];
|
||||
const me = await createUser({}, {
|
||||
birthday: '2000-01-01',
|
||||
achievements: achievements,
|
||||
});
|
||||
await memo(me, me, 'memo');
|
||||
|
||||
const actual = await service.pack(me, me, { schema: 'MeDetailed' }) as FIXME;
|
||||
// is detail
|
||||
expect(actual.memo).toBe('memo');
|
||||
// is detail
|
||||
expect(actual.birthday).toBe('2000-01-01');
|
||||
// is detail and me
|
||||
expect(actual.achievements).toEqual(achievements);
|
||||
});
|
||||
|
||||
describe('packManyによるpreloadがある時、preloadが無い時とpackの結果が同じになるか見たい', () => {
|
||||
test('no-preload', async() => {
|
||||
const me = await createUser();
|
||||
// meがフォローしてる人たち
|
||||
const followeeMe = await Promise.all(randomIntRange().map(() => createUser()));
|
||||
for (const who of followeeMe) {
|
||||
await follow(me, who);
|
||||
const actual = await service.pack(who, me, { schema: 'UserDetailed' }) as FIXME;
|
||||
expect(actual.isFollowing).toBe(true);
|
||||
expect(actual.isFollowed).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestFromYou).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestToYou).toBe(false);
|
||||
expect(actual.isBlocking).toBe(false);
|
||||
expect(actual.isBlocked).toBe(false);
|
||||
expect(actual.isMuted).toBe(false);
|
||||
expect(actual.isRenoteMuted).toBe(false);
|
||||
}
|
||||
|
||||
// meをフォローしてる人たち
|
||||
const followerMe = await Promise.all(randomIntRange().map(() => createUser()));
|
||||
for (const who of followerMe) {
|
||||
await follow(who, me);
|
||||
const actual = await service.pack(who, me, { schema: 'UserDetailed' }) as FIXME;
|
||||
expect(actual.isFollowing).toBe(false);
|
||||
expect(actual.isFollowed).toBe(true);
|
||||
expect(actual.hasPendingFollowRequestFromYou).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestToYou).toBe(false);
|
||||
expect(actual.isBlocking).toBe(false);
|
||||
expect(actual.isBlocked).toBe(false);
|
||||
expect(actual.isMuted).toBe(false);
|
||||
expect(actual.isRenoteMuted).toBe(false);
|
||||
}
|
||||
|
||||
// meがフォローリクエストを送った人たち
|
||||
const requestsFromYou = await Promise.all(randomIntRange().map(() => createUser()));
|
||||
for (const who of requestsFromYou) {
|
||||
await requestFollow(me, who);
|
||||
const actual = await service.pack(who, me, { schema: 'UserDetailed' }) as FIXME;
|
||||
expect(actual.isFollowing).toBe(false);
|
||||
expect(actual.isFollowed).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestFromYou).toBe(true);
|
||||
expect(actual.hasPendingFollowRequestToYou).toBe(false);
|
||||
expect(actual.isBlocking).toBe(false);
|
||||
expect(actual.isBlocked).toBe(false);
|
||||
expect(actual.isMuted).toBe(false);
|
||||
expect(actual.isRenoteMuted).toBe(false);
|
||||
}
|
||||
|
||||
// meにフォローリクエストを送った人たち
|
||||
const requestsToYou = await Promise.all(randomIntRange().map(() => createUser()));
|
||||
for (const who of requestsToYou) {
|
||||
await requestFollow(who, me);
|
||||
const actual = await service.pack(who, me, { schema: 'UserDetailed' }) as FIXME;
|
||||
expect(actual.isFollowing).toBe(false);
|
||||
expect(actual.isFollowed).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestFromYou).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestToYou).toBe(true);
|
||||
expect(actual.isBlocking).toBe(false);
|
||||
expect(actual.isBlocked).toBe(false);
|
||||
expect(actual.isMuted).toBe(false);
|
||||
expect(actual.isRenoteMuted).toBe(false);
|
||||
}
|
||||
|
||||
// meがブロックしてる人たち
|
||||
const blockingYou = await Promise.all(randomIntRange().map(() => createUser()));
|
||||
for (const who of blockingYou) {
|
||||
await block(me, who);
|
||||
const actual = await service.pack(who, me, { schema: 'UserDetailed' }) as FIXME;
|
||||
expect(actual.isFollowing).toBe(false);
|
||||
expect(actual.isFollowed).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestFromYou).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestToYou).toBe(false);
|
||||
expect(actual.isBlocking).toBe(true);
|
||||
expect(actual.isBlocked).toBe(false);
|
||||
expect(actual.isMuted).toBe(false);
|
||||
expect(actual.isRenoteMuted).toBe(false);
|
||||
}
|
||||
|
||||
// meをブロックしてる人たち
|
||||
const blockingMe = await Promise.all(randomIntRange().map(() => createUser()));
|
||||
for (const who of blockingMe) {
|
||||
await block(who, me);
|
||||
const actual = await service.pack(who, me, { schema: 'UserDetailed' }) as FIXME;
|
||||
expect(actual.isFollowing).toBe(false);
|
||||
expect(actual.isFollowed).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestFromYou).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestToYou).toBe(false);
|
||||
expect(actual.isBlocking).toBe(false);
|
||||
expect(actual.isBlocked).toBe(true);
|
||||
expect(actual.isMuted).toBe(false);
|
||||
expect(actual.isRenoteMuted).toBe(false);
|
||||
}
|
||||
|
||||
// meがミュートしてる人たち
|
||||
const muters = await Promise.all(randomIntRange().map(() => createUser()));
|
||||
for (const who of muters) {
|
||||
await mute(me, who);
|
||||
const actual = await service.pack(who, me, { schema: 'UserDetailed' }) as FIXME;
|
||||
expect(actual.isFollowing).toBe(false);
|
||||
expect(actual.isFollowed).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestFromYou).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestToYou).toBe(false);
|
||||
expect(actual.isBlocking).toBe(false);
|
||||
expect(actual.isBlocked).toBe(false);
|
||||
expect(actual.isMuted).toBe(true);
|
||||
expect(actual.isRenoteMuted).toBe(false);
|
||||
}
|
||||
|
||||
// meがリノートミュートしてる人たち
|
||||
const renoteMuters = await Promise.all(randomIntRange().map(() => createUser()));
|
||||
for (const who of renoteMuters) {
|
||||
await muteRenote(me, who);
|
||||
const actual = await service.pack(who, me, { schema: 'UserDetailed' }) as FIXME;
|
||||
expect(actual.isFollowing).toBe(false);
|
||||
expect(actual.isFollowed).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestFromYou).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestToYou).toBe(false);
|
||||
expect(actual.isBlocking).toBe(false);
|
||||
expect(actual.isBlocked).toBe(false);
|
||||
expect(actual.isMuted).toBe(false);
|
||||
expect(actual.isRenoteMuted).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
test('preload', async() => {
|
||||
const me = await createUser();
|
||||
|
||||
{
|
||||
// meがフォローしてる人たち
|
||||
const followeeMe = await Promise.all(randomIntRange().map(() => createUser()));
|
||||
for (const who of followeeMe) {
|
||||
await follow(me, who);
|
||||
}
|
||||
const actualList = await service.packMany(followeeMe, me, { schema: 'UserDetailed' }) as FIXME;
|
||||
for (const actual of actualList) {
|
||||
expect(actual.isFollowing).toBe(true);
|
||||
expect(actual.isFollowed).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestFromYou).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestToYou).toBe(false);
|
||||
expect(actual.isBlocking).toBe(false);
|
||||
expect(actual.isBlocked).toBe(false);
|
||||
expect(actual.isMuted).toBe(false);
|
||||
expect(actual.isRenoteMuted).toBe(false);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// meをフォローしてる人たち
|
||||
const followerMe = await Promise.all(randomIntRange().map(() => createUser()));
|
||||
for (const who of followerMe) {
|
||||
await follow(who, me);
|
||||
}
|
||||
const actualList = await service.packMany(followerMe, me, { schema: 'UserDetailed' }) as FIXME;
|
||||
for (const actual of actualList) {
|
||||
expect(actual.isFollowing).toBe(false);
|
||||
expect(actual.isFollowed).toBe(true);
|
||||
expect(actual.hasPendingFollowRequestFromYou).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestToYou).toBe(false);
|
||||
expect(actual.isBlocking).toBe(false);
|
||||
expect(actual.isBlocked).toBe(false);
|
||||
expect(actual.isMuted).toBe(false);
|
||||
expect(actual.isRenoteMuted).toBe(false);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// meがフォローリクエストを送った人たち
|
||||
const requestsFromYou = await Promise.all(randomIntRange().map(() => createUser()));
|
||||
for (const who of requestsFromYou) {
|
||||
await requestFollow(me, who);
|
||||
}
|
||||
const actualList = await service.packMany(requestsFromYou, me, { schema: 'UserDetailed' }) as FIXME;
|
||||
for (const actual of actualList) {
|
||||
expect(actual.isFollowing).toBe(false);
|
||||
expect(actual.isFollowed).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestFromYou).toBe(true);
|
||||
expect(actual.hasPendingFollowRequestToYou).toBe(false);
|
||||
expect(actual.isBlocking).toBe(false);
|
||||
expect(actual.isBlocked).toBe(false);
|
||||
expect(actual.isMuted).toBe(false);
|
||||
expect(actual.isRenoteMuted).toBe(false);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// meにフォローリクエストを送った人たち
|
||||
const requestsToYou = await Promise.all(randomIntRange().map(() => createUser()));
|
||||
for (const who of requestsToYou) {
|
||||
await requestFollow(who, me);
|
||||
}
|
||||
const actualList = await service.packMany(requestsToYou, me, { schema: 'UserDetailed' }) as FIXME;
|
||||
for (const actual of actualList) {
|
||||
expect(actual.isFollowing).toBe(false);
|
||||
expect(actual.isFollowed).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestFromYou).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestToYou).toBe(true);
|
||||
expect(actual.isBlocking).toBe(false);
|
||||
expect(actual.isBlocked).toBe(false);
|
||||
expect(actual.isMuted).toBe(false);
|
||||
expect(actual.isRenoteMuted).toBe(false);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// meがブロックしてる人たち
|
||||
const blockingYou = await Promise.all(randomIntRange().map(() => createUser()));
|
||||
for (const who of blockingYou) {
|
||||
await block(me, who);
|
||||
}
|
||||
const actualList = await service.packMany(blockingYou, me, { schema: 'UserDetailed' }) as FIXME;
|
||||
for (const actual of actualList) {
|
||||
expect(actual.isFollowing).toBe(false);
|
||||
expect(actual.isFollowed).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestFromYou).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestToYou).toBe(false);
|
||||
expect(actual.isBlocking).toBe(true);
|
||||
expect(actual.isBlocked).toBe(false);
|
||||
expect(actual.isMuted).toBe(false);
|
||||
expect(actual.isRenoteMuted).toBe(false);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// meをブロックしてる人たち
|
||||
const blockingMe = await Promise.all(randomIntRange().map(() => createUser()));
|
||||
for (const who of blockingMe) {
|
||||
await block(who, me);
|
||||
}
|
||||
const actualList = await service.packMany(blockingMe, me, { schema: 'UserDetailed' }) as FIXME;
|
||||
for (const actual of actualList) {
|
||||
expect(actual.isFollowing).toBe(false);
|
||||
expect(actual.isFollowed).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestFromYou).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestToYou).toBe(false);
|
||||
expect(actual.isBlocking).toBe(false);
|
||||
expect(actual.isBlocked).toBe(true);
|
||||
expect(actual.isMuted).toBe(false);
|
||||
expect(actual.isRenoteMuted).toBe(false);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// meがミュートしてる人たち
|
||||
const muters = await Promise.all(randomIntRange().map(() => createUser()));
|
||||
for (const who of muters) {
|
||||
await mute(me, who);
|
||||
}
|
||||
const actualList = await service.packMany(muters, me, { schema: 'UserDetailed' }) as FIXME;
|
||||
for (const actual of actualList) {
|
||||
expect(actual.isFollowing).toBe(false);
|
||||
expect(actual.isFollowed).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestFromYou).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestToYou).toBe(false);
|
||||
expect(actual.isBlocking).toBe(false);
|
||||
expect(actual.isBlocked).toBe(false);
|
||||
expect(actual.isMuted).toBe(true);
|
||||
expect(actual.isRenoteMuted).toBe(false);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
// meがリノートミュートしてる人たち
|
||||
const renoteMuters = await Promise.all(randomIntRange().map(() => createUser()));
|
||||
for (const who of renoteMuters) {
|
||||
await muteRenote(me, who);
|
||||
}
|
||||
const actualList = await service.packMany(renoteMuters, me, { schema: 'UserDetailed' }) as FIXME;
|
||||
for (const actual of actualList) {
|
||||
expect(actual.isFollowing).toBe(false);
|
||||
expect(actual.isFollowed).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestFromYou).toBe(false);
|
||||
expect(actual.hasPendingFollowRequestToYou).toBe(false);
|
||||
expect(actual.isBlocking).toBe(false);
|
||||
expect(actual.isBlocked).toBe(false);
|
||||
expect(actual.isMuted).toBe(false);
|
||||
expect(actual.isRenoteMuted).toBe(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { DebounceLoader } from '@/misc/loader.js';
|
||||
|
||||
class Mock {
|
||||
|
|
|
@ -194,7 +194,7 @@ export const page = async (user: UserToken, page: Partial<misskey.entities.Page>
|
|||
},
|
||||
],
|
||||
eyeCatchingImageId: null,
|
||||
font: 'sans-serif' as any,
|
||||
font: 'sans-serif' as FIXME,
|
||||
hideTitleWhenPinned: false,
|
||||
name: '1678594845072',
|
||||
script: '',
|
||||
|
@ -256,7 +256,7 @@ export const role = async (user: UserToken, role: Partial<misskey.entities.Role>
|
|||
condFormula: {
|
||||
id: 'ebef1684-672d-49b6-ad82-1b3ec3784f85',
|
||||
type: 'isRemote',
|
||||
} as any,
|
||||
} as FIXME,
|
||||
description: '',
|
||||
displayOrder: 0,
|
||||
iconUrl: null,
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
<!--
|
||||
SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
-->
|
||||
|
||||
<link rel="preload" href="https://github.com/misskey-dev/misskey/blob/master/packages/frontend/assets/about-icon.png?raw=true" as="image" type="image/png" crossorigin="anonymous">
|
||||
<link rel="preload" href="https://github.com/misskey-dev/misskey/blob/master/packages/frontend/assets/fedi.jpg?raw=true" as="image" type="image/jpeg" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://unpkg.com/@tabler/icons-webfont@2.46.0/tabler-icons.min.css">
|
||||
|
|
|
@ -178,14 +178,26 @@ export async function mainBoot() {
|
|||
if ($i.followersCount >= 500) claimAchievement('followers500');
|
||||
if ($i.followersCount >= 1000) claimAchievement('followers1000');
|
||||
|
||||
if (Date.now() - new Date($i.createdAt).getTime() > 1000 * 60 * 60 * 24 * 365) {
|
||||
const createdAt = new Date($i.createdAt);
|
||||
const createdAtThreeYearsLater = new Date($i.createdAt);
|
||||
createdAtThreeYearsLater.setFullYear(createdAtThreeYearsLater.getFullYear() + 3);
|
||||
if (now >= createdAtThreeYearsLater) {
|
||||
claimAchievement('passedSinceAccountCreated3');
|
||||
claimAchievement('passedSinceAccountCreated2');
|
||||
claimAchievement('passedSinceAccountCreated1');
|
||||
} else {
|
||||
const createdAtTwoYearsLater = new Date($i.createdAt);
|
||||
createdAtTwoYearsLater.setFullYear(createdAtTwoYearsLater.getFullYear() + 2);
|
||||
if (now >= createdAtTwoYearsLater) {
|
||||
claimAchievement('passedSinceAccountCreated2');
|
||||
claimAchievement('passedSinceAccountCreated1');
|
||||
} else {
|
||||
const createdAtOneYearLater = new Date($i.createdAt);
|
||||
createdAtOneYearLater.setFullYear(createdAtOneYearLater.getFullYear() + 1);
|
||||
if (now >= createdAtOneYearLater) {
|
||||
claimAchievement('passedSinceAccountCreated1');
|
||||
}
|
||||
if (Date.now() - new Date($i.createdAt).getTime() > 1000 * 60 * 60 * 24 * 365 * 2) {
|
||||
claimAchievement('passedSinceAccountCreated2');
|
||||
}
|
||||
if (Date.now() - new Date($i.createdAt).getTime() > 1000 * 60 * 60 * 24 * 365 * 3) {
|
||||
claimAchievement('passedSinceAccountCreated3');
|
||||
}
|
||||
|
||||
if (claimedAchievements.length >= 30) {
|
||||
|
@ -220,7 +232,7 @@ export async function mainBoot() {
|
|||
|
||||
const latestDonationInfoShownAt = miLocalStorage.getItem('latestDonationInfoShownAt');
|
||||
const neverShowDonationInfo = miLocalStorage.getItem('neverShowDonationInfo');
|
||||
if (neverShowDonationInfo !== 'true' && (new Date($i.createdAt).getTime() < (Date.now() - (1000 * 60 * 60 * 24 * 3))) && !location.pathname.startsWith('/miauth')) {
|
||||
if (neverShowDonationInfo !== 'true' && (createdAt.getTime() < (Date.now() - (1000 * 60 * 60 * 24 * 3))) && !location.pathname.startsWith('/miauth')) {
|
||||
if (latestDonationInfoShownAt == null || (new Date(latestDonationInfoShownAt).getTime() < (Date.now() - (1000 * 60 * 60 * 24 * 30)))) {
|
||||
popup(defineAsyncComponent(() => import('@/components/MkDonation.vue')), {}, {}, 'closed');
|
||||
}
|
||||
|
|
|
@ -29,13 +29,13 @@ const self = props.url.startsWith(local);
|
|||
const attr = self ? 'to' : 'href';
|
||||
const target = self ? null : '_blank';
|
||||
|
||||
const el = ref<HTMLElement>();
|
||||
const el = ref<HTMLElement | { $el: HTMLElement }>();
|
||||
|
||||
useTooltip(el, (showing) => {
|
||||
os.popup(defineAsyncComponent(() => import('@/components/MkUrlPreviewPopup.vue')), {
|
||||
showing,
|
||||
url: props.url,
|
||||
source: el.value,
|
||||
source: el.value instanceof HTMLElement ? el.value : el.value?.$el,
|
||||
}, {}, 'closed');
|
||||
});
|
||||
</script>
|
||||
|
|
|
@ -121,7 +121,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<i v-else-if="appearNote.myReaction != null" class="ti ti-minus" style="color: var(--accent);"></i>
|
||||
<i v-else-if="appearNote.reactionAcceptance === 'likeOnly'" class="ti ti-heart"></i>
|
||||
<i v-else class="ti ti-plus"></i>
|
||||
<p v-if="defaultStore.state.showReactionsCount && appearNote.reactionCount > 0" :class="$style.footerButtonCount">{{ number(appearNote.reactionCount) }}</p>
|
||||
<p v-if="(appearNote.reactionAcceptance === 'likeOnly' || defaultStore.state.showReactionsCount) && appearNote.reactionCount > 0" :class="$style.footerButtonCount">{{ number(appearNote.reactionCount) }}</p>
|
||||
</button>
|
||||
<button v-if="defaultStore.state.showClipButtonInNoteFooter" ref="clipButton" :class="$style.footerButton" class="_button" @mousedown="clip()">
|
||||
<i class="ti ti-paperclip"></i>
|
||||
|
|
|
@ -129,7 +129,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<i v-else-if="appearNote.myReaction != null" class="ti ti-minus" style="color: var(--accent);"></i>
|
||||
<i v-else-if="appearNote.reactionAcceptance === 'likeOnly'" class="ti ti-heart"></i>
|
||||
<i v-else class="ti ti-plus"></i>
|
||||
<p v-if="defaultStore.state.showReactionsCount && appearNote.reactionCount > 0" :class="$style.noteFooterButtonCount">{{ number(appearNote.reactionCount) }}</p>
|
||||
<p v-if="(appearNote.reactionAcceptance === 'likeOnly' || defaultStore.state.showReactionsCount) && appearNote.reactionCount > 0" :class="$style.noteFooterButtonCount">{{ number(appearNote.reactionCount) }}</p>
|
||||
</button>
|
||||
<button v-if="defaultStore.state.showClipButtonInNoteFooter" ref="clipButton" class="_button" :class="$style.noteFooterButton" @mousedown="clip()">
|
||||
<i class="ti ti-paperclip"></i>
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
<!--
|
||||
SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
SPDX-License-Identifier: AGPL-3.0-only
|
||||
-->
|
||||
|
||||
<template>
|
||||
<render/>
|
||||
</template>
|
||||
|
|
|
@ -4,13 +4,13 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
-->
|
||||
|
||||
<template>
|
||||
<a :href="to" :class="active ? activeClass : null" @click.prevent="nav" @contextmenu.prevent.stop="onContextmenu">
|
||||
<a ref="el" :href="to" :class="active ? activeClass : null" @click.prevent="nav" @contextmenu.prevent.stop="onContextmenu">
|
||||
<slot></slot>
|
||||
</a>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed } from 'vue';
|
||||
import { computed, shallowRef } from 'vue';
|
||||
import * as os from '@/os.js';
|
||||
import copyToClipboard from '@/scripts/copy-to-clipboard.js';
|
||||
import { url } from '@/config.js';
|
||||
|
@ -26,6 +26,10 @@ const props = withDefaults(defineProps<{
|
|||
behavior: null,
|
||||
});
|
||||
|
||||
const el = shallowRef<HTMLElement>();
|
||||
|
||||
defineExpose({ $el: el });
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const active = computed(() => {
|
||||
|
|
|
@ -14,10 +14,20 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
[$style.form_vertical]: chosen.place === 'vertical',
|
||||
}]"
|
||||
>
|
||||
<a :href="chosen.url" rel="noopener" target="_blank" :class="$style.link">
|
||||
<component
|
||||
:is="self ? 'MkA' : 'a'"
|
||||
:class="$style.link"
|
||||
v-bind="self ? {
|
||||
to: chosen.url.substring(local.length),
|
||||
} : {
|
||||
href: chosen.url,
|
||||
rel: 'nofollow noopener',
|
||||
target: '_blank',
|
||||
}"
|
||||
>
|
||||
<img :src="chosen.imageUrl" :class="$style.img">
|
||||
<button class="_button" :class="$style.i" @click.prevent.stop="toggleMenu"><i :class="$style.iIcon" class="ti ti-info-circle"></i></button>
|
||||
</a>
|
||||
</component>
|
||||
</div>
|
||||
<div v-else :class="$style.menu">
|
||||
<div :class="$style.menuContainer">
|
||||
|
@ -32,10 +42,10 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref } from 'vue';
|
||||
import { ref, computed } from 'vue';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { instance } from '@/instance.js';
|
||||
import { host } from '@/config.js';
|
||||
import { url as local, host } from '@/config.js';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
import { defaultStore } from '@/store.js';
|
||||
import * as os from '@/os.js';
|
||||
|
@ -100,6 +110,9 @@ const choseAd = (): Ad | null => {
|
|||
};
|
||||
|
||||
const chosen = ref(choseAd());
|
||||
|
||||
const self = computed(() => chosen.value?.url.startsWith(local));
|
||||
|
||||
const shouldHide = ref(!defaultStore.state.forceShowAds && $i && $i.policies.canHideAds && (props.specify == null));
|
||||
|
||||
function reduceFrequency(): void {
|
||||
|
|
|
@ -49,7 +49,7 @@ if (props.showUrlPreview) {
|
|||
os.popup(defineAsyncComponent(() => import('@/components/MkUrlPreviewPopup.vue')), {
|
||||
showing,
|
||||
url: props.url,
|
||||
source: el.value,
|
||||
source: el.value instanceof HTMLElement ? el.value : el.value?.$el,
|
||||
}, {}, 'closed');
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export default (v, fractionDigits = 0) => {
|
||||
if (v == null) return 'N/A';
|
||||
if (v === 0) return '0';
|
||||
|
|
|
@ -319,6 +319,7 @@ const patrons = [
|
|||
'てば',
|
||||
'たっくん',
|
||||
'SHO SEKIGUCHI',
|
||||
'塩キャベツ',
|
||||
];
|
||||
|
||||
const thereIsTreasure = ref($i && !claimedAchievements.includes('foundTreasure'));
|
||||
|
|
|
@ -41,13 +41,26 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<MkButton inline danger @click="uninstall(plugin)"><i class="ti ti-trash"></i> {{ i18n.ts.uninstall }}</MkButton>
|
||||
</div>
|
||||
|
||||
<MkFolder>
|
||||
<template #icon><i class="ti ti-terminal-2"></i></template>
|
||||
<template #label>{{ i18n.ts._plugin.viewLog }}</template>
|
||||
|
||||
<div class="_gaps_s">
|
||||
<div class="_buttons">
|
||||
<MkButton inline @click="copy(pluginLogs.get(plugin.id)?.join('\n'))"><i class="ti ti-copy"></i> {{ i18n.ts.copy }}</MkButton>
|
||||
</div>
|
||||
|
||||
<MkCode :code="pluginLogs.get(plugin.id)?.join('\n') ?? ''"/>
|
||||
</div>
|
||||
</MkFolder>
|
||||
|
||||
<MkFolder>
|
||||
<template #icon><i class="ti ti-code"></i></template>
|
||||
<template #label>{{ i18n.ts._plugin.viewSource }}</template>
|
||||
|
||||
<div class="_gaps_s">
|
||||
<div class="_buttons">
|
||||
<MkButton inline @click="copy(plugin)"><i class="ti ti-copy"></i> {{ i18n.ts.copy }}</MkButton>
|
||||
<MkButton inline @click="copy(plugin.src)"><i class="ti ti-copy"></i> {{ i18n.ts.copy }}</MkButton>
|
||||
</div>
|
||||
|
||||
<MkCode :code="plugin.src ?? ''" lang="is"/>
|
||||
|
@ -74,6 +87,7 @@ import { ColdDeviceStorage } from '@/store.js';
|
|||
import { unisonReload } from '@/scripts/unison-reload.js';
|
||||
import { i18n } from '@/i18n.js';
|
||||
import { definePageMetadata } from '@/scripts/page-metadata.js';
|
||||
import { pluginLogs } from '@/plugin.js';
|
||||
|
||||
const plugins = ref(ColdDeviceStorage.get('plugins'));
|
||||
|
||||
|
@ -87,8 +101,8 @@ async function uninstall(plugin) {
|
|||
});
|
||||
}
|
||||
|
||||
function copy(plugin) {
|
||||
copyToClipboard(plugin.src ?? '');
|
||||
function copy(text) {
|
||||
copyToClipboard(text ?? '');
|
||||
os.success();
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,10 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<XTimeline class="tl"/>
|
||||
<div class="shape1"></div>
|
||||
<div class="shape2"></div>
|
||||
<div class="logo-wrapper">
|
||||
<div class="powered-by">Powered by</div>
|
||||
<img :src="misskeysvg" class="misskey"/>
|
||||
</div>
|
||||
<div class="emojis">
|
||||
<MkEmoji :normal="true" :noStyle="true" emoji="👍"/>
|
||||
<MkEmoji :normal="true" :noStyle="true" emoji="❤"/>
|
||||
|
@ -113,16 +116,26 @@ misskeyApiGet('federation/instances', {
|
|||
opacity: 0.5;
|
||||
}
|
||||
|
||||
> .misskey {
|
||||
> .logo-wrapper {
|
||||
position: fixed;
|
||||
top: 42px;
|
||||
left: 42px;
|
||||
width: 140px;
|
||||
top: 36px;
|
||||
left: 36px;
|
||||
flex: auto;
|
||||
color: #fff;
|
||||
user-select: none;
|
||||
pointer-events: none;
|
||||
|
||||
> .powered-by {
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
> .misskey {
|
||||
width: 140px;
|
||||
@media (max-width: 450px) {
|
||||
width: 130px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
> .emojis {
|
||||
position: fixed;
|
||||
|
|
|
@ -3,12 +3,14 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { ref } from 'vue';
|
||||
import { Interpreter, Parser, utils, values } from '@syuilo/aiscript';
|
||||
import { aiScriptReadline, createAiScriptEnv } from '@/scripts/aiscript/api.js';
|
||||
import { Plugin, noteActions, notePostInterruptors, noteViewInterruptors, postFormActions, userActions, pageViewInterruptors } from '@/store.js';
|
||||
|
||||
const parser = new Parser();
|
||||
const pluginContexts = new Map<string, Interpreter>();
|
||||
export const pluginLogs = ref(new Map<string, string[]>());
|
||||
|
||||
export async function install(plugin: Plugin): Promise<void> {
|
||||
// 後方互換性のため
|
||||
|
@ -21,21 +23,27 @@ export async function install(plugin: Plugin): Promise<void> {
|
|||
in: aiScriptReadline,
|
||||
out: (value): void => {
|
||||
console.log(value);
|
||||
pluginLogs.value.get(plugin.id).push(utils.reprValue(value));
|
||||
},
|
||||
log: (): void => {
|
||||
},
|
||||
err: (err): void => {
|
||||
pluginLogs.value.get(plugin.id).push(`${err}`);
|
||||
throw err; // install時のtry-catchに反応させる
|
||||
},
|
||||
});
|
||||
|
||||
initPlugin({ plugin, aiscript });
|
||||
|
||||
try {
|
||||
await aiscript.exec(parser.parse(plugin.src));
|
||||
} catch (err) {
|
||||
console.error('Plugin install failed:', plugin.name, 'v' + plugin.version);
|
||||
return;
|
||||
}
|
||||
|
||||
aiscript.exec(parser.parse(plugin.src)).then(
|
||||
() => {
|
||||
console.info('Plugin installed:', plugin.name, 'v' + plugin.version);
|
||||
},
|
||||
(err) => {
|
||||
console.error('Plugin install failed:', plugin.name, 'v' + plugin.version);
|
||||
throw err;
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
function createPluginEnv(opts: { plugin: Plugin; storageKey: string }): Record<string, values.Value> {
|
||||
|
@ -91,6 +99,7 @@ function createPluginEnv(opts: { plugin: Plugin; storageKey: string }): Record<s
|
|||
|
||||
function initPlugin({ plugin, aiscript }): void {
|
||||
pluginContexts.set(plugin.id, aiscript);
|
||||
pluginLogs.value.set(plugin.id, []);
|
||||
}
|
||||
|
||||
function registerPostFormAction({ pluginId, title, handler }): void {
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import * as Misskey from 'misskey-js';
|
||||
|
||||
export function checkReactionPermissions(me: Misskey.entities.MeDetailed, note: Misskey.entities.Note, emoji: Misskey.entities.EmojiSimple): boolean {
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { unisonReload } from '@/scripts/unison-reload.js';
|
||||
import * as os from '@/os.js';
|
||||
import { miLocalStorage } from '@/local-storage.js';
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { bundledThemesInfo } from 'shiki';
|
||||
import { getHighlighterCore, loadWasm } from 'shiki/core';
|
||||
import darkPlus from 'shiki/themes/dark-plus.mjs';
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export default async function hasAudio(media: HTMLMediaElement) {
|
||||
const cloned = media.cloneNode() as HTMLMediaElement;
|
||||
cloned.muted = (cloned as typeof cloned & Partial<HTMLVideoElement>).playsInline = true;
|
||||
|
|
|
@ -236,7 +236,7 @@ export const defaultStore = markRaw(new Storage('base', {
|
|||
},
|
||||
showReactionsCount: {
|
||||
where: 'device',
|
||||
default: true,
|
||||
default: false,
|
||||
},
|
||||
enableQuickAddMfmFunction: {
|
||||
where: 'device',
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
|
||||
|
||||
export type WithNonNullable<T, K extends keyof T> = T & { [P in K]-?: NonNullable<T[P]> };
|
||||
|
|
|
@ -10938,19 +10938,19 @@ export type operations = {
|
|||
'application/json': {
|
||||
/** Format: misskey:id */
|
||||
antennaId: string;
|
||||
name: string;
|
||||
name?: string;
|
||||
/** @enum {string} */
|
||||
src: 'home' | 'all' | 'users' | 'list' | 'users_blacklist';
|
||||
src?: 'home' | 'all' | 'users' | 'list' | 'users_blacklist';
|
||||
/** Format: misskey:id */
|
||||
userListId?: string | null;
|
||||
keywords: string[][];
|
||||
excludeKeywords: string[][];
|
||||
users: string[];
|
||||
caseSensitive: boolean;
|
||||
keywords?: string[][];
|
||||
excludeKeywords?: string[][];
|
||||
users?: string[];
|
||||
caseSensitive?: boolean;
|
||||
localOnly?: boolean;
|
||||
withReplies: boolean;
|
||||
withFile: boolean;
|
||||
notify: boolean;
|
||||
withReplies?: boolean;
|
||||
withFile?: boolean;
|
||||
notify?: boolean;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { Release } from './parser.js';
|
||||
|
||||
export class Result {
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import * as process from 'process';
|
||||
import * as fs from 'fs';
|
||||
import { parseChangeLog } from './parser.js';
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import * as fs from 'node:fs';
|
||||
import { unified } from 'unified';
|
||||
import remarkParse from 'remark-parse';
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import {expect, suite, test} from "vitest";
|
||||
import {Release, ReleaseCategory} from "../src/parser";
|
||||
import {checkNewRelease, checkNewTopic} from "../src/checker";
|
||||
|
|
Loading…
Reference in New Issue