mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-28 18:48:31 +01:00
Merge branch 'develop' into pr/13473
This commit is contained in:
commit
7a22282346
61 changed files with 1119 additions and 77 deletions
75
.github/workflows/check-spdx-license-id.yml
vendored
Normal file
75
.github/workflows/check-spdx-license-id.yml
vendored
Normal file
|
@ -0,0 +1,75 @@
|
|||
name: Check SPDX-License-Identifier
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- develop
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
check-spdx-license-id:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4.1.1
|
||||
- name: Check
|
||||
run: |
|
||||
counter=0
|
||||
|
||||
search() {
|
||||
local directory="$1"
|
||||
find "$directory" -type f \
|
||||
'(' \
|
||||
-name "*.cjs" -and -not -name '*.config.cjs' -o \
|
||||
-name "*.html" -o \
|
||||
-name "*.js" -and -not -name '*.config.js' -o \
|
||||
-name "*.mjs" -and -not -name '*.config.mjs' -o \
|
||||
-name "*.scss" -o \
|
||||
-name "*.ts" -and -not -name '*.config.ts' -o \
|
||||
-name "*.vue" \
|
||||
')' -and \
|
||||
-not -name '*eslint*'
|
||||
}
|
||||
|
||||
check() {
|
||||
local file="$1"
|
||||
if ! (
|
||||
grep -q "SPDX-FileCopyrightText: syuilo and misskey-project" "$file" ||
|
||||
grep -q "SPDX-License-Identifier: AGPL-3.0-only" "$file"
|
||||
); then
|
||||
echo "Missing: $file"
|
||||
((counter++))
|
||||
fi
|
||||
}
|
||||
|
||||
directories=(
|
||||
"cypress/e2e"
|
||||
"packages/backend/migration"
|
||||
"packages/backend/src"
|
||||
"packages/backend/test"
|
||||
"packages/frontend/.storybook"
|
||||
"packages/frontend/@types"
|
||||
"packages/frontend/lib"
|
||||
"packages/frontend/public"
|
||||
"packages/frontend/src"
|
||||
"packages/frontend/test"
|
||||
"packages/misskey-bubble-game/src"
|
||||
"packages/misskey-reversi/src"
|
||||
"packages/sw/src"
|
||||
"scripts"
|
||||
)
|
||||
|
||||
for directory in "${directories[@]}"; do
|
||||
for file in $(search $directory); do
|
||||
check "$file"
|
||||
done
|
||||
done
|
||||
|
||||
if [ $counter -gt 0 ]; then
|
||||
echo "SPDX-License-Identifier is missing in $counter files."
|
||||
exit 1
|
||||
else
|
||||
echo "SPDX-License-Identifier is certainly described in all target files!"
|
||||
exit 0
|
||||
fi
|
1
.vscode/extensions.json
vendored
1
.vscode/extensions.json
vendored
|
@ -4,7 +4,6 @@
|
|||
"dbaeumer.vscode-eslint",
|
||||
"Vue.volar",
|
||||
"Orta.vscode-jest",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"mrmlnc.vscode-json5"
|
||||
]
|
||||
}
|
||||
|
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
@ -7,7 +7,7 @@
|
|||
"*.test.ts": "typescript"
|
||||
},
|
||||
"jest.jestCommandLine": "pnpm run jest",
|
||||
"jest.autoRun": "off",
|
||||
"jest.runMode": "on-demand",
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll": "explicit"
|
||||
},
|
||||
|
|
|
@ -3,17 +3,21 @@
|
|||
### General
|
||||
- Feat: カスタム絵文字管理画面をリニューアル #10996
|
||||
* β版として公開のため、旧画面も引き続き利用可能です
|
||||
- Fix: Play作成時に設定した公開範囲が機能していない問題を修正
|
||||
|
||||
### Client
|
||||
- Enhance: 自分のノートの添付ファイルから直接ファイルの詳細ページに飛べるように
|
||||
- Enhance: 広告がMisskeyと同一ドメインの場合はRouterで遷移するように
|
||||
- Enhance: リアクション・いいねの総数を表示するように
|
||||
- Enhance: リアクション受け入れが「いいねのみ」の場合はリアクション絵文字一覧を表示しないように
|
||||
- Enhance: 設定>プラグインのページからプラグインの簡易的なログやエラーを見られるように
|
||||
- 実装の都合により、プラグインは1つエラーを起こした時に即時停止するようになりました
|
||||
- Fix: 一部のページ内リンクが正しく動作しない問題を修正
|
||||
- Fix: 周年の実績が閏年を考慮しない問題を修正
|
||||
- Fix: ローカルURLのプレビューポップアップが左上に表示される
|
||||
|
||||
### Server
|
||||
-
|
||||
- Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに
|
||||
|
||||
## 2024.3.1
|
||||
|
||||
|
@ -27,7 +31,7 @@
|
|||
- Fix: カスタム絵文字の画像読み込みに失敗した際はテキストではなくダミー画像を表示 #13487
|
||||
|
||||
### Server
|
||||
- Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに
|
||||
-
|
||||
|
||||
## 2024.3.0
|
||||
|
||||
|
|
|
@ -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(() => {
|
||||
|
|
8
locales/index.d.ts
vendored
8
locales/index.d.ts
vendored
|
@ -6809,6 +6809,10 @@ export interface Locale extends ILocale {
|
|||
* ソースを表示
|
||||
*/
|
||||
"viewSource": string;
|
||||
/**
|
||||
* ログを表示
|
||||
*/
|
||||
"viewLog": string;
|
||||
};
|
||||
"_preferencesBackups": {
|
||||
/**
|
||||
|
@ -8635,6 +8639,10 @@ export interface Locale extends ILocale {
|
|||
* 説明
|
||||
*/
|
||||
"summary": string;
|
||||
/**
|
||||
* 非公開に設定するとプロフィールに表示されなくなりますが、URLを知っている人は引き続きアクセスできます。
|
||||
*/
|
||||
"visibilityDescription": string;
|
||||
};
|
||||
"_pages": {
|
||||
/**
|
||||
|
|
|
@ -1773,6 +1773,7 @@ _plugin:
|
|||
installWarn: "信頼できないプラグインはインストールしないでください。"
|
||||
manage: "プラグインの管理"
|
||||
viewSource: "ソースを表示"
|
||||
viewLog: "ログを表示"
|
||||
|
||||
_preferencesBackups:
|
||||
list: "作成したバックアップ"
|
||||
|
@ -2280,6 +2281,7 @@ _play:
|
|||
title: "タイトル"
|
||||
script: "スクリプト"
|
||||
summary: "説明"
|
||||
visibilityDescription: "非公開に設定するとプロフィールに表示されなくなりますが、URLを知っている人は引き続きアクセスできます。"
|
||||
|
||||
_pages:
|
||||
newPage: "ページの作成"
|
||||
|
|
|
@ -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";
|
||||
|
@ -5,4 +10,4 @@ import { writeFileSync } from "node:fs";
|
|||
const config = loadConfig();
|
||||
const spec = genOpenapiSpec(config, true);
|
||||
|
||||
writeFileSync('./built/api.json', JSON.stringify(spec), 'utf-8');
|
||||
writeFileSync('./built/api.json', JSON.stringify(spec), 'utf-8');
|
||||
|
|
|
@ -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 User2faBackupCodes1690569881926 {
|
||||
name = 'User2faBackupCodes1690569881926'
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -459,13 +459,15 @@ export default abstract class Chart<T extends Schema> {
|
|||
}
|
||||
}
|
||||
|
||||
// bake unique count
|
||||
// bake cardinality
|
||||
for (const [k, v] of Object.entries(finalDiffs)) {
|
||||
if (this.schema[k].uniqueIncrement) {
|
||||
const name = COLUMN_PREFIX + k.replaceAll('.', COLUMN_DELIMITER) as keyof Columns<T>;
|
||||
const tempColumnName = UNIQUE_TEMP_COLUMN_PREFIX + k.replaceAll('.', COLUMN_DELIMITER) as keyof TempColumnsForUnique<T>;
|
||||
queryForHour[name] = new Set([...(v as string[]), ...(logHour[tempColumnName] as unknown as string[])]).size;
|
||||
queryForDay[name] = new Set([...(v as string[]), ...(logDay[tempColumnName] as unknown as string[])]).size;
|
||||
const cardinalityOfHour = new Set([...(v as string[]), ...(logHour[tempColumnName] as unknown as string[])]).size;
|
||||
const cardinalityOfDay = new Set([...(v as string[]), ...(logDay[tempColumnName] as unknown as string[])]).size;
|
||||
queryForHour[name] = cardinalityOfHour;
|
||||
queryForDay[name] = cardinalityOfDay;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -637,7 +639,7 @@ export default abstract class Chart<T extends Schema> {
|
|||
// 要求された範囲にログがひとつもなかったら
|
||||
if (logs.length === 0) {
|
||||
// もっとも新しいログを持ってくる
|
||||
// (すくなくともひとつログが無いと隙間埋めできないため)
|
||||
// (すくなくともひとつログが無いと補間できないため)
|
||||
const recentLog = await repository.findOne({
|
||||
where: group ? {
|
||||
group: group,
|
||||
|
@ -654,7 +656,7 @@ export default abstract class Chart<T extends Schema> {
|
|||
// 要求された範囲の最も古い箇所に位置するログが存在しなかったら
|
||||
} else if (!isTimeSame(new Date(logs.at(-1)!.date * 1000), gt)) {
|
||||
// 要求された範囲の最も古い箇所時点での最も新しいログを持ってきて末尾に追加する
|
||||
// (隙間埋めできないため)
|
||||
// (補間できないため)
|
||||
const outdatedLog = await repository.findOne({
|
||||
where: {
|
||||
date: LessThan(Chart.dateToTimestamp(gt)),
|
||||
|
@ -683,7 +685,7 @@ export default abstract class Chart<T extends Schema> {
|
|||
if (log) {
|
||||
chart.unshift(this.convertRawRecord(log));
|
||||
} else {
|
||||
// 隙間埋め
|
||||
// 補間
|
||||
const latest = logs.find(l => isTimeBefore(new Date(l.date * 1000), current));
|
||||
const data = latest ? this.convertRawRecord(latest) : null;
|
||||
chart.unshift(this.getNewLog(data));
|
||||
|
|
|
@ -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';
|
||||
|
@ -46,11 +68,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;
|
||||
|
@ -89,9 +123,6 @@ export class UserEntityService implements OnModuleInit {
|
|||
@Inject(DI.renoteMutingsRepository)
|
||||
private renoteMutingsRepository: RenoteMutingsRepository,
|
||||
|
||||
@Inject(DI.driveFilesRepository)
|
||||
private driveFilesRepository: DriveFilesRepository,
|
||||
|
||||
@Inject(DI.noteUnreadsRepository)
|
||||
private noteUnreadsRepository: NoteUnreadsRepository,
|
||||
|
||||
|
@ -101,12 +132,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,
|
||||
) {
|
||||
|
@ -115,7 +140,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');
|
||||
|
@ -138,7 +162,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,
|
||||
|
@ -211,6 +235,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> {
|
||||
/*
|
||||
|
@ -303,6 +380,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({
|
||||
|
@ -317,13 +397,41 @@ export class UserEntityService implements OnModuleInit {
|
|||
const isMe = meId === user.id;
|
||||
const iAmModerator = me ? await this.roleService.isModerator(me as MiUser) : false;
|
||||
|
||||
const relation = meId && !isMe && isDetailed ? await this.getRelation(meId, user.id) : null;
|
||||
const pins = isDetailed ? 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;
|
||||
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 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).sort((a, b) => b.displayOrder - a.displayOrder).map(role => ({
|
||||
id: role.id,
|
||||
|
@ -430,10 +536,7 @@ export class UserEntityService implements OnModuleInit {
|
|||
isAdministrator: role.isAdministrator,
|
||||
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,
|
||||
} : {}),
|
||||
|
||||
|
@ -514,7 +617,7 @@ export class UserEntityService implements OnModuleInit {
|
|||
return await awaitAll(packed);
|
||||
}
|
||||
|
||||
public packMany<S extends 'MeDetailed' | 'UserDetailedNotMe' | 'UserDetailed' | 'UserLite' = 'UserLite'>(
|
||||
public async packMany<S extends 'MeDetailed' | 'UserDetailedNotMe' | 'UserDetailed' | 'UserLite' = 'UserLite'>(
|
||||
users: (MiUser['id'] | MiUser)[],
|
||||
me?: { id: MiUser['id'] } | null | undefined,
|
||||
options?: {
|
||||
|
@ -522,6 +625,70 @@ export class UserEntityService implements OnModuleInit {
|
|||
includeSecrets?: boolean,
|
||||
},
|
||||
): Promise<Packed<S>[]> {
|
||||
return Promise.all(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 Promise.all(
|
||||
_users.map(u => this.pack(
|
||||
u,
|
||||
me,
|
||||
{
|
||||
...options,
|
||||
userProfile: profilesMap.get(u.id),
|
||||
userRelations: userRelations,
|
||||
userMemos: userMemos,
|
||||
pinNotes: pinNotes,
|
||||
},
|
||||
)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -44,6 +44,7 @@ export const paramDef = {
|
|||
permissions: { type: 'array', items: {
|
||||
type: 'string',
|
||||
} },
|
||||
visibility: { type: 'string', enum: ['public', 'private'], default: 'public' },
|
||||
},
|
||||
required: ['title', 'summary', 'script', 'permissions'],
|
||||
} as const;
|
||||
|
@ -66,6 +67,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
|||
summary: ps.summary,
|
||||
script: ps.script,
|
||||
permissions: ps.permissions,
|
||||
visibility: ps.visibility,
|
||||
}).then(x => this.flashsRepository.findOneByOrFail(x.identifiers[0]));
|
||||
|
||||
return await this.flashEntityService.pack(flash);
|
||||
|
|
|
@ -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]);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 () => {
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
528
packages/backend/test/unit/entities/UserEntityService.ts
Normal file
528
packages/backend/test/unit/entities/UserEntityService.ts
Normal file
|
@ -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 any;
|
||||
// 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 any;
|
||||
// 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 any;
|
||||
// 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 any;
|
||||
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 any;
|
||||
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 any;
|
||||
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 any;
|
||||
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 any;
|
||||
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 any;
|
||||
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 any;
|
||||
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 any;
|
||||
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 any;
|
||||
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 any;
|
||||
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 any;
|
||||
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 any;
|
||||
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 any;
|
||||
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 any;
|
||||
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 any;
|
||||
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 any;
|
||||
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 {
|
||||
|
|
|
@ -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.44.0/tabler-icons.min.css">
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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(() => {
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -18,16 +18,17 @@ SPDX-License-Identifier: AGPL-3.0-only
|
|||
<MkCodeEditor v-model="script" lang="is">
|
||||
<template #label>{{ i18n.ts._play.script }}</template>
|
||||
</MkCodeEditor>
|
||||
<MkSelect v-model="visibility">
|
||||
<template #label>{{ i18n.ts.visibility }}</template>
|
||||
<template #caption>{{ i18n.ts._play.visibilityDescription }}</template>
|
||||
<option :key="'public'" :value="'public'">{{ i18n.ts.public }}</option>
|
||||
<option :key="'private'" :value="'private'">{{ i18n.ts.private }}</option>
|
||||
</MkSelect>
|
||||
<div class="_buttons">
|
||||
<MkButton primary @click="save"><i class="ti ti-check"></i> {{ i18n.ts.save }}</MkButton>
|
||||
<MkButton @click="show"><i class="ti ti-eye"></i> {{ i18n.ts.show }}</MkButton>
|
||||
<MkButton v-if="flash" danger @click="del"><i class="ti ti-trash"></i> {{ i18n.ts.delete }}</MkButton>
|
||||
</div>
|
||||
<MkSelect v-model="visibility">
|
||||
<template #label>{{ i18n.ts.visibility }}</template>
|
||||
<option :key="'public'" :value="'public'">{{ i18n.ts.public }}</option>
|
||||
<option :key="'private'" :value="'private'">{{ i18n.ts.private }}</option>
|
||||
</MkSelect>
|
||||
</div>
|
||||
</MkSpacer>
|
||||
</MkStickyContainer>
|
||||
|
@ -367,7 +368,7 @@ const props = defineProps<{
|
|||
}>();
|
||||
|
||||
const flash = ref<Misskey.entities.Flash | null>(null);
|
||||
const visibility = ref<Misskey.entities.FlashUpdateRequest['visibility']>('public');
|
||||
const visibility = ref<'private' | 'public'>('public');
|
||||
|
||||
if (props.id) {
|
||||
flash.value = await misskeyApi('flash/show', {
|
||||
|
@ -420,6 +421,7 @@ async function save() {
|
|||
summary: summary.value,
|
||||
permissions: permissions.value,
|
||||
script: script.value,
|
||||
visibility: visibility.value,
|
||||
});
|
||||
router.push('/play/' + created.id + '/edit');
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
<img :src="misskeysvg" class="misskey"/>
|
||||
<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,14 +116,24 @@ 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;
|
||||
|
||||
@media (max-width: 450px) {
|
||||
width: 130px;
|
||||
> .powered-by {
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
> .misskey {
|
||||
width: 140px;
|
||||
@media (max-width: 450px) {
|
||||
width: 130px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
* 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 { inputText } from '@/os.js';
|
||||
|
@ -10,6 +11,7 @@ import { Plugin, noteActions, notePostInterruptors, noteViewInterruptors, postFo
|
|||
|
||||
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> {
|
||||
// 後方互換性のため
|
||||
|
@ -22,21 +24,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;
|
||||
}
|
||||
|
||||
console.info('Plugin installed:', plugin.name, 'v' + plugin.version);
|
||||
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> {
|
||||
|
@ -92,6 +100,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';
|
||||
import { UnicodeEmojiDef } from './emojilist.js';
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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]> };
|
||||
|
|
|
@ -22815,6 +22815,11 @@ export type operations = {
|
|||
summary: string;
|
||||
script: string;
|
||||
permissions: string[];
|
||||
/**
|
||||
* @default public
|
||||
* @enum {string}
|
||||
*/
|
||||
visibility?: 'public' | 'private';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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";
|
||||
|
@ -411,4 +416,4 @@ suite('checkNewTopic', () => {
|
|||
console.log(result.message)
|
||||
expect(result.success).toBe(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import { createWriteStream } from 'node:fs';
|
||||
import { mkdir } from 'node:fs/promises';
|
||||
import { resolve } from 'node:path';
|
||||
|
|
Loading…
Reference in a new issue