Merge remote-tracking branch 'misskey-dev/develop' into io
This commit is contained in:
commit
fd696a9621
113 changed files with 2272 additions and 443 deletions
2
.github/workflows/test-backend.yml
vendored
2
.github/workflows/test-backend.yml
vendored
|
@ -46,6 +46,8 @@ jobs:
|
||||||
with:
|
with:
|
||||||
version: 9
|
version: 9
|
||||||
run_install: false
|
run_install: false
|
||||||
|
- name: Install FFmpeg
|
||||||
|
uses: FedericoCarboni/setup-ffmpeg@v3
|
||||||
- name: Use Node.js ${{ matrix.node-version }}
|
- name: Use Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v4.0.2
|
uses: actions/setup-node@v4.0.2
|
||||||
with:
|
with:
|
||||||
|
|
39
CHANGELOG.md
39
CHANGELOG.md
|
@ -7,9 +7,18 @@
|
||||||
- Enhance: URLプレビューの有効化・無効化を設定できるように #13569
|
- Enhance: URLプレビューの有効化・無効化を設定できるように #13569
|
||||||
- Enhance: アンテナでBotによるノートを除外できるように
|
- Enhance: アンテナでBotによるノートを除外できるように
|
||||||
(Cherry-picked from https://github.com/MisskeyIO/misskey/pull/545)
|
(Cherry-picked from https://github.com/MisskeyIO/misskey/pull/545)
|
||||||
|
- Enhance: クリップのノート数を表示するように
|
||||||
|
- Enhance: コンディショナルロールの条件として以下を新たに追加 (#13667)
|
||||||
|
- 猫ユーザーか
|
||||||
|
- botユーザーか
|
||||||
|
- サスペンド済みユーザーか
|
||||||
|
- 鍵アカウントユーザーか
|
||||||
|
- 「アカウントを見つけやすくする」が有効なユーザーか
|
||||||
- Fix: Play作成時に設定した公開範囲が機能していない問題を修正
|
- Fix: Play作成時に設定した公開範囲が機能していない問題を修正
|
||||||
|
- Fix: 正規化されていない状態のhashtagが連合されてきたhtmlに含まれているとhashtagが正しくhashtagに復元されない問題を修正
|
||||||
|
|
||||||
### Client
|
### Client
|
||||||
|
- Feat: アップロードするファイルの名前をランダム文字列にできるように
|
||||||
- Enhance: 自分のノートの添付ファイルから直接ファイルの詳細ページに飛べるように
|
- Enhance: 自分のノートの添付ファイルから直接ファイルの詳細ページに飛べるように
|
||||||
- Enhance: 広告がMisskeyと同一ドメインの場合はRouterで遷移するように
|
- Enhance: 広告がMisskeyと同一ドメインの場合はRouterで遷移するように
|
||||||
- Enhance: リアクション・いいねの総数を表示するように
|
- Enhance: リアクション・いいねの総数を表示するように
|
||||||
|
@ -19,6 +28,16 @@
|
||||||
- Enhance: ページのデザインを変更
|
- Enhance: ページのデザインを変更
|
||||||
- Enhance: 2要素認証(ワンタイムパスワード)の入力欄を改善
|
- Enhance: 2要素認証(ワンタイムパスワード)の入力欄を改善
|
||||||
- Enhance: 「今日誕生日のフォロー中ユーザー」ウィジェットを手動でリロードできるように
|
- Enhance: 「今日誕生日のフォロー中ユーザー」ウィジェットを手動でリロードできるように
|
||||||
|
- Enhance: 映像・音声の再生にブラウザのネイティブプレイヤーを使用できるように
|
||||||
|
- Enhance: 映像・音声の再生メニューに「再生速度」「ループ再生」「ピクチャインピクチャ」を追加
|
||||||
|
- Enhance: 映像・音声の再生にキーボードショートカットが使えるように
|
||||||
|
- Enhance: ノートについているリアクションの「もっと!」から、リアクションの一覧を表示できるように
|
||||||
|
- Enhance: リプライにて引用がある場合テキストが空でもノートできるように
|
||||||
|
- 引用したいノートのURLをコピーしリプライ投稿画面にペーストして添付することで達成できます
|
||||||
|
- Enhance: フォローするかどうかの確認ダイアログを出せるように
|
||||||
|
- Enhance: Playを手動でリロードできるように
|
||||||
|
- Enhance: 通報のコメント内のリンクをクリックした際、ウィンドウで開くように
|
||||||
|
- Chore: AiScriptを0.18.0にバージョンアップ
|
||||||
- Fix: 一部のページ内リンクが正しく動作しない問題を修正
|
- Fix: 一部のページ内リンクが正しく動作しない問題を修正
|
||||||
- Fix: 周年の実績が閏年を考慮しない問題を修正
|
- Fix: 周年の実績が閏年を考慮しない問題を修正
|
||||||
- Fix: ローカルURLのプレビューポップアップが左上に表示される
|
- Fix: ローカルURLのプレビューポップアップが左上に表示される
|
||||||
|
@ -29,12 +48,32 @@
|
||||||
- Fix: コードブロックのシンタックスハイライトで使用される定義ファイルをCDNから取得するように #13177
|
- Fix: コードブロックのシンタックスハイライトで使用される定義ファイルをCDNから取得するように #13177
|
||||||
- CDNから取得せずMisskey本体にバンドルする場合は`pacakges/frontend/vite.config.ts`を修正してください。
|
- CDNから取得せずMisskey本体にバンドルする場合は`pacakges/frontend/vite.config.ts`を修正してください。
|
||||||
- Fix: タイムゾーンによっては、「今日誕生日のフォロー中ユーザー」ウィジェットが正しく動作しない問題を修正
|
- Fix: タイムゾーンによっては、「今日誕生日のフォロー中ユーザー」ウィジェットが正しく動作しない問題を修正
|
||||||
|
- Fix: CWのみの引用リノートが詳細ページで純粋なリノートとして誤って扱われてしまう問題を修正
|
||||||
|
- Fix: ノート詳細ページにおいてCW付き引用リノートのCWボタンのラベルに「引用」が含まれていない問題を修正
|
||||||
|
- Fix: ダイアログの入力で字数制限に違反していてもEnterキーが押せてしまう問題を修正
|
||||||
|
- Fix: ダイレクト投稿の宛先が保存されない問題を修正
|
||||||
|
- Fix: Playのページを離れたときに、Playが正常に初期化されない問題を修正
|
||||||
|
- Fix: ページのOGP URLが間違っているのを修正
|
||||||
|
- Fix: リバーシの対局を正しく共有できないことがある問題を修正
|
||||||
|
- Fix: 通知をグループ化している際に、人数が正常に表示されないことがある問題を修正
|
||||||
|
|
||||||
### Server
|
### Server
|
||||||
- Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに
|
- Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに
|
||||||
- Enhance: misskey-dev/summaly@5.1.0の取り込み(プレビュー生成処理の効率化)
|
- Enhance: misskey-dev/summaly@5.1.0の取り込み(プレビュー生成処理の効率化)
|
||||||
- Fix: フォローリクエストを作成する際に既存のものは削除するように
|
- Fix: フォローリクエストを作成する際に既存のものは削除するように
|
||||||
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/440)
|
(Cherry-picked from https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/440)
|
||||||
|
- Fix: エンドポイント`notes/translate`のエラーを改善
|
||||||
|
- Fix: CleanRemoteFilesProcessorService report progress from 100% (#13632)
|
||||||
|
- Fix: 一部の音声ファイルが映像ファイルとして扱われる問題を修正
|
||||||
|
- Fix: リプライのみの引用リノートと、CWのみの引用リノートが純粋なリノートとして誤って扱われてしまう問題を修正
|
||||||
|
- Fix: 登録にメール認証が必須になっている場合、登録されているメールアドレスを削除できないように
|
||||||
|
(Cherry-picked from https://github.com/MisskeyIO/misskey/pull/606)
|
||||||
|
- Fix: Add Cache-Control to Bull Board
|
||||||
|
- Fix: nginx経由で/files/にRangeリクエストされた場合に正しく応答できないのを修正
|
||||||
|
- Fix: 一部のタイムラインのストリーミングでインスタンスミュートが効かない問題を修正
|
||||||
|
- Fix: グローバルタイムラインで返信が表示されないことがある問題を修正
|
||||||
|
- Fix: リノートをミュートしたユーザの投稿のリノートがミュートされる問題を修正
|
||||||
|
- Fix: AP Link等は添付ファイル扱いしないようになど (#13754)
|
||||||
|
|
||||||
## 2024.3.1
|
## 2024.3.1
|
||||||
|
|
||||||
|
|
|
@ -30,9 +30,13 @@ Cypress.Commands.add('visitHome', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
Cypress.Commands.add('resetState', () => {
|
Cypress.Commands.add('resetState', () => {
|
||||||
|
// iframe.contentWindow.indexedDB.deleteDatabase() がchromeのバグで使用できないため、indexedDBを無効化している。
|
||||||
|
// see https://github.com/misskey-dev/misskey/issues/13605#issuecomment-2053652123
|
||||||
|
/*
|
||||||
cy.window().then(win => {
|
cy.window().then(win => {
|
||||||
win.indexedDB.deleteDatabase('keyval-store');
|
win.indexedDB.deleteDatabase('keyval-store');
|
||||||
});
|
});
|
||||||
|
*/
|
||||||
cy.request('POST', '/api/reset-db', {}).as('reset');
|
cy.request('POST', '/api/reset-db', {}).as('reset');
|
||||||
cy.get('@reset').its('status').should('equal', 204);
|
cy.get('@reset').its('status').should('equal', 204);
|
||||||
cy.reload(true);
|
cy.reload(true);
|
||||||
|
|
|
@ -2022,7 +2022,7 @@ _2fa:
|
||||||
backupCodesSavedConfirmTitle: "Did you save your backup codes?"
|
backupCodesSavedConfirmTitle: "Did you save your backup codes?"
|
||||||
backupCodesSavedConfirmDescription: "If you lose both your two-factor authentication app and backup codes, YOU WILL LOSE ACCESS TO YOUR ACCOUNT.\nKeep them safe and secure, and do not share them with anyone.\n\n$[x2 Two-factor authentication settings CANNOT be changed by anyone other than yourself, $[fg.color=red AND THE ADMINISTRATOR CANNOT DISABLE IT EITHER.]]"
|
backupCodesSavedConfirmDescription: "If you lose both your two-factor authentication app and backup codes, YOU WILL LOSE ACCESS TO YOUR ACCOUNT.\nKeep them safe and secure, and do not share them with anyone.\n\n$[x2 Two-factor authentication settings CANNOT be changed by anyone other than yourself, $[fg.color=red AND THE ADMINISTRATOR CANNOT DISABLE IT EITHER.]]"
|
||||||
backupCodesSavedConfirmChecked: "I have saved my backup codes"
|
backupCodesSavedConfirmChecked: "I have saved my backup codes"
|
||||||
howto2fa: "If you are having trouble setting up, please refer to {link}."
|
detailedGuide: "If you are having trouble setting up, please refer to {link}."
|
||||||
_permissions:
|
_permissions:
|
||||||
"read:account": "View your account information"
|
"read:account": "View your account information"
|
||||||
"write:account": "Edit your account information"
|
"write:account": "Edit your account information"
|
||||||
|
|
78
locales/index.d.ts
vendored
78
locales/index.d.ts
vendored
|
@ -5019,6 +5019,30 @@ export interface Locale extends ILocale {
|
||||||
* バックアップコードを使う
|
* バックアップコードを使う
|
||||||
*/
|
*/
|
||||||
"useBackupCode": string;
|
"useBackupCode": string;
|
||||||
|
/**
|
||||||
|
* アプリを起動
|
||||||
|
*/
|
||||||
|
"launchApp": string;
|
||||||
|
/**
|
||||||
|
* 動画・音声の再生にブラウザのUIを使用する
|
||||||
|
*/
|
||||||
|
"useNativeUIForVideoAudioPlayer": string;
|
||||||
|
/**
|
||||||
|
* オリジナルのファイル名を保持
|
||||||
|
*/
|
||||||
|
"keepOriginalFilename": string;
|
||||||
|
/**
|
||||||
|
* この設定をオフにすると、アップロード時にファイル名が自動でランダム文字列に置き換えられます。
|
||||||
|
*/
|
||||||
|
"keepOriginalFilenameDescription": string;
|
||||||
|
/**
|
||||||
|
* 説明文はありません
|
||||||
|
*/
|
||||||
|
"noDescription": string;
|
||||||
|
/**
|
||||||
|
* フォローの際常に確認する
|
||||||
|
*/
|
||||||
|
"alwaysConfirmFollow": string;
|
||||||
/**
|
/**
|
||||||
* 通報の種類
|
* 通報の種類
|
||||||
*/
|
*/
|
||||||
|
@ -6787,6 +6811,26 @@ export interface Locale extends ILocale {
|
||||||
* リモートユーザー
|
* リモートユーザー
|
||||||
*/
|
*/
|
||||||
"isRemote": string;
|
"isRemote": string;
|
||||||
|
/**
|
||||||
|
* 猫ユーザー
|
||||||
|
*/
|
||||||
|
"isCat": string;
|
||||||
|
/**
|
||||||
|
* botユーザー
|
||||||
|
*/
|
||||||
|
"isBot": string;
|
||||||
|
/**
|
||||||
|
* サスペンド済みユーザー
|
||||||
|
*/
|
||||||
|
"isSuspended": string;
|
||||||
|
/**
|
||||||
|
* 鍵アカウントユーザー
|
||||||
|
*/
|
||||||
|
"isLocked": string;
|
||||||
|
/**
|
||||||
|
* 「アカウントを見つけやすくする」が有効なユーザー
|
||||||
|
*/
|
||||||
|
"isExplorable": string;
|
||||||
/**
|
/**
|
||||||
* アカウント作成から~以内
|
* アカウント作成から~以内
|
||||||
*/
|
*/
|
||||||
|
@ -7765,13 +7809,9 @@ export interface Locale extends ILocale {
|
||||||
*/
|
*/
|
||||||
"step1": ParameterizedString<"a" | "b">;
|
"step1": ParameterizedString<"a" | "b">;
|
||||||
/**
|
/**
|
||||||
* 次に、表示されているQRコードをアプリでスキャンします。
|
* 次に、表示されているQRコードをアプリでスキャンするか、ボタンをクリックして端末上でアプリを開きます。
|
||||||
*/
|
*/
|
||||||
"step2": string;
|
"step2": string;
|
||||||
/**
|
|
||||||
* QRコードをクリックすると、お使いの端末にインストールされている認証アプリやキーリングに登録できます。
|
|
||||||
*/
|
|
||||||
"step2Click": string;
|
|
||||||
/**
|
/**
|
||||||
* デスクトップアプリを使用する場合は次のURIを入力します
|
* デスクトップアプリを使用する場合は次のURIを入力します
|
||||||
*/
|
*/
|
||||||
|
@ -7864,6 +7904,10 @@ export interface Locale extends ILocale {
|
||||||
* バックアップコードが全て使用されました。認証アプリを利用できない場合、これ以上アカウントにアクセスできなくなります。認証アプリを再登録してください。
|
* バックアップコードが全て使用されました。認証アプリを利用できない場合、これ以上アカウントにアクセスできなくなります。認証アプリを再登録してください。
|
||||||
*/
|
*/
|
||||||
"backupCodesExhaustedWarning": string;
|
"backupCodesExhaustedWarning": string;
|
||||||
|
/**
|
||||||
|
* 詳細なガイドはこちら
|
||||||
|
*/
|
||||||
|
"moreDetailedGuideHere": string;
|
||||||
/**
|
/**
|
||||||
* バックアップコードを保存しましたか?
|
* バックアップコードを保存しましたか?
|
||||||
*/
|
*/
|
||||||
|
@ -7882,7 +7926,7 @@ export interface Locale extends ILocale {
|
||||||
/**
|
/**
|
||||||
* 設定方法でお困りの際は、{link}を参照してください。
|
* 設定方法でお困りの際は、{link}を参照してください。
|
||||||
*/
|
*/
|
||||||
"howto2fa": ParameterizedString<"link">;
|
"detailedGuide": ParameterizedString<"link">;
|
||||||
};
|
};
|
||||||
"_permissions": {
|
"_permissions": {
|
||||||
/**
|
/**
|
||||||
|
@ -9088,6 +9132,14 @@ export interface Locale extends ILocale {
|
||||||
* ボタン
|
* ボタン
|
||||||
*/
|
*/
|
||||||
"button": string;
|
"button": string;
|
||||||
|
/**
|
||||||
|
* 動的ブロック
|
||||||
|
*/
|
||||||
|
"dynamic": string;
|
||||||
|
/**
|
||||||
|
* このブロックは廃止されています。今後は{play}を利用してください。
|
||||||
|
*/
|
||||||
|
"dynamicDescription": ParameterizedString<"play">;
|
||||||
/**
|
/**
|
||||||
* ノート埋め込み
|
* ノート埋め込み
|
||||||
*/
|
*/
|
||||||
|
@ -10172,6 +10224,20 @@ export interface Locale extends ILocale {
|
||||||
*/
|
*/
|
||||||
"summaryProxyDescription2": string;
|
"summaryProxyDescription2": string;
|
||||||
};
|
};
|
||||||
|
"_mediaControls": {
|
||||||
|
/**
|
||||||
|
* ピクチャインピクチャ
|
||||||
|
*/
|
||||||
|
"pip": string;
|
||||||
|
/**
|
||||||
|
* 再生速度
|
||||||
|
*/
|
||||||
|
"playbackRate": string;
|
||||||
|
/**
|
||||||
|
* ループ再生
|
||||||
|
*/
|
||||||
|
"loop": string;
|
||||||
|
};
|
||||||
"_skebStatus": {
|
"_skebStatus": {
|
||||||
"_genres": {
|
"_genres": {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1250,6 +1250,12 @@ gameRetry: "リトライ"
|
||||||
notUsePleaseLeaveBlank: "使用しない場合は空欄にしてください"
|
notUsePleaseLeaveBlank: "使用しない場合は空欄にしてください"
|
||||||
useTotp: "ワンタイムパスワードを使う"
|
useTotp: "ワンタイムパスワードを使う"
|
||||||
useBackupCode: "バックアップコードを使う"
|
useBackupCode: "バックアップコードを使う"
|
||||||
|
launchApp: "アプリを起動"
|
||||||
|
useNativeUIForVideoAudioPlayer: "動画・音声の再生にブラウザのUIを使用する"
|
||||||
|
keepOriginalFilename: "オリジナルのファイル名を保持"
|
||||||
|
keepOriginalFilenameDescription: "この設定をオフにすると、アップロード時にファイル名が自動でランダム文字列に置き換えられます。"
|
||||||
|
noDescription: "説明文はありません"
|
||||||
|
alwaysConfirmFollow: "フォローの際常に確認する"
|
||||||
abuseReportCategory: "通報の種類"
|
abuseReportCategory: "通報の種類"
|
||||||
selectCategory: "カテゴリを選択"
|
selectCategory: "カテゴリを選択"
|
||||||
reportComplete: "通報完了"
|
reportComplete: "通報完了"
|
||||||
|
@ -1754,6 +1760,11 @@ _role:
|
||||||
roleAssignedTo: "マニュアルロールにアサイン済み"
|
roleAssignedTo: "マニュアルロールにアサイン済み"
|
||||||
isLocal: "ローカルユーザー"
|
isLocal: "ローカルユーザー"
|
||||||
isRemote: "リモートユーザー"
|
isRemote: "リモートユーザー"
|
||||||
|
isCat: "猫ユーザー"
|
||||||
|
isBot: "botユーザー"
|
||||||
|
isSuspended: "サスペンド済みユーザー"
|
||||||
|
isLocked: "鍵アカウントユーザー"
|
||||||
|
isExplorable: "「アカウントを見つけやすくする」が有効なユーザー"
|
||||||
createdLessThan: "アカウント作成から~以内"
|
createdLessThan: "アカウント作成から~以内"
|
||||||
createdMoreThan: "アカウント作成から~経過"
|
createdMoreThan: "アカウント作成から~経過"
|
||||||
followersLessThanOrEq: "フォロワー数が~以下"
|
followersLessThanOrEq: "フォロワー数が~以下"
|
||||||
|
@ -2041,8 +2052,7 @@ _2fa:
|
||||||
alreadyRegistered: "既に設定は完了しています。"
|
alreadyRegistered: "既に設定は完了しています。"
|
||||||
registerTOTP: "認証アプリの設定を開始"
|
registerTOTP: "認証アプリの設定を開始"
|
||||||
step1: "まず、{a}や{b}などの認証アプリをお使いのデバイスにインストールします。"
|
step1: "まず、{a}や{b}などの認証アプリをお使いのデバイスにインストールします。"
|
||||||
step2: "次に、表示されているQRコードをアプリでスキャンします。"
|
step2: "次に、表示されているQRコードをアプリでスキャンするか、ボタンをクリックして端末上でアプリを開きます。"
|
||||||
step2Click: "QRコードをクリックすると、お使いの端末にインストールされている認証アプリやキーリングに登録できます。"
|
|
||||||
step2Uri: "デスクトップアプリを使用する場合は次のURIを入力します"
|
step2Uri: "デスクトップアプリを使用する場合は次のURIを入力します"
|
||||||
step3Title: "確認コードを入力"
|
step3Title: "確認コードを入力"
|
||||||
step3: "アプリに表示されている確認コード(トークン)を入力します。"
|
step3: "アプリに表示されている確認コード(トークン)を入力します。"
|
||||||
|
@ -2069,7 +2079,7 @@ _2fa:
|
||||||
backupCodesSavedConfirmTitle: "バックアップコードを保存しましたか?"
|
backupCodesSavedConfirmTitle: "バックアップコードを保存しましたか?"
|
||||||
backupCodesSavedConfirmDescription: "二要素認証アプリとバックアップコードの両方を紛失した場合、アカウントにアクセスできなくなります。\n誰とも共有せず、適切な方法で保管してください。\n\n$[x2 二要素認証設定は自分以外の誰にも変更できませんので、$[fg.color=red 運営チームも無効化することはできません。]]"
|
backupCodesSavedConfirmDescription: "二要素認証アプリとバックアップコードの両方を紛失した場合、アカウントにアクセスできなくなります。\n誰とも共有せず、適切な方法で保管してください。\n\n$[x2 二要素認証設定は自分以外の誰にも変更できませんので、$[fg.color=red 運営チームも無効化することはできません。]]"
|
||||||
backupCodesSavedConfirmChecked: "バックアップコードを保存しました"
|
backupCodesSavedConfirmChecked: "バックアップコードを保存しました"
|
||||||
howto2fa: "設定方法でお困りの際は、{link}を参照してください。"
|
detailedGuide: "設定方法でお困りの際は、{link}を参照してください。"
|
||||||
|
|
||||||
_permissions:
|
_permissions:
|
||||||
"read:account": "アカウントの情報を見る"
|
"read:account": "アカウントの情報を見る"
|
||||||
|
@ -2397,6 +2407,8 @@ _pages:
|
||||||
section: "セクション"
|
section: "セクション"
|
||||||
image: "画像"
|
image: "画像"
|
||||||
button: "ボタン"
|
button: "ボタン"
|
||||||
|
dynamic: "動的ブロック"
|
||||||
|
dynamicDescription: "このブロックは廃止されています。今後は{play}を利用してください。"
|
||||||
|
|
||||||
note: "ノート埋め込み"
|
note: "ノート埋め込み"
|
||||||
_note:
|
_note:
|
||||||
|
@ -2708,6 +2720,11 @@ _urlPreviewSetting:
|
||||||
summaryProxyDescription: "Misskey本体ではなく、サマリープロキシを使用してプレビューを生成します。"
|
summaryProxyDescription: "Misskey本体ではなく、サマリープロキシを使用してプレビューを生成します。"
|
||||||
summaryProxyDescription2: "プロキシには下記パラメータがクエリ文字列として連携されます。プロキシ側がこれらをサポートしない場合、設定値は無視されます。"
|
summaryProxyDescription2: "プロキシには下記パラメータがクエリ文字列として連携されます。プロキシ側がこれらをサポートしない場合、設定値は無視されます。"
|
||||||
|
|
||||||
|
_mediaControls:
|
||||||
|
pip: "ピクチャインピクチャ"
|
||||||
|
playbackRate: "再生速度"
|
||||||
|
loop: "ループ再生"
|
||||||
|
|
||||||
_skebStatus:
|
_skebStatus:
|
||||||
_genres:
|
_genres:
|
||||||
art: "イラスト"
|
art: "イラスト"
|
||||||
|
|
|
@ -2000,7 +2000,7 @@ _2fa:
|
||||||
backupCodesSavedConfirmTitle: "백업 코드를 저장했습니까?"
|
backupCodesSavedConfirmTitle: "백업 코드를 저장했습니까?"
|
||||||
backupCodesSavedConfirmDescription: "인증 앱과 백업 코드를 모두 분실하면\n계정에 액세스할 수 없게 됩니다.\n자신만이 알 수 있도록 안전한 장소에 보관해 주십시오.\n\n$[x2 2단계 인증 설정은\n본인만이 변경할 수 있으며, $[fg.color=red 운영팀도 해제할 수 없습니다.]]"
|
backupCodesSavedConfirmDescription: "인증 앱과 백업 코드를 모두 분실하면\n계정에 액세스할 수 없게 됩니다.\n자신만이 알 수 있도록 안전한 장소에 보관해 주십시오.\n\n$[x2 2단계 인증 설정은\n본인만이 변경할 수 있으며, $[fg.color=red 운영팀도 해제할 수 없습니다.]]"
|
||||||
backupCodesSavedConfirmChecked: "백업 코드를 저장했습니다"
|
backupCodesSavedConfirmChecked: "백업 코드를 저장했습니다"
|
||||||
howto2fa: "설정 방법에 대한 자세한 내용은 {link}를 참조하세요."
|
detailedGuide: "설정 방법에 대한 자세한 내용은 {link}를 참조하세요."
|
||||||
_permissions:
|
_permissions:
|
||||||
"read:account": "계정의 정보를 봅니다"
|
"read:account": "계정의 정보를 봅니다"
|
||||||
"write:account": "계정의 정보를 변경합니다"
|
"write:account": "계정의 정보를 변경합니다"
|
||||||
|
|
|
@ -19,6 +19,6 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<redoc spec-url="/api.json" expand-responses="200" expand-single-schema-field="true"></redoc>
|
<redoc spec-url="/api.json" expand-responses="200" expand-single-schema-field="true"></redoc>
|
||||||
<script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"></script>
|
<script src="https://cdn.redoc.ly/redoc/v2.1.3/bundles/redoc.standalone.js" integrity="sha256-u4DgqzYXoArvNF/Ymw3puKexfOC6lYfw0sfmeliBJ1I=" crossorigin="anonymous"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -11,14 +11,14 @@
|
||||||
"start:test": "cross-env NODE_ENV=test node ./built/boot/entry.js",
|
"start:test": "cross-env NODE_ENV=test node ./built/boot/entry.js",
|
||||||
"migrate": "pnpm typeorm migration:run -d ormconfig.js",
|
"migrate": "pnpm typeorm migration:run -d ormconfig.js",
|
||||||
"revert": "pnpm typeorm migration:revert -d ormconfig.js",
|
"revert": "pnpm typeorm migration:revert -d ormconfig.js",
|
||||||
"check:connect": "node ./check_connect.js",
|
"check:connect": "node ./scripts/check_connect.js",
|
||||||
"build": "swc src -d built -D",
|
"build": "swc src -d built -D",
|
||||||
"build:test": "swc test-server -d built-test -D --config-file test-server/.swcrc",
|
"build:test": "swc test-server -d built-test -D --config-file test-server/.swcrc",
|
||||||
"watch:swc": "swc src -d built -D -w",
|
"watch:swc": "swc src -d built -D -w",
|
||||||
"build:tsc": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json",
|
"build:tsc": "tsc -p tsconfig.json && tsc-alias -p tsconfig.json",
|
||||||
"watch": "node watch.mjs",
|
"watch": "node ./scripts/watch.mjs",
|
||||||
"restart": "pnpm build && pnpm start",
|
"restart": "pnpm build && pnpm start",
|
||||||
"dev": "nodemon -w src -e ts,js,mjs,cjs,json --exec \"cross-env NODE_ENV=development pnpm run restart\"",
|
"dev": "node ./scripts/dev.mjs",
|
||||||
"typecheck": "tsc --noEmit && tsc -p test --noEmit",
|
"typecheck": "tsc --noEmit && tsc -p test --noEmit",
|
||||||
"eslint": "eslint --quiet \"src/**/*.ts\"",
|
"eslint": "eslint --quiet \"src/**/*.ts\"",
|
||||||
"lint": "pnpm typecheck && pnpm eslint",
|
"lint": "pnpm typecheck && pnpm eslint",
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
"test:e2e": "pnpm build && pnpm build:test && pnpm jest:e2e",
|
"test:e2e": "pnpm build && pnpm build:test && pnpm jest:e2e",
|
||||||
"test-and-coverage": "pnpm jest-and-coverage",
|
"test-and-coverage": "pnpm jest-and-coverage",
|
||||||
"test-and-coverage:e2e": "pnpm build && pnpm build:test && pnpm jest-and-coverage:e2e",
|
"test-and-coverage:e2e": "pnpm build && pnpm build:test && pnpm jest-and-coverage:e2e",
|
||||||
"generate-api-json": "pnpm build && node ./generate_api_json.js"
|
"generate-api-json": "pnpm build && node ./scripts/generate_api_json.js"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@swc/core-android-arm64": "1.3.11",
|
"@swc/core-android-arm64": "1.3.11",
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import Redis from 'ioredis';
|
import Redis from 'ioredis';
|
||||||
import { loadConfig } from './built/config.js';
|
import { loadConfig } from '../built/config.js';
|
||||||
|
|
||||||
const config = loadConfig();
|
const config = loadConfig();
|
||||||
const redis = new Redis(config.redis);
|
const redis = new Redis(config.redis);
|
61
packages/backend/scripts/dev.mjs
Normal file
61
packages/backend/scripts/dev.mjs
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { execa, execaNode } from 'execa';
|
||||||
|
|
||||||
|
/** @type {import('execa').ExecaChildProcess | undefined} */
|
||||||
|
let backendProcess;
|
||||||
|
|
||||||
|
async function execBuildAssets() {
|
||||||
|
await execa('pnpm', ['run', 'build-assets'], {
|
||||||
|
cwd: '../../',
|
||||||
|
stdout: process.stdout,
|
||||||
|
stderr: process.stderr,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function execStart() {
|
||||||
|
// pnpm run start を呼び出したいが、windowsだとプロセスグループ単位でのkillが出来ずゾンビプロセス化するので
|
||||||
|
// 上記と同等の動きをするコマンドで子・孫プロセスを作らないようにしたい
|
||||||
|
backendProcess = execaNode('./built/boot/entry.js', [], {
|
||||||
|
stdout: process.stdout,
|
||||||
|
stderr: process.stderr,
|
||||||
|
env: {
|
||||||
|
'NODE_ENV': 'development',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function killProc() {
|
||||||
|
if (backendProcess) {
|
||||||
|
backendProcess.kill();
|
||||||
|
await new Promise(resolve => backendProcess.on('exit', resolve));
|
||||||
|
backendProcess = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
execaNode(
|
||||||
|
'./node_modules/nodemon/bin/nodemon.js',
|
||||||
|
[
|
||||||
|
'-w', 'src',
|
||||||
|
'-e', 'ts,js,mjs,cjs,json',
|
||||||
|
'--exec', 'pnpm', 'run', 'build',
|
||||||
|
],
|
||||||
|
{
|
||||||
|
stdio: [process.stdin, process.stdout, process.stderr, 'ipc'],
|
||||||
|
})
|
||||||
|
.on('message', async (message) => {
|
||||||
|
if (message.type === 'exit') {
|
||||||
|
// かならずbuild->build-assetsの順番で呼び出したいので、
|
||||||
|
// 少々トリッキーだがnodemonからのexitイベントを利用してbuild-assets->startを行う。
|
||||||
|
// pnpm restartをbuildが終わる前にbuild-assetsが動いてしまうので、バラバラに呼び出す必要がある
|
||||||
|
|
||||||
|
await killProc();
|
||||||
|
await execBuildAssets();
|
||||||
|
execStart();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})();
|
|
@ -3,8 +3,8 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { loadConfig } from './built/config.js'
|
import { loadConfig } from '../built/config.js'
|
||||||
import { genOpenapiSpec } from './built/server/api/openapi/gen-spec.js'
|
import { genOpenapiSpec } from '../built/server/api/openapi/gen-spec.js'
|
||||||
import { writeFileSync } from "node:fs";
|
import { writeFileSync } from "node:fs";
|
||||||
|
|
||||||
const config = loadConfig();
|
const config = loadConfig();
|
|
@ -305,7 +305,7 @@ export class AccountMoveService {
|
||||||
let resultUser: MiLocalUser | MiRemoteUser | null = null;
|
let resultUser: MiLocalUser | MiRemoteUser | null = null;
|
||||||
|
|
||||||
if (this.userEntityService.isRemoteUser(dst)) {
|
if (this.userEntityService.isRemoteUser(dst)) {
|
||||||
if ((new Date()).getTime() - (dst.lastFetchedAt?.getTime() ?? 0) > 10 * 1000) {
|
if (Date.now() - (dst.lastFetchedAt?.getTime() ?? 0) > 10 * 1000) {
|
||||||
await this.apPersonService.updatePerson(dst.uri);
|
await this.apPersonService.updatePerson(dst.uri);
|
||||||
}
|
}
|
||||||
dst = await this.apPersonService.fetchPerson(dst.uri) ?? dst;
|
dst = await this.apPersonService.fetchPerson(dst.uri) ?? dst;
|
||||||
|
@ -321,7 +321,7 @@ export class AccountMoveService {
|
||||||
if (!src) continue; // oldAccountを探してもこのサーバーに存在しない場合はフォロー関係もないということなのでスルー
|
if (!src) continue; // oldAccountを探してもこのサーバーに存在しない場合はフォロー関係もないということなのでスルー
|
||||||
|
|
||||||
if (this.userEntityService.isRemoteUser(dst)) {
|
if (this.userEntityService.isRemoteUser(dst)) {
|
||||||
if ((new Date()).getTime() - (src.lastFetchedAt?.getTime() ?? 0) > 10 * 1000) {
|
if (Date.now() - (src.lastFetchedAt?.getTime() ?? 0) > 10 * 1000) {
|
||||||
await this.apPersonService.updatePerson(srcUri);
|
await this.apPersonService.updatePerson(srcUri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { query } from '@/misc/prelude/url.js';
|
||||||
import type { Serialized } from '@/types.js';
|
import type { Serialized } from '@/types.js';
|
||||||
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||||
|
|
||||||
const parseEmojiStrRegexp = /^(\w+)(?:@([\w.-]+))?$/;
|
const parseEmojiStrRegexp = /^([-\w]+)(?:@([\w.-]+))?$/;
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CustomEmojiService implements OnApplicationShutdown {
|
export class CustomEmojiService implements OnApplicationShutdown {
|
||||||
|
|
|
@ -13,7 +13,7 @@ import type { NotesRepository } from '@/models/_.js';
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
import { FanoutTimelineName, FanoutTimelineService } from '@/core/FanoutTimelineService.js';
|
import { FanoutTimelineName, FanoutTimelineService } from '@/core/FanoutTimelineService.js';
|
||||||
import { isUserRelated } from '@/misc/is-user-related.js';
|
import { isUserRelated } from '@/misc/is-user-related.js';
|
||||||
import { isPureRenote } from '@/misc/is-pure-renote.js';
|
import { isQuote, isRenote } from '@/misc/is-renote.js';
|
||||||
import { CacheService } from '@/core/CacheService.js';
|
import { CacheService } from '@/core/CacheService.js';
|
||||||
import { isReply } from '@/misc/is-reply.js';
|
import { isReply } from '@/misc/is-reply.js';
|
||||||
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
|
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
|
||||||
|
@ -95,7 +95,7 @@ export class FanoutTimelineEndpointService {
|
||||||
|
|
||||||
if (ps.excludePureRenotes) {
|
if (ps.excludePureRenotes) {
|
||||||
const parentFilter = filter;
|
const parentFilter = filter;
|
||||||
filter = (note) => !isPureRenote(note) && parentFilter(note);
|
filter = (note) => (!isRenote(note) || isQuote(note)) && parentFilter(note);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ps.me) {
|
if (ps.me) {
|
||||||
|
@ -116,7 +116,7 @@ export class FanoutTimelineEndpointService {
|
||||||
filter = (note) => {
|
filter = (note) => {
|
||||||
if (isUserRelated(note, userIdsWhoBlockingMe, ps.ignoreAuthorFromBlock)) return false;
|
if (isUserRelated(note, userIdsWhoBlockingMe, ps.ignoreAuthorFromBlock)) return false;
|
||||||
if (isUserRelated(note, userIdsWhoMeMuting, ps.ignoreAuthorFromMute)) return false;
|
if (isUserRelated(note, userIdsWhoMeMuting, ps.ignoreAuthorFromMute)) return false;
|
||||||
if (isPureRenote(note) && isUserRelated(note, userIdsWhoMeMutingRenotes, ps.ignoreAuthorFromMute)) return false;
|
if (!ps.ignoreAuthorFromMute && isRenote(note) && !isQuote(note) && userIdsWhoMeMutingRenotes.has(note.userId)) return false;
|
||||||
if (isInstanceMuted(note, userMutedInstances)) return false;
|
if (isInstanceMuted(note, userMutedInstances)) return false;
|
||||||
|
|
||||||
return parentFilter(note);
|
return parentFilter(note);
|
||||||
|
|
|
@ -18,6 +18,8 @@ import { sharpBmp } from '@misskey-dev/sharp-read-bmp';
|
||||||
import { encode } from 'blurhash';
|
import { encode } from 'blurhash';
|
||||||
import { createTempDir } from '@/misc/create-temp.js';
|
import { createTempDir } from '@/misc/create-temp.js';
|
||||||
import { AiService } from '@/core/AiService.js';
|
import { AiService } from '@/core/AiService.js';
|
||||||
|
import { LoggerService } from '@/core/LoggerService.js';
|
||||||
|
import type Logger from '@/logger.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
|
|
||||||
export type FileInfo = {
|
export type FileInfo = {
|
||||||
|
@ -48,9 +50,13 @@ const TYPE_SVG = {
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class FileInfoService {
|
export class FileInfoService {
|
||||||
|
private logger: Logger;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private aiService: AiService,
|
private aiService: AiService,
|
||||||
|
private loggerService: LoggerService,
|
||||||
) {
|
) {
|
||||||
|
this.logger = this.loggerService.getLogger('file-info');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -316,6 +322,34 @@ export class FileInfoService {
|
||||||
return mime;
|
return mime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ビデオファイルにビデオトラックがあるかどうかチェック
|
||||||
|
* (ない場合:m4a, webmなど)
|
||||||
|
*
|
||||||
|
* @param path ファイルパス
|
||||||
|
* @returns ビデオトラックがあるかどうか(エラー発生時は常に`true`を返す)
|
||||||
|
*/
|
||||||
|
@bindThis
|
||||||
|
private hasVideoTrackOnVideoFile(path: string): Promise<boolean> {
|
||||||
|
const sublogger = this.logger.createSubLogger('ffprobe');
|
||||||
|
sublogger.info(`Checking the video file. File path: ${path}`);
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
try {
|
||||||
|
FFmpeg.ffprobe(path, (err, metadata) => {
|
||||||
|
if (err) {
|
||||||
|
sublogger.warn(`Could not check the video file. Returns true. File path: ${path}`, err);
|
||||||
|
resolve(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resolve(metadata.streams.some((stream) => stream.codec_type === 'video'));
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
sublogger.warn(`Could not check the video file. Returns true. File path: ${path}`, err as Error);
|
||||||
|
resolve(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Detect MIME Type and extension
|
* Detect MIME Type and extension
|
||||||
*/
|
*/
|
||||||
|
@ -338,6 +372,20 @@ export class FileInfoService {
|
||||||
return TYPE_SVG;
|
return TYPE_SVG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((type.mime.startsWith('video') || type.mime === 'application/ogg') && !(await this.hasVideoTrackOnVideoFile(path))) {
|
||||||
|
const newMime = `audio/${type.mime.split('/')[1]}`;
|
||||||
|
if (newMime === 'audio/mp4') {
|
||||||
|
return {
|
||||||
|
mime: 'audio/mp4',
|
||||||
|
ext: 'm4a',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
mime: newMime,
|
||||||
|
ext: type.ext,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
mime: this.fixMime(type.mime),
|
mime: this.fixMime(type.mime),
|
||||||
ext: type.ext,
|
ext: type.ext,
|
||||||
|
|
|
@ -6,10 +6,11 @@
|
||||||
import { URL } from 'node:url';
|
import { URL } from 'node:url';
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import * as parse5 from 'parse5';
|
import * as parse5 from 'parse5';
|
||||||
import { Window } from 'happy-dom';
|
import { Window, XMLSerializer } from 'happy-dom';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import type { Config } from '@/config.js';
|
import type { Config } from '@/config.js';
|
||||||
import { intersperse } from '@/misc/prelude/array.js';
|
import { intersperse } from '@/misc/prelude/array.js';
|
||||||
|
import { normalizeForSearch } from '@/misc/normalize-for-search.js';
|
||||||
import type { IMentionedRemoteUsers } from '@/models/Note.js';
|
import type { IMentionedRemoteUsers } from '@/models/Note.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import * as TreeAdapter from '../../node_modules/parse5/dist/tree-adapters/default.js';
|
import * as TreeAdapter from '../../node_modules/parse5/dist/tree-adapters/default.js';
|
||||||
|
@ -33,6 +34,8 @@ export class MfmService {
|
||||||
// some AP servers like Pixelfed use br tags as well as newlines
|
// some AP servers like Pixelfed use br tags as well as newlines
|
||||||
html = html.replace(/<br\s?\/?>\r?\n/gi, '\n');
|
html = html.replace(/<br\s?\/?>\r?\n/gi, '\n');
|
||||||
|
|
||||||
|
const normalizedHashtagNames = hashtagNames == null ? undefined : new Set<string>(hashtagNames.map(x => normalizeForSearch(x)));
|
||||||
|
|
||||||
const dom = parse5.parseFragment(html);
|
const dom = parse5.parseFragment(html);
|
||||||
|
|
||||||
let text = '';
|
let text = '';
|
||||||
|
@ -85,7 +88,7 @@ export class MfmService {
|
||||||
const href = node.attrs.find(x => x.name === 'href');
|
const href = node.attrs.find(x => x.name === 'href');
|
||||||
|
|
||||||
// ハッシュタグ
|
// ハッシュタグ
|
||||||
if (hashtagNames && href && hashtagNames.map(x => x.toLowerCase()).includes(txt.toLowerCase())) {
|
if (normalizedHashtagNames && href && normalizedHashtagNames.has(normalizeForSearch(txt))) {
|
||||||
text += txt;
|
text += txt;
|
||||||
// メンション
|
// メンション
|
||||||
} else if (txt.startsWith('@') && !(rel && rel.value.startsWith('me '))) {
|
} else if (txt.startsWith('@') && !(rel && rel.value.startsWith('me '))) {
|
||||||
|
@ -244,6 +247,8 @@ export class MfmService {
|
||||||
|
|
||||||
const doc = window.document;
|
const doc = window.document;
|
||||||
|
|
||||||
|
const body = doc.createElement('p');
|
||||||
|
|
||||||
function appendChildren(children: mfm.MfmNode[], targetElement: any): void {
|
function appendChildren(children: mfm.MfmNode[], targetElement: any): void {
|
||||||
if (children) {
|
if (children) {
|
||||||
for (const child of children.map(x => (handlers as any)[x.type](x))) targetElement.appendChild(child);
|
for (const child of children.map(x => (handlers as any)[x.type](x))) targetElement.appendChild(child);
|
||||||
|
@ -454,8 +459,8 @@ export class MfmService {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
appendChildren(nodes, doc.body);
|
appendChildren(nodes, body);
|
||||||
|
|
||||||
return `<p>${doc.body.innerHTML}</p>`;
|
return new XMLSerializer().serializeToString(body);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -318,7 +318,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check blocking
|
// Check blocking
|
||||||
if (data.renote && !this.isQuote(data)) {
|
if (this.isRenote(data) && !this.isQuote(data)) {
|
||||||
if (data.renote.userHost === null) {
|
if (data.renote.userHost === null) {
|
||||||
if (data.renote.userId !== user.id) {
|
if (data.renote.userId !== user.id) {
|
||||||
const blocked = await this.userBlockingService.checkBlocked(data.renote.userId, user.id);
|
const blocked = await this.userBlockingService.checkBlocked(data.renote.userId, user.id);
|
||||||
|
@ -678,7 +678,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it is renote
|
// If it is renote
|
||||||
if (data.renote) {
|
if (this.isRenote(data)) {
|
||||||
const type = this.isQuote(data) ? 'quote' : 'renote';
|
const type = this.isQuote(data) ? 'quote' : 'renote';
|
||||||
|
|
||||||
// Notify
|
// Notify
|
||||||
|
@ -791,9 +791,20 @@ export class NoteCreateService implements OnApplicationShutdown {
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
private isQuote(note: Option): note is Option & { renote: MiNote } {
|
private isRenote(note: Option): note is Option & { renote: MiNote } {
|
||||||
// sync with misc/is-quote.ts
|
return note.renote != null;
|
||||||
return !!note.renote && (!!note.text || !!note.cw || (!!note.files && !!note.files.length) || !!note.poll);
|
}
|
||||||
|
|
||||||
|
@bindThis
|
||||||
|
private isQuote(note: Option & { renote: MiNote }): note is Option & { renote: MiNote } & (
|
||||||
|
{ text: string } | { cw: string } | { reply: MiNote } | { poll: IPoll } | { files: MiDriveFile[] }
|
||||||
|
) {
|
||||||
|
// NOTE: SYNC WITH misc/is-quote.ts
|
||||||
|
return note.text != null ||
|
||||||
|
note.reply != null ||
|
||||||
|
note.cw != null ||
|
||||||
|
note.poll != null ||
|
||||||
|
(note.files != null && note.files.length > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
|
@ -862,7 +873,7 @@ export class NoteCreateService implements OnApplicationShutdown {
|
||||||
private async renderNoteOrRenoteActivity(data: Option, note: MiNote) {
|
private async renderNoteOrRenoteActivity(data: Option, note: MiNote) {
|
||||||
if (data.localOnly) return null;
|
if (data.localOnly) return null;
|
||||||
|
|
||||||
const content = data.renote && !this.isQuote(data)
|
const content = this.isRenote(data) && !this.isQuote(data)
|
||||||
? this.apRendererService.renderAnnounce(data.renote.uri ? data.renote.uri : `${this.config.url}/notes/${data.renote.id}`, note)
|
? this.apRendererService.renderAnnounce(data.renote.uri ? data.renote.uri : `${this.config.url}/notes/${data.renote.id}`, note)
|
||||||
: this.apRendererService.renderCreate(await this.apRendererService.renderNote(note, false), note);
|
: this.apRendererService.renderCreate(await this.apRendererService.renderNote(note, false), note);
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ import { bindThis } from '@/decorators.js';
|
||||||
import { MetaService } from '@/core/MetaService.js';
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
import { SearchService } from '@/core/SearchService.js';
|
import { SearchService } from '@/core/SearchService.js';
|
||||||
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
import { ModerationLogService } from '@/core/ModerationLogService.js';
|
||||||
import { isPureRenote } from '@/misc/is-pure-renote.js';
|
import { isQuote, isRenote } from '@/misc/is-renote.js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class NoteDeleteService {
|
export class NoteDeleteService {
|
||||||
|
@ -79,7 +79,7 @@ export class NoteDeleteService {
|
||||||
let renote: MiNote | null = null;
|
let renote: MiNote | null = null;
|
||||||
|
|
||||||
// if deleted note is renote
|
// if deleted note is renote
|
||||||
if (isPureRenote(note)) {
|
if (isRenote(note) && !isQuote(note)) {
|
||||||
renote = await this.notesRepository.findOneBy({
|
renote = await this.notesRepository.findOneBy({
|
||||||
id: note.renoteId,
|
id: note.renoteId,
|
||||||
});
|
});
|
||||||
|
|
|
@ -101,7 +101,7 @@ export class PushNotificationService implements OnApplicationShutdown {
|
||||||
type,
|
type,
|
||||||
body: (type === 'notification' || type === 'unreadAntennaNote') ? truncateBody(type, body) : body,
|
body: (type === 'notification' || type === 'unreadAntennaNote') ? truncateBody(type, body) : body,
|
||||||
userId,
|
userId,
|
||||||
dateTime: (new Date()).getTime(),
|
dateTime: Date.now(),
|
||||||
}), {
|
}), {
|
||||||
proxy: this.config.proxy,
|
proxy: this.config.proxy,
|
||||||
}).catch((err: any) => {
|
}).catch((err: any) => {
|
||||||
|
|
|
@ -226,45 +226,79 @@ export class RoleService implements OnApplicationShutdown, OnModuleInit {
|
||||||
private evalCond(user: MiUser, roles: MiRole[], value: RoleCondFormulaValue): boolean {
|
private evalCond(user: MiUser, roles: MiRole[], value: RoleCondFormulaValue): boolean {
|
||||||
try {
|
try {
|
||||||
switch (value.type) {
|
switch (value.type) {
|
||||||
|
// ~かつ~
|
||||||
case 'and': {
|
case 'and': {
|
||||||
return value.values.every(v => this.evalCond(user, roles, v));
|
return value.values.every(v => this.evalCond(user, roles, v));
|
||||||
}
|
}
|
||||||
|
// ~または~
|
||||||
case 'or': {
|
case 'or': {
|
||||||
return value.values.some(v => this.evalCond(user, roles, v));
|
return value.values.some(v => this.evalCond(user, roles, v));
|
||||||
}
|
}
|
||||||
|
// ~ではない
|
||||||
case 'not': {
|
case 'not': {
|
||||||
return !this.evalCond(user, roles, value.value);
|
return !this.evalCond(user, roles, value.value);
|
||||||
}
|
}
|
||||||
|
// マニュアルロールがアサインされている
|
||||||
case 'roleAssignedTo': {
|
case 'roleAssignedTo': {
|
||||||
return roles.some(r => r.id === value.roleId);
|
return roles.some(r => r.id === value.roleId);
|
||||||
}
|
}
|
||||||
|
// ローカルユーザのみ
|
||||||
case 'isLocal': {
|
case 'isLocal': {
|
||||||
return this.userEntityService.isLocalUser(user);
|
return this.userEntityService.isLocalUser(user);
|
||||||
}
|
}
|
||||||
|
// リモートユーザのみ
|
||||||
case 'isRemote': {
|
case 'isRemote': {
|
||||||
return this.userEntityService.isRemoteUser(user);
|
return this.userEntityService.isRemoteUser(user);
|
||||||
}
|
}
|
||||||
|
// サスペンド済みユーザである
|
||||||
|
case 'isSuspended': {
|
||||||
|
return user.isSuspended;
|
||||||
|
}
|
||||||
|
// 鍵アカウントユーザである
|
||||||
|
case 'isLocked': {
|
||||||
|
return user.isLocked;
|
||||||
|
}
|
||||||
|
// botユーザである
|
||||||
|
case 'isBot': {
|
||||||
|
return user.isBot;
|
||||||
|
}
|
||||||
|
// 猫である
|
||||||
|
case 'isCat': {
|
||||||
|
return user.isCat;
|
||||||
|
}
|
||||||
|
// 「ユーザを見つけやすくする」が有効なアカウント
|
||||||
|
case 'isExplorable': {
|
||||||
|
return user.isExplorable;
|
||||||
|
}
|
||||||
|
// ユーザが作成されてから指定期間経過した
|
||||||
case 'createdLessThan': {
|
case 'createdLessThan': {
|
||||||
return this.idService.parse(user.id).date.getTime() > (Date.now() - (value.sec * 1000));
|
return this.idService.parse(user.id).date.getTime() > (Date.now() - (value.sec * 1000));
|
||||||
}
|
}
|
||||||
|
// ユーザが作成されてから指定期間経っていない
|
||||||
case 'createdMoreThan': {
|
case 'createdMoreThan': {
|
||||||
return this.idService.parse(user.id).date.getTime() < (Date.now() - (value.sec * 1000));
|
return this.idService.parse(user.id).date.getTime() < (Date.now() - (value.sec * 1000));
|
||||||
}
|
}
|
||||||
|
// フォロワー数が指定値以下
|
||||||
case 'followersLessThanOrEq': {
|
case 'followersLessThanOrEq': {
|
||||||
return user.followersCount <= value.value;
|
return user.followersCount <= value.value;
|
||||||
}
|
}
|
||||||
|
// フォロワー数が指定値以上
|
||||||
case 'followersMoreThanOrEq': {
|
case 'followersMoreThanOrEq': {
|
||||||
return user.followersCount >= value.value;
|
return user.followersCount >= value.value;
|
||||||
}
|
}
|
||||||
|
// フォロー数が指定値以下
|
||||||
case 'followingLessThanOrEq': {
|
case 'followingLessThanOrEq': {
|
||||||
return user.followingCount <= value.value;
|
return user.followingCount <= value.value;
|
||||||
}
|
}
|
||||||
|
// フォロー数が指定値以上
|
||||||
case 'followingMoreThanOrEq': {
|
case 'followingMoreThanOrEq': {
|
||||||
return user.followingCount >= value.value;
|
return user.followingCount >= value.value;
|
||||||
}
|
}
|
||||||
|
// ノート数が指定値以下
|
||||||
case 'notesLessThanOrEq': {
|
case 'notesLessThanOrEq': {
|
||||||
return user.notesCount <= value.value;
|
return user.notesCount <= value.value;
|
||||||
}
|
}
|
||||||
|
// ノート数が指定値以上
|
||||||
case 'notesMoreThanOrEq': {
|
case 'notesMoreThanOrEq': {
|
||||||
return user.notesCount >= value.value;
|
return user.notesCount >= value.value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { bindThis } from '@/decorators.js';
|
||||||
import { checkHttps } from '@/misc/check-https.js';
|
import { checkHttps } from '@/misc/check-https.js';
|
||||||
import { ApResolverService } from '../ApResolverService.js';
|
import { ApResolverService } from '../ApResolverService.js';
|
||||||
import { ApLoggerService } from '../ApLoggerService.js';
|
import { ApLoggerService } from '../ApLoggerService.js';
|
||||||
import type { IObject } from '../type.js';
|
import { isDocument, type IObject } from '../type.js';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ApImageService {
|
export class ApImageService {
|
||||||
|
@ -39,7 +39,7 @@ export class ApImageService {
|
||||||
* Imageを作成します。
|
* Imageを作成します。
|
||||||
*/
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
public async createImage(actor: MiRemoteUser, value: string | IObject): Promise<MiDriveFile> {
|
public async createImage(actor: MiRemoteUser, value: string | IObject): Promise<MiDriveFile | null> {
|
||||||
// 投稿者が凍結されていたらスキップ
|
// 投稿者が凍結されていたらスキップ
|
||||||
if (actor.isSuspended) {
|
if (actor.isSuspended) {
|
||||||
throw new Error('actor has been suspended');
|
throw new Error('actor has been suspended');
|
||||||
|
@ -47,16 +47,18 @@ export class ApImageService {
|
||||||
|
|
||||||
const image = await this.apResolverService.createResolver().resolve(value);
|
const image = await this.apResolverService.createResolver().resolve(value);
|
||||||
|
|
||||||
|
if (!isDocument(image)) return null;
|
||||||
|
|
||||||
if (image.url == null) {
|
if (image.url == null) {
|
||||||
throw new Error('invalid image: url not provided');
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof image.url !== 'string') {
|
if (typeof image.url !== 'string') {
|
||||||
throw new Error('invalid image: unexpected type of url: ' + JSON.stringify(image.url, null, 2));
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!checkHttps(image.url)) {
|
if (!checkHttps(image.url)) {
|
||||||
throw new Error('invalid image: unexpected schema of url: ' + image.url);
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.info(`Creating the Image: ${image.url}`);
|
this.logger.info(`Creating the Image: ${image.url}`);
|
||||||
|
@ -86,12 +88,11 @@ export class ApImageService {
|
||||||
/**
|
/**
|
||||||
* Imageを解決します。
|
* Imageを解決します。
|
||||||
*
|
*
|
||||||
* Misskeyに対象のImageが登録されていればそれを返し、そうでなければ
|
* ImageをリモートサーバーからフェッチしてMisskeyに登録しそれを返します。
|
||||||
* リモートサーバーからフェッチしてMisskeyに登録しそれを返します。
|
|
||||||
*/
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
public async resolveImage(actor: MiRemoteUser, value: string | IObject): Promise<MiDriveFile> {
|
public async resolveImage(actor: MiRemoteUser, value: string | IObject): Promise<MiDriveFile | null> {
|
||||||
// TODO
|
// TODO: Misskeyに対象のImageが登録されていればそれを返す
|
||||||
|
|
||||||
// リモートサーバーからフェッチしてきて登録
|
// リモートサーバーからフェッチしてきて登録
|
||||||
return await this.createImage(actor, value);
|
return await this.createImage(actor, value);
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { forwardRef, Inject, Injectable } from '@nestjs/common';
|
import { forwardRef, Inject, Injectable } from '@nestjs/common';
|
||||||
import promiseLimit from 'promise-limit';
|
|
||||||
import { In } from 'typeorm';
|
import { In } from 'typeorm';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import type { UsersRepository, PollsRepository, EmojisRepository } from '@/models/_.js';
|
import type { UsersRepository, PollsRepository, EmojisRepository } from '@/models/_.js';
|
||||||
|
@ -217,15 +216,13 @@ export class ApNoteService {
|
||||||
const isSensitiveMediaHost = this.utilityService.isSensitiveMediaHost(meta.sensitiveMediaHosts, this.utilityService.extractDbHost(note.id ?? entryUri));
|
const isSensitiveMediaHost = this.utilityService.isSensitiveMediaHost(meta.sensitiveMediaHosts, this.utilityService.extractDbHost(note.id ?? entryUri));
|
||||||
|
|
||||||
// 添付ファイル
|
// 添付ファイル
|
||||||
// TODO: attachmentは必ずしもImageではない
|
const files: MiDriveFile[] = [];
|
||||||
// TODO: attachmentは必ずしも配列ではない
|
|
||||||
const limit = promiseLimit<MiDriveFile>(2);
|
for (const attach of toArray(note.attachment)) {
|
||||||
const files = (await Promise.all(toArray(note.attachment).map(attach => (
|
attach.sensitive ||= isSensitiveMediaHost || note.sensitive; // Noteがsensitiveなら添付もsensitiveにする
|
||||||
limit(() => this.apImageService.resolveImage(actor, {
|
const file = await this.apImageService.resolveImage(actor, attach);
|
||||||
...attach,
|
if (file) files.push(file);
|
||||||
sensitive: isSensitiveMediaHost || note.sensitive, // Noteがsensitiveなら添付もsensitiveにする
|
}
|
||||||
}))
|
|
||||||
))));
|
|
||||||
|
|
||||||
// リプライ
|
// リプライ
|
||||||
const reply: MiNote | null = note.inReplyTo
|
const reply: MiNote | null = note.inReplyTo
|
||||||
|
|
|
@ -25,6 +25,7 @@ export interface IObject {
|
||||||
endTime?: Date;
|
endTime?: Date;
|
||||||
icon?: any;
|
icon?: any;
|
||||||
image?: any;
|
image?: any;
|
||||||
|
mediaType?: string;
|
||||||
url?: ApObject | string;
|
url?: ApObject | string;
|
||||||
href?: string;
|
href?: string;
|
||||||
tag?: IObject | IObject[];
|
tag?: IObject | IObject[];
|
||||||
|
@ -240,14 +241,14 @@ export interface IKey extends IObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IApDocument extends IObject {
|
export interface IApDocument extends IObject {
|
||||||
type: 'Document';
|
type: 'Audio' | 'Document' | 'Image' | 'Page' | 'Video';
|
||||||
name: string | null;
|
|
||||||
mediaType: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IApImage extends IObject {
|
export const isDocument = (object: IObject): object is IApDocument =>
|
||||||
|
['Audio', 'Document', 'Image', 'Page', 'Video'].includes(getApType(object));
|
||||||
|
|
||||||
|
export interface IApImage extends IApDocument {
|
||||||
type: 'Image';
|
type: 'Image';
|
||||||
name: string | null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ICreate extends IActivity {
|
export interface ICreate extends IActivity {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import type { ClipFavoritesRepository, ClipsRepository, MiUser } from '@/models/_.js';
|
import type { ClipNotesRepository, ClipFavoritesRepository, ClipsRepository, MiUser } from '@/models/_.js';
|
||||||
import { awaitAll } from '@/misc/prelude/await-all.js';
|
import { awaitAll } from '@/misc/prelude/await-all.js';
|
||||||
import type { Packed } from '@/misc/json-schema.js';
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
import type { MiClip } from '@/models/Clip.js';
|
import type { MiClip } from '@/models/Clip.js';
|
||||||
|
@ -19,6 +19,9 @@ export class ClipEntityService {
|
||||||
@Inject(DI.clipsRepository)
|
@Inject(DI.clipsRepository)
|
||||||
private clipsRepository: ClipsRepository,
|
private clipsRepository: ClipsRepository,
|
||||||
|
|
||||||
|
@Inject(DI.clipNotesRepository)
|
||||||
|
private clipNotesRepository: ClipNotesRepository,
|
||||||
|
|
||||||
@Inject(DI.clipFavoritesRepository)
|
@Inject(DI.clipFavoritesRepository)
|
||||||
private clipFavoritesRepository: ClipFavoritesRepository,
|
private clipFavoritesRepository: ClipFavoritesRepository,
|
||||||
|
|
||||||
|
@ -46,6 +49,7 @@ export class ClipEntityService {
|
||||||
isPublic: clip.isPublic,
|
isPublic: clip.isPublic,
|
||||||
favoritedCount: await this.clipFavoritesRepository.countBy({ clipId: clip.id }),
|
favoritedCount: await this.clipFavoritesRepository.countBy({ clipId: clip.id }),
|
||||||
isFavorited: meId ? await this.clipFavoritesRepository.exists({ where: { clipId: clip.id, userId: meId } }) : undefined,
|
isFavorited: meId ? await this.clipFavoritesRepository.exists({ where: { clipId: clip.id, userId: meId } }) : undefined,
|
||||||
|
notesCount: meId ? await this.clipNotesRepository.countBy({ clipId: clip.id }) : undefined,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
/*
|
|
||||||
* 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']> } {
|
|
||||||
if (!note.renoteId) return false;
|
|
||||||
|
|
||||||
if (note.text) return false; // it's quoted with text
|
|
||||||
if (note.fileIds.length !== 0) return false; // it's quoted with files
|
|
||||||
if (note.hasPoll) return false; // it's quoted with poll
|
|
||||||
return true;
|
|
||||||
}
|
|
|
@ -1,12 +0,0 @@
|
||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: syuilo and misskey-project
|
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
|
||||||
*/
|
|
||||||
|
|
||||||
import type { MiNote } from '@/models/Note.js';
|
|
||||||
|
|
||||||
// eslint-disable-next-line import/no-default-export
|
|
||||||
export default function(note: MiNote): boolean {
|
|
||||||
// sync with NoteCreateService.isQuote
|
|
||||||
return note.renoteId != null && (note.text != null || note.hasPoll || (note.fileIds != null && note.fileIds.length > 0));
|
|
||||||
}
|
|
67
packages/backend/src/misc/is-renote.ts
Normal file
67
packages/backend/src/misc/is-renote.ts
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type { MiNote } from '@/models/Note.js';
|
||||||
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
|
|
||||||
|
type Renote =
|
||||||
|
MiNote & {
|
||||||
|
renoteId: NonNullable<MiNote['renoteId']>
|
||||||
|
};
|
||||||
|
|
||||||
|
type Quote =
|
||||||
|
Renote & ({
|
||||||
|
text: NonNullable<MiNote['text']>
|
||||||
|
} | {
|
||||||
|
cw: NonNullable<MiNote['cw']>
|
||||||
|
} | {
|
||||||
|
replyId: NonNullable<MiNote['replyId']>
|
||||||
|
reply: NonNullable<MiNote['reply']>
|
||||||
|
} | {
|
||||||
|
hasPoll: true
|
||||||
|
});
|
||||||
|
|
||||||
|
export function isRenote(note: MiNote): note is Renote {
|
||||||
|
return note.renoteId != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isQuote(note: Renote): note is Quote {
|
||||||
|
// NOTE: SYNC WITH NoteCreateService.isQuote
|
||||||
|
return note.text != null ||
|
||||||
|
note.cw != null ||
|
||||||
|
note.replyId != null ||
|
||||||
|
note.hasPoll ||
|
||||||
|
note.fileIds.length > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
type PackedRenote =
|
||||||
|
Packed<'Note'> & {
|
||||||
|
renoteId: NonNullable<Packed<'Note'>['renoteId']>
|
||||||
|
};
|
||||||
|
|
||||||
|
type PackedQuote =
|
||||||
|
PackedRenote & ({
|
||||||
|
text: NonNullable<Packed<'Note'>['text']>
|
||||||
|
} | {
|
||||||
|
cw: NonNullable<Packed<'Note'>['cw']>
|
||||||
|
} | {
|
||||||
|
replyId: NonNullable<Packed<'Note'>['replyId']>
|
||||||
|
} | {
|
||||||
|
poll: NonNullable<Packed<'Note'>['poll']>
|
||||||
|
} | {
|
||||||
|
fileIds: NonNullable<Packed<'Note'>['fileIds']>
|
||||||
|
});
|
||||||
|
|
||||||
|
export function isRenotePacked(note: Packed<'Note'>): note is PackedRenote {
|
||||||
|
return note.renoteId != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function isQuotePacked(note: PackedRenote): note is PackedQuote {
|
||||||
|
return note.text != null ||
|
||||||
|
note.cw != null ||
|
||||||
|
note.replyId != null ||
|
||||||
|
note.poll != null ||
|
||||||
|
(note.fileIds != null && note.fileIds.length > 0);
|
||||||
|
}
|
|
@ -50,6 +50,7 @@ import {
|
||||||
packedRoleCondFormulaValueCreatedSchema,
|
packedRoleCondFormulaValueCreatedSchema,
|
||||||
packedRoleCondFormulaFollowersOrFollowingOrNotesSchema,
|
packedRoleCondFormulaFollowersOrFollowingOrNotesSchema,
|
||||||
packedRoleCondFormulaValueSchema,
|
packedRoleCondFormulaValueSchema,
|
||||||
|
packedRoleCondFormulaValueUserSettingBooleanSchema,
|
||||||
} from '@/models/json-schema/role.js';
|
} from '@/models/json-schema/role.js';
|
||||||
import { packedAdSchema } from '@/models/json-schema/ad.js';
|
import { packedAdSchema } from '@/models/json-schema/ad.js';
|
||||||
import { packedReversiGameLiteSchema, packedReversiGameDetailedSchema } from '@/models/json-schema/reversi-game.js';
|
import { packedReversiGameLiteSchema, packedReversiGameDetailedSchema } from '@/models/json-schema/reversi-game.js';
|
||||||
|
@ -105,6 +106,7 @@ export const refs = {
|
||||||
RoleCondFormulaLogics: packedRoleCondFormulaLogicsSchema,
|
RoleCondFormulaLogics: packedRoleCondFormulaLogicsSchema,
|
||||||
RoleCondFormulaValueNot: packedRoleCondFormulaValueNot,
|
RoleCondFormulaValueNot: packedRoleCondFormulaValueNot,
|
||||||
RoleCondFormulaValueIsLocalOrRemote: packedRoleCondFormulaValueIsLocalOrRemoteSchema,
|
RoleCondFormulaValueIsLocalOrRemote: packedRoleCondFormulaValueIsLocalOrRemoteSchema,
|
||||||
|
RoleCondFormulaValueUserSettingBooleanSchema: packedRoleCondFormulaValueUserSettingBooleanSchema,
|
||||||
RoleCondFormulaValueAssignedRole: packedRoleCondFormulaValueAssignedRoleSchema,
|
RoleCondFormulaValueAssignedRole: packedRoleCondFormulaValueAssignedRoleSchema,
|
||||||
RoleCondFormulaValueCreated: packedRoleCondFormulaValueCreatedSchema,
|
RoleCondFormulaValueCreated: packedRoleCondFormulaValueCreatedSchema,
|
||||||
RoleCondFormulaFollowersOrFollowingOrNotes: packedRoleCondFormulaFollowersOrFollowingOrNotesSchema,
|
RoleCondFormulaFollowersOrFollowingOrNotes: packedRoleCondFormulaFollowersOrFollowingOrNotesSchema,
|
||||||
|
|
|
@ -6,69 +6,149 @@
|
||||||
import { Entity, Column, PrimaryColumn, Index } from 'typeorm';
|
import { Entity, Column, PrimaryColumn, Index } from 'typeorm';
|
||||||
import { id } from './util/id.js';
|
import { id } from './util/id.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ~かつ~
|
||||||
|
* 複数の条件を同時に満たす場合のみ成立とする
|
||||||
|
*/
|
||||||
type CondFormulaValueAnd = {
|
type CondFormulaValueAnd = {
|
||||||
type: 'and';
|
type: 'and';
|
||||||
values: RoleCondFormulaValue[];
|
values: RoleCondFormulaValue[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ~または~
|
||||||
|
* 複数の条件のうち、いずれかを満たす場合のみ成立とする
|
||||||
|
*/
|
||||||
type CondFormulaValueOr = {
|
type CondFormulaValueOr = {
|
||||||
type: 'or';
|
type: 'or';
|
||||||
values: RoleCondFormulaValue[];
|
values: RoleCondFormulaValue[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ~ではない
|
||||||
|
* 条件を満たさない場合のみ成立とする
|
||||||
|
*/
|
||||||
type CondFormulaValueNot = {
|
type CondFormulaValueNot = {
|
||||||
type: 'not';
|
type: 'not';
|
||||||
value: RoleCondFormulaValue;
|
value: RoleCondFormulaValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ローカルユーザーのみ成立とする
|
||||||
|
*/
|
||||||
type CondFormulaValueIsLocal = {
|
type CondFormulaValueIsLocal = {
|
||||||
type: 'isLocal';
|
type: 'isLocal';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* リモートユーザーのみ成立とする
|
||||||
|
*/
|
||||||
type CondFormulaValueIsRemote = {
|
type CondFormulaValueIsRemote = {
|
||||||
type: 'isRemote';
|
type: 'isRemote';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 既に指定のマニュアルロールにアサインされている場合のみ成立とする
|
||||||
|
*/
|
||||||
type CondFormulaValueRoleAssignedTo = {
|
type CondFormulaValueRoleAssignedTo = {
|
||||||
type: 'roleAssignedTo';
|
type: 'roleAssignedTo';
|
||||||
roleId: string;
|
roleId: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* サスペンド済みアカウントの場合のみ成立とする
|
||||||
|
*/
|
||||||
|
type CondFormulaValueIsSuspended = {
|
||||||
|
type: 'isSuspended';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 鍵アカウントの場合のみ成立とする
|
||||||
|
*/
|
||||||
|
type CondFormulaValueIsLocked = {
|
||||||
|
type: 'isLocked';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* botアカウントの場合のみ成立とする
|
||||||
|
*/
|
||||||
|
type CondFormulaValueIsBot = {
|
||||||
|
type: 'isBot';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 猫アカウントの場合のみ成立とする
|
||||||
|
*/
|
||||||
|
type CondFormulaValueIsCat = {
|
||||||
|
type: 'isCat';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 「ユーザを見つけやすくする」が有効なアカウントの場合のみ成立とする
|
||||||
|
*/
|
||||||
|
type CondFormulaValueIsExplorable = {
|
||||||
|
type: 'isExplorable';
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ユーザが作成されてから指定期間経過した場合のみ成立とする
|
||||||
|
*/
|
||||||
type CondFormulaValueCreatedLessThan = {
|
type CondFormulaValueCreatedLessThan = {
|
||||||
type: 'createdLessThan';
|
type: 'createdLessThan';
|
||||||
sec: number;
|
sec: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ユーザが作成されてから指定期間経っていない場合のみ成立とする
|
||||||
|
*/
|
||||||
type CondFormulaValueCreatedMoreThan = {
|
type CondFormulaValueCreatedMoreThan = {
|
||||||
type: 'createdMoreThan';
|
type: 'createdMoreThan';
|
||||||
sec: number;
|
sec: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* フォロワー数が指定値以下の場合のみ成立とする
|
||||||
|
*/
|
||||||
type CondFormulaValueFollowersLessThanOrEq = {
|
type CondFormulaValueFollowersLessThanOrEq = {
|
||||||
type: 'followersLessThanOrEq';
|
type: 'followersLessThanOrEq';
|
||||||
value: number;
|
value: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* フォロワー数が指定値以上の場合のみ成立とする
|
||||||
|
*/
|
||||||
type CondFormulaValueFollowersMoreThanOrEq = {
|
type CondFormulaValueFollowersMoreThanOrEq = {
|
||||||
type: 'followersMoreThanOrEq';
|
type: 'followersMoreThanOrEq';
|
||||||
value: number;
|
value: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* フォロー数が指定値以下の場合のみ成立とする
|
||||||
|
*/
|
||||||
type CondFormulaValueFollowingLessThanOrEq = {
|
type CondFormulaValueFollowingLessThanOrEq = {
|
||||||
type: 'followingLessThanOrEq';
|
type: 'followingLessThanOrEq';
|
||||||
value: number;
|
value: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* フォロー数が指定値以上の場合のみ成立とする
|
||||||
|
*/
|
||||||
type CondFormulaValueFollowingMoreThanOrEq = {
|
type CondFormulaValueFollowingMoreThanOrEq = {
|
||||||
type: 'followingMoreThanOrEq';
|
type: 'followingMoreThanOrEq';
|
||||||
value: number;
|
value: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 投稿数が指定値以下の場合のみ成立とする
|
||||||
|
*/
|
||||||
type CondFormulaValueNotesLessThanOrEq = {
|
type CondFormulaValueNotesLessThanOrEq = {
|
||||||
type: 'notesLessThanOrEq';
|
type: 'notesLessThanOrEq';
|
||||||
value: number;
|
value: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 投稿数が指定値以上の場合のみ成立とする
|
||||||
|
*/
|
||||||
type CondFormulaValueNotesMoreThanOrEq = {
|
type CondFormulaValueNotesMoreThanOrEq = {
|
||||||
type: 'notesMoreThanOrEq';
|
type: 'notesMoreThanOrEq';
|
||||||
value: number;
|
value: number;
|
||||||
|
@ -80,6 +160,11 @@ export type RoleCondFormulaValue = { id: string } & (
|
||||||
CondFormulaValueNot |
|
CondFormulaValueNot |
|
||||||
CondFormulaValueIsLocal |
|
CondFormulaValueIsLocal |
|
||||||
CondFormulaValueIsRemote |
|
CondFormulaValueIsRemote |
|
||||||
|
CondFormulaValueIsSuspended |
|
||||||
|
CondFormulaValueIsLocked |
|
||||||
|
CondFormulaValueIsBot |
|
||||||
|
CondFormulaValueIsCat |
|
||||||
|
CondFormulaValueIsExplorable |
|
||||||
CondFormulaValueRoleAssignedTo |
|
CondFormulaValueRoleAssignedTo |
|
||||||
CondFormulaValueCreatedLessThan |
|
CondFormulaValueCreatedLessThan |
|
||||||
CondFormulaValueCreatedMoreThan |
|
CondFormulaValueCreatedMoreThan |
|
||||||
|
|
|
@ -52,5 +52,9 @@ export const packedClipSchema = {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
optional: true, nullable: false,
|
optional: true, nullable: false,
|
||||||
},
|
},
|
||||||
|
notesCount: {
|
||||||
|
type: 'integer',
|
||||||
|
optional: true, nullable: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
|
@ -57,6 +57,20 @@ export const packedRoleCondFormulaValueIsLocalOrRemoteSchema = {
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
export const packedRoleCondFormulaValueUserSettingBooleanSchema = {
|
||||||
|
type: 'object',
|
||||||
|
properties: {
|
||||||
|
id: {
|
||||||
|
type: 'string', optional: false,
|
||||||
|
},
|
||||||
|
type: {
|
||||||
|
type: 'string',
|
||||||
|
nullable: false, optional: false,
|
||||||
|
enum: ['isSuspended', 'isLocked', 'isBot', 'isCat', 'isExplorable'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
} as const;
|
||||||
|
|
||||||
export const packedRoleCondFormulaValueAssignedRoleSchema = {
|
export const packedRoleCondFormulaValueAssignedRoleSchema = {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
|
@ -135,6 +149,9 @@ export const packedRoleCondFormulaValueSchema = {
|
||||||
{
|
{
|
||||||
ref: 'RoleCondFormulaValueIsLocalOrRemote',
|
ref: 'RoleCondFormulaValueIsLocalOrRemote',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
ref: 'RoleCondFormulaValueUserSettingBooleanSchema',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
ref: 'RoleCondFormulaValueAssignedRole',
|
ref: 'RoleCondFormulaValueAssignedRole',
|
||||||
},
|
},
|
||||||
|
|
|
@ -63,7 +63,7 @@ export class CleanRemoteFilesProcessorService {
|
||||||
isLink: false,
|
isLink: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
job.updateProgress(deletedCount / total);
|
job.updateProgress(100 / total * deletedCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.succ('All cached remote files has been deleted.');
|
this.logger.succ('All cached remote files has been deleted.');
|
||||||
|
|
|
@ -28,7 +28,7 @@ import { UtilityService } from '@/core/UtilityService.js';
|
||||||
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { IActivity } from '@/core/activitypub/type.js';
|
import { IActivity } from '@/core/activitypub/type.js';
|
||||||
import { isPureRenote } from '@/misc/is-pure-renote.js';
|
import { isQuote, isRenote } from '@/misc/is-renote.js';
|
||||||
import type { FastifyInstance, FastifyRequest, FastifyReply, FastifyPluginOptions, FastifyBodyParser } from 'fastify';
|
import type { FastifyInstance, FastifyRequest, FastifyReply, FastifyPluginOptions, FastifyBodyParser } from 'fastify';
|
||||||
import type { FindOptionsWhere } from 'typeorm';
|
import type { FindOptionsWhere } from 'typeorm';
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ export class ActivityPubServerService {
|
||||||
*/
|
*/
|
||||||
@bindThis
|
@bindThis
|
||||||
private async packActivity(note: MiNote): Promise<any> {
|
private async packActivity(note: MiNote): Promise<any> {
|
||||||
if (isPureRenote(note)) {
|
if (isRenote(note) && !isQuote(note)) {
|
||||||
const renote = await this.notesRepository.findOneByOrFail({ id: note.renoteId });
|
const renote = await this.notesRepository.findOneByOrFail({ id: note.renoteId });
|
||||||
return this.apRendererService.renderAnnounce(renote.uri ? renote.uri : `${this.config.url}/notes/${renote.id}`, note);
|
return this.apRendererService.renderAnnounce(renote.uri ? renote.uri : `${this.config.url}/notes/${renote.id}`, note);
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,6 +194,7 @@ export class FileServerService {
|
||||||
reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
|
reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
|
||||||
reply.header('Accept-Ranges', 'bytes');
|
reply.header('Accept-Ranges', 'bytes');
|
||||||
reply.header('Content-Length', chunksize);
|
reply.header('Content-Length', chunksize);
|
||||||
|
reply.code(206);
|
||||||
} else {
|
} else {
|
||||||
image = {
|
image = {
|
||||||
data: fs.createReadStream(file.path),
|
data: fs.createReadStream(file.path),
|
||||||
|
@ -213,6 +214,8 @@ export class FileServerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.header('Content-Type', FILE_TYPE_BROWSERSAFE.includes(image.type) ? image.type : 'application/octet-stream');
|
reply.header('Content-Type', FILE_TYPE_BROWSERSAFE.includes(image.type) ? image.type : 'application/octet-stream');
|
||||||
|
reply.header('Content-Length', file.file.size);
|
||||||
|
reply.header('Cache-Control', 'max-age=31536000, immutable');
|
||||||
reply.header('Content-Disposition',
|
reply.header('Content-Disposition',
|
||||||
contentDisposition(
|
contentDisposition(
|
||||||
'inline',
|
'inline',
|
||||||
|
@ -255,6 +258,7 @@ export class FileServerService {
|
||||||
return fs.createReadStream(file.path);
|
return fs.createReadStream(file.path);
|
||||||
} else {
|
} else {
|
||||||
reply.header('Content-Type', FILE_TYPE_BROWSERSAFE.includes(file.file.type) ? file.file.type : 'application/octet-stream');
|
reply.header('Content-Type', FILE_TYPE_BROWSERSAFE.includes(file.file.type) ? file.file.type : 'application/octet-stream');
|
||||||
|
reply.header('Content-Length', file.file.size);
|
||||||
reply.header('Cache-Control', 'max-age=31536000, immutable');
|
reply.header('Cache-Control', 'max-age=31536000, immutable');
|
||||||
reply.header('Content-Disposition', contentDisposition('inline', file.filename));
|
reply.header('Content-Disposition', contentDisposition('inline', file.filename));
|
||||||
|
|
||||||
|
@ -263,7 +267,6 @@ export class FileServerService {
|
||||||
const parts = range.replace(/bytes=/, '').split('-');
|
const parts = range.replace(/bytes=/, '').split('-');
|
||||||
const start = parseInt(parts[0], 10);
|
const start = parseInt(parts[0], 10);
|
||||||
let end = parts[1] ? parseInt(parts[1], 10) : file.file.size - 1;
|
let end = parts[1] ? parseInt(parts[1], 10) : file.file.size - 1;
|
||||||
console.log(end);
|
|
||||||
if (end > file.file.size) {
|
if (end > file.file.size) {
|
||||||
end = file.file.size - 1;
|
end = file.file.size - 1;
|
||||||
}
|
}
|
||||||
|
@ -433,6 +436,7 @@ export class FileServerService {
|
||||||
reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
|
reply.header('Content-Range', `bytes ${start}-${end}/${file.file.size}`);
|
||||||
reply.header('Accept-Ranges', 'bytes');
|
reply.header('Accept-Ranges', 'bytes');
|
||||||
reply.header('Content-Length', chunksize);
|
reply.header('Content-Length', chunksize);
|
||||||
|
reply.code(206);
|
||||||
} else {
|
} else {
|
||||||
image = {
|
image = {
|
||||||
data: fs.createReadStream(file.path),
|
data: fs.createReadStream(file.path),
|
||||||
|
@ -529,6 +533,7 @@ export class FileServerService {
|
||||||
if (!file.storedInternal) {
|
if (!file.storedInternal) {
|
||||||
if (!(file.isLink && file.uri)) return '204';
|
if (!(file.isLink && file.uri)) return '204';
|
||||||
const result = await this.downloadAndDetectTypeFromUrl(file.uri);
|
const result = await this.downloadAndDetectTypeFromUrl(file.uri);
|
||||||
|
file.size = (await fs.promises.stat(result.path)).size; // DB file.sizeは正確とは限らないので
|
||||||
return {
|
return {
|
||||||
...result,
|
...result,
|
||||||
url: file.uri,
|
url: file.uri,
|
||||||
|
|
|
@ -135,12 +135,20 @@ export class ServerService implements OnApplicationShutdown {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const name = path.split('@')[0].replace(/\.webp$/i, '');
|
const emojiPath = path.replace(/\.webp$/i, '');
|
||||||
const host = path.split('@')[1]?.replace(/\.webp$/i, '');
|
const pathChunks = emojiPath.split('@');
|
||||||
|
|
||||||
|
if (pathChunks.length > 2) {
|
||||||
|
reply.code(400);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = pathChunks.shift();
|
||||||
|
const host = pathChunks.pop();
|
||||||
|
|
||||||
const emoji = await this.emojisRepository.findOneBy({
|
const emoji = await this.emojisRepository.findOneBy({
|
||||||
// `@.` is the spec of ReactionService.decodeReaction
|
// `@.` is the spec of ReactionService.decodeReaction
|
||||||
host: (host == null || host === '.') ? IsNull() : host,
|
host: (host === undefined || host === '.') ? IsNull() : host,
|
||||||
name: name,
|
name: name,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
|
|
||||||
const checkMoving = await this.accountMoveService.validateAlsoKnownAs(
|
const checkMoving = await this.accountMoveService.validateAlsoKnownAs(
|
||||||
me,
|
me,
|
||||||
(old, src) => !!src.movedAt && src.movedAt.getTime() + 1000 * 60 * 60 * 2 > (new Date()).getTime(),
|
(old, src) => !!src.movedAt && src.movedAt.getTime() + 1000 * 60 * 60 * 2 > Date.now(),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
if (checkMoving ? file.size > 32 * 1024 * 1024 : file.size > 64 * 1024) throw new ApiError(meta.errors.tooBigFile);
|
if (checkMoving ? file.size > 32 * 1024 * 1024 : file.size > 64 * 1024) throw new ApiError(meta.errors.tooBigFile);
|
||||||
|
|
|
@ -75,7 +75,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
|
|
||||||
const checkMoving = await this.accountMoveService.validateAlsoKnownAs(
|
const checkMoving = await this.accountMoveService.validateAlsoKnownAs(
|
||||||
me,
|
me,
|
||||||
(old, src) => !!src.movedAt && src.movedAt.getTime() + 1000 * 60 * 60 * 2 > (new Date()).getTime(),
|
(old, src) => !!src.movedAt && src.movedAt.getTime() + 1000 * 60 * 60 * 2 > Date.now(),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
if (checkMoving ? file.size > 32 * 1024 * 1024 : file.size > 64 * 1024) throw new ApiError(meta.errors.tooBigFile);
|
if (checkMoving ? file.size > 32 * 1024 * 1024 : file.size > 64 * 1024) throw new ApiError(meta.errors.tooBigFile);
|
||||||
|
|
|
@ -77,7 +77,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
|
|
||||||
const checkMoving = await this.accountMoveService.validateAlsoKnownAs(
|
const checkMoving = await this.accountMoveService.validateAlsoKnownAs(
|
||||||
me,
|
me,
|
||||||
(old, src) => !!src.movedAt && src.movedAt.getTime() + 1000 * 60 * 60 * 2 > (new Date()).getTime(),
|
(old, src) => !!src.movedAt && src.movedAt.getTime() + 1000 * 60 * 60 * 2 > Date.now(),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
if (checkMoving ? file.size > 32 * 1024 * 1024 : file.size > 64 * 1024) throw new ApiError(meta.errors.tooBigFile);
|
if (checkMoving ? file.size > 32 * 1024 * 1024 : file.size > 64 * 1024) throw new ApiError(meta.errors.tooBigFile);
|
||||||
|
|
|
@ -77,7 +77,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
|
|
||||||
const checkMoving = await this.accountMoveService.validateAlsoKnownAs(
|
const checkMoving = await this.accountMoveService.validateAlsoKnownAs(
|
||||||
me,
|
me,
|
||||||
(old, src) => !!src.movedAt && src.movedAt.getTime() + 1000 * 60 * 60 * 2 > (new Date()).getTime(),
|
(old, src) => !!src.movedAt && src.movedAt.getTime() + 1000 * 60 * 60 * 2 > Date.now(),
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
if (checkMoving ? file.size > 32 * 1024 * 1024 : file.size > 64 * 1024) throw new ApiError(meta.errors.tooBigFile);
|
if (checkMoving ? file.size > 32 * 1024 * 1024 : file.size > 64 * 1024) throw new ApiError(meta.errors.tooBigFile);
|
||||||
|
|
|
@ -18,7 +18,7 @@ import { Endpoint } from '@/server/api/endpoint-base.js';
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
import { NoteCreateService } from '@/core/NoteCreateService.js';
|
import { NoteCreateService } from '@/core/NoteCreateService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { isPureRenote } from '@/misc/is-pure-renote.js';
|
import { isQuote, isRenote } from '@/misc/is-renote.js';
|
||||||
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
||||||
import { LoggerService } from '@/core/LoggerService.js';
|
import { LoggerService } from '@/core/LoggerService.js';
|
||||||
import { ApiError } from '../../error.js';
|
import { ApiError } from '../../error.js';
|
||||||
|
@ -314,7 +314,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
if (renote == null) {
|
if (renote == null) {
|
||||||
logger.error('No such renote target.', { renoteId: ps.renoteId });
|
logger.error('No such renote target.', { renoteId: ps.renoteId });
|
||||||
throw new ApiError(meta.errors.noSuchRenoteTarget);
|
throw new ApiError(meta.errors.noSuchRenoteTarget);
|
||||||
} else if (isPureRenote(renote)) {
|
} else if (isRenote(renote) && !isQuote(renote)) {
|
||||||
logger.error('Cannot Renote a pure Renote.', { renoteId: ps.renoteId });
|
logger.error('Cannot Renote a pure Renote.', { renoteId: ps.renoteId });
|
||||||
throw new ApiError(meta.errors.cannotReRenote);
|
throw new ApiError(meta.errors.cannotReRenote);
|
||||||
}
|
}
|
||||||
|
@ -367,7 +367,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
if (reply == null) {
|
if (reply == null) {
|
||||||
logger.error('No such reply target.', { replyId: ps.replyId });
|
logger.error('No such reply target.', { replyId: ps.replyId });
|
||||||
throw new ApiError(meta.errors.noSuchReplyTarget);
|
throw new ApiError(meta.errors.noSuchReplyTarget);
|
||||||
} else if (isPureRenote(reply)) {
|
} else if (isRenote(reply) && !isQuote(reply)) {
|
||||||
logger.error('Cannot reply to a pure Renote.', { replyId: ps.replyId });
|
logger.error('Cannot reply to a pure Renote.', { replyId: ps.replyId });
|
||||||
throw new ApiError(meta.errors.cannotReplyToPureRenote);
|
throw new ApiError(meta.errors.cannotReplyToPureRenote);
|
||||||
} else if (!await this.noteEntityService.isVisibleForMe(reply, me.id)) {
|
} else if (!await this.noteEntityService.isVisibleForMe(reply, me.id)) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ export const meta = {
|
||||||
|
|
||||||
res: {
|
res: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
optional: false, nullable: false,
|
optional: true, nullable: false,
|
||||||
properties: {
|
properties: {
|
||||||
sourceLang: { type: 'string' },
|
sourceLang: { type: 'string' },
|
||||||
text: { type: 'string' },
|
text: { type: 'string' },
|
||||||
|
@ -39,6 +39,11 @@ export const meta = {
|
||||||
code: 'NO_SUCH_NOTE',
|
code: 'NO_SUCH_NOTE',
|
||||||
id: 'bea9b03f-36e0-49c5-a4db-627a029f8971',
|
id: 'bea9b03f-36e0-49c5-a4db-627a029f8971',
|
||||||
},
|
},
|
||||||
|
cannotTranslateInvisibleNote: {
|
||||||
|
message: 'Cannot translate invisible note.',
|
||||||
|
code: 'CANNOT_TRANSLATE_INVISIBLE_NOTE',
|
||||||
|
id: 'ea29f2ca-c368-43b3-aaf1-5ac3e74bbe5d',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
|
@ -72,17 +77,17 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!(await this.noteEntityService.isVisibleForMe(note, me.id))) {
|
if (!(await this.noteEntityService.isVisibleForMe(note, me.id))) {
|
||||||
return 204; // TODO: 良い感じのエラー返す
|
throw new ApiError(meta.errors.cannotTranslateInvisibleNote);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (note.text == null) {
|
if (note.text == null) {
|
||||||
return 204;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const instance = await this.metaService.fetch();
|
const instance = await this.metaService.fetch();
|
||||||
|
|
||||||
if (instance.deeplAuthKey == null) {
|
if (instance.deeplAuthKey == null) {
|
||||||
return 204; // TODO: 良い感じのエラー返す
|
throw new ApiError(meta.errors.unavailable);
|
||||||
}
|
}
|
||||||
|
|
||||||
let targetLang = ps.targetLang;
|
let targetLang = ps.targetLang;
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
|
||||||
|
import { isUserRelated } from '@/misc/is-user-related.js';
|
||||||
|
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
||||||
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
import type Connection from './Connection.js';
|
import type Connection from './Connection.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -54,6 +58,24 @@ export default abstract class Channel {
|
||||||
return this.connection.subscriber;
|
return this.connection.subscriber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ミュートとブロックされてるを処理する
|
||||||
|
*/
|
||||||
|
protected isNoteMutedOrBlocked(note: Packed<'Note'>): boolean {
|
||||||
|
// 流れてきたNoteがインスタンスミュートしたインスタンスが関わる
|
||||||
|
if (isInstanceMuted(note, new Set<string>(this.userProfile?.mutedInstances ?? []))) return true;
|
||||||
|
|
||||||
|
// 流れてきたNoteがミュートしているユーザーが関わる
|
||||||
|
if (isUserRelated(note, this.userIdsWhoMeMuting)) return true;
|
||||||
|
// 流れてきたNoteがブロックされているユーザーが関わる
|
||||||
|
if (isUserRelated(note, this.userIdsWhoBlockingMe)) return true;
|
||||||
|
|
||||||
|
// 流れてきたNoteがリノートをミュートしてるユーザが行ったもの
|
||||||
|
if (isRenotePacked(note) && !isQuotePacked(note) && this.userIdsWhoMeMutingRenotes.has(note.user.id)) return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
constructor(id: string, connection: Connection) {
|
constructor(id: string, connection: Connection) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.connection = connection;
|
this.connection = connection;
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { isUserRelated } from '@/misc/is-user-related.js';
|
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import type { GlobalEvents } from '@/core/GlobalEventService.js';
|
import type { GlobalEvents } from '@/core/GlobalEventService.js';
|
||||||
|
@ -48,12 +47,7 @@ class AntennaChannel extends Channel {
|
||||||
if (reply.visibility === 'specified' && !reply.visibleUserIds!.includes(this.user!.id)) return;
|
if (reply.visibility === 'specified' && !reply.visibleUserIds!.includes(this.user!.id)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する
|
if (this.isNoteMutedOrBlocked(note)) return;
|
||||||
if (isUserRelated(note, this.userIdsWhoMeMuting)) return;
|
|
||||||
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
|
|
||||||
if (isUserRelated(note, this.userIdsWhoBlockingMe)) return;
|
|
||||||
|
|
||||||
if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return;
|
|
||||||
|
|
||||||
this.connection.cacheNote(note);
|
this.connection.cacheNote(note);
|
||||||
|
|
||||||
|
|
|
@ -4,10 +4,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { isUserRelated } from '@/misc/is-user-related.js';
|
|
||||||
import type { Packed } from '@/misc/json-schema.js';
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
||||||
import Channel, { type MiChannelService } from '../channel.js';
|
import Channel, { type MiChannelService } from '../channel.js';
|
||||||
|
|
||||||
class ChannelChannel extends Channel {
|
class ChannelChannel extends Channel {
|
||||||
|
@ -46,14 +46,9 @@ class ChannelChannel extends Channel {
|
||||||
if (reply.visibility === 'specified' && !reply.visibleUserIds!.includes(this.user!.id)) return;
|
if (reply.visibility === 'specified' && !reply.visibleUserIds!.includes(this.user!.id)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する
|
if (this.isNoteMutedOrBlocked(note)) return;
|
||||||
if (isUserRelated(note, this.userIdsWhoMeMuting)) return;
|
|
||||||
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
|
|
||||||
if (isUserRelated(note, this.userIdsWhoBlockingMe)) return;
|
|
||||||
|
|
||||||
if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return;
|
if (this.user && isRenotePacked(note) && !isQuotePacked(note)) {
|
||||||
|
|
||||||
if (this.user && note.renoteId && !note.text) {
|
|
||||||
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
||||||
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
||||||
note.renote.myReaction = myRenoteReaction;
|
note.renote.myReaction = myRenoteReaction;
|
||||||
|
|
|
@ -4,14 +4,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { checkWordMute } from '@/misc/check-word-mute.js';
|
|
||||||
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
|
|
||||||
import { isUserRelated } from '@/misc/is-user-related.js';
|
|
||||||
import type { Packed } from '@/misc/json-schema.js';
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
import { MetaService } from '@/core/MetaService.js';
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { RoleService } from '@/core/RoleService.js';
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
|
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
||||||
import Channel, { type MiChannelService } from '../channel.js';
|
import Channel, { type MiChannelService } from '../channel.js';
|
||||||
|
|
||||||
class GlobalTimelineChannel extends Channel {
|
class GlobalTimelineChannel extends Channel {
|
||||||
|
@ -47,12 +45,11 @@ class GlobalTimelineChannel extends Channel {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
private async onNote(note: Packed<'Note'>) {
|
private async onNote(note: Packed<'Note'>) {
|
||||||
if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return;
|
|
||||||
|
|
||||||
if (note.visibility !== 'public') return;
|
if (note.visibility !== 'public') return;
|
||||||
if (note.channelId != null) return;
|
if (note.channelId != null) return;
|
||||||
|
|
||||||
// ファイルを含まない投稿は除外
|
// ファイルを含まない投稿は除外
|
||||||
|
if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return;
|
||||||
if (this.withFiles && (note.files === undefined || note.files.length === 0)) return;
|
if (this.withFiles && (note.files === undefined || note.files.length === 0)) return;
|
||||||
|
|
||||||
// 関係ない返信は除外
|
// 関係ない返信は除外
|
||||||
|
@ -69,19 +66,19 @@ class GlobalTimelineChannel extends Channel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (note.renote && note.text == null && (note.fileIds == null || note.fileIds.length === 0) && !this.withRenotes) return;
|
// 純粋なリノート(引用リノートでないリノート)の場合
|
||||||
|
if (isRenotePacked(note) && !isQuotePacked(note) && note.renote) {
|
||||||
|
if (!this.withRenotes) return;
|
||||||
|
if (note.renote.reply) {
|
||||||
|
const reply = note.renote.reply;
|
||||||
|
// 自分のフォローしていないユーザーの visibility: followers な投稿への返信のリノートは弾く
|
||||||
|
if (reply.visibility === 'followers' && !Object.hasOwn(this.following, reply.userId)) return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Ignore notes from instances the user has muted
|
if (this.isNoteMutedOrBlocked(note)) return;
|
||||||
if (isInstanceMuted(note, new Set<string>(this.userProfile?.mutedInstances ?? []))) return;
|
|
||||||
|
|
||||||
// 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する
|
if (this.user && isRenotePacked(note) && !isQuotePacked(note)) {
|
||||||
if (isUserRelated(note, this.userIdsWhoMeMuting)) return;
|
|
||||||
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
|
|
||||||
if (isUserRelated(note, this.userIdsWhoBlockingMe)) return;
|
|
||||||
|
|
||||||
if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return;
|
|
||||||
|
|
||||||
if (this.user && note.renoteId && !note.text) {
|
|
||||||
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
||||||
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
||||||
note.renote.myReaction = myRenoteReaction;
|
note.renote.myReaction = myRenoteReaction;
|
||||||
|
|
|
@ -5,10 +5,10 @@
|
||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { normalizeForSearch } from '@/misc/normalize-for-search.js';
|
import { normalizeForSearch } from '@/misc/normalize-for-search.js';
|
||||||
import { isUserRelated } from '@/misc/is-user-related.js';
|
|
||||||
import type { Packed } from '@/misc/json-schema.js';
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
||||||
import Channel, { type MiChannelService } from '../channel.js';
|
import Channel, { type MiChannelService } from '../channel.js';
|
||||||
|
|
||||||
class HashtagChannel extends Channel {
|
class HashtagChannel extends Channel {
|
||||||
|
@ -51,14 +51,9 @@ class HashtagChannel extends Channel {
|
||||||
if (reply.visibility === 'specified' && !reply.visibleUserIds!.includes(this.user!.id)) return;
|
if (reply.visibility === 'specified' && !reply.visibleUserIds!.includes(this.user!.id)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する
|
if (this.isNoteMutedOrBlocked(note)) return;
|
||||||
if (isUserRelated(note, this.userIdsWhoMeMuting)) return;
|
|
||||||
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
|
|
||||||
if (isUserRelated(note, this.userIdsWhoBlockingMe)) return;
|
|
||||||
|
|
||||||
if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return;
|
if (this.user && isRenotePacked(note) && !isQuotePacked(note)) {
|
||||||
|
|
||||||
if (this.user && note.renoteId && !note.text) {
|
|
||||||
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
||||||
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
||||||
note.renote.myReaction = myRenoteReaction;
|
note.renote.myReaction = myRenoteReaction;
|
||||||
|
|
|
@ -4,12 +4,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { checkWordMute } from '@/misc/check-word-mute.js';
|
|
||||||
import { isUserRelated } from '@/misc/is-user-related.js';
|
|
||||||
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
|
|
||||||
import type { Packed } from '@/misc/json-schema.js';
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
|
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
||||||
import Channel, { type MiChannelService } from '../channel.js';
|
import Channel, { type MiChannelService } from '../channel.js';
|
||||||
|
|
||||||
class HomeTimelineChannel extends Channel {
|
class HomeTimelineChannel extends Channel {
|
||||||
|
@ -42,8 +40,6 @@ class HomeTimelineChannel extends Channel {
|
||||||
private async onNote(note: Packed<'Note'>) {
|
private async onNote(note: Packed<'Note'>) {
|
||||||
const isMe = this.user!.id === note.userId;
|
const isMe = this.user!.id === note.userId;
|
||||||
|
|
||||||
if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return;
|
|
||||||
|
|
||||||
if (note.channelId) {
|
if (note.channelId) {
|
||||||
if (!this.followingChannels.has(note.channelId)) return;
|
if (!this.followingChannels.has(note.channelId)) return;
|
||||||
} else {
|
} else {
|
||||||
|
@ -51,10 +47,8 @@ class HomeTimelineChannel extends Channel {
|
||||||
if (!isMe && !Object.hasOwn(this.following, note.userId)) return;
|
if (!isMe && !Object.hasOwn(this.following, note.userId)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore notes from instances the user has muted
|
|
||||||
if (isInstanceMuted(note, new Set<string>(this.userProfile!.mutedInstances))) return;
|
|
||||||
|
|
||||||
// ファイルを含まない投稿は除外
|
// ファイルを含まない投稿は除外
|
||||||
|
if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return;
|
||||||
if (this.withFiles && (note.files === undefined || note.files.length === 0)) return;
|
if (this.withFiles && (note.files === undefined || note.files.length === 0)) return;
|
||||||
|
|
||||||
if (note.visibility === 'followers') {
|
if (note.visibility === 'followers') {
|
||||||
|
@ -77,7 +71,7 @@ class HomeTimelineChannel extends Channel {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 純粋なリノート(引用リノートでないリノート)の場合
|
// 純粋なリノート(引用リノートでないリノート)の場合
|
||||||
if (note.renote && note.text == null && (note.fileIds == null || note.fileIds.length === 0) && note.poll == null) {
|
if (isRenotePacked(note) && !isQuotePacked(note) && note.renote) {
|
||||||
if (!this.withRenotes) return;
|
if (!this.withRenotes) return;
|
||||||
if (note.renote.reply) {
|
if (note.renote.reply) {
|
||||||
const reply = note.renote.reply;
|
const reply = note.renote.reply;
|
||||||
|
@ -86,14 +80,9 @@ class HomeTimelineChannel extends Channel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する
|
if (this.isNoteMutedOrBlocked(note)) return;
|
||||||
if (isUserRelated(note, this.userIdsWhoMeMuting)) return;
|
|
||||||
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
|
|
||||||
if (isUserRelated(note, this.userIdsWhoBlockingMe)) return;
|
|
||||||
|
|
||||||
if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return;
|
if (this.user && isRenotePacked(note) && !isQuotePacked(note)) {
|
||||||
|
|
||||||
if (this.user && note.renoteId && !note.text) {
|
|
||||||
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
||||||
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
||||||
note.renote.myReaction = myRenoteReaction;
|
note.renote.myReaction = myRenoteReaction;
|
||||||
|
|
|
@ -4,14 +4,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { checkWordMute } from '@/misc/check-word-mute.js';
|
|
||||||
import { isUserRelated } from '@/misc/is-user-related.js';
|
|
||||||
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
|
|
||||||
import type { Packed } from '@/misc/json-schema.js';
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
import { MetaService } from '@/core/MetaService.js';
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { RoleService } from '@/core/RoleService.js';
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
|
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
||||||
import Channel, { type MiChannelService } from '../channel.js';
|
import Channel, { type MiChannelService } from '../channel.js';
|
||||||
|
|
||||||
class HybridTimelineChannel extends Channel {
|
class HybridTimelineChannel extends Channel {
|
||||||
|
@ -52,8 +50,6 @@ class HybridTimelineChannel extends Channel {
|
||||||
private async onNote(note: Packed<'Note'>) {
|
private async onNote(note: Packed<'Note'>) {
|
||||||
const isMe = this.user!.id === note.userId;
|
const isMe = this.user!.id === note.userId;
|
||||||
|
|
||||||
if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return;
|
|
||||||
|
|
||||||
// チャンネルの投稿ではなく、自分自身の投稿 または
|
// チャンネルの投稿ではなく、自分自身の投稿 または
|
||||||
// チャンネルの投稿ではなく、その投稿のユーザーをフォローしている または
|
// チャンネルの投稿ではなく、その投稿のユーザーをフォローしている または
|
||||||
// チャンネルの投稿ではなく、全体公開のローカルの投稿 または
|
// チャンネルの投稿ではなく、全体公開のローカルの投稿 または
|
||||||
|
@ -66,6 +62,7 @@ class HybridTimelineChannel extends Channel {
|
||||||
)) return;
|
)) return;
|
||||||
|
|
||||||
// ファイルを含まない投稿は除外
|
// ファイルを含まない投稿は除外
|
||||||
|
if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return;
|
||||||
if (this.withFiles && (note.files === undefined || note.files.length === 0)) return;
|
if (this.withFiles && (note.files === undefined || note.files.length === 0)) return;
|
||||||
|
|
||||||
if (note.visibility === 'followers') {
|
if (note.visibility === 'followers') {
|
||||||
|
@ -74,9 +71,6 @@ class HybridTimelineChannel extends Channel {
|
||||||
if (!isMe && !note.visibleUserIds!.includes(this.user!.id)) return;
|
if (!isMe && !note.visibleUserIds!.includes(this.user!.id)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore notes from instances the user has muted
|
|
||||||
if (isInstanceMuted(note, new Set<string>(this.userProfile!.mutedInstances))) return;
|
|
||||||
|
|
||||||
if (note.reply) {
|
if (note.reply) {
|
||||||
const reply = note.reply;
|
const reply = note.reply;
|
||||||
if ((this.following[note.userId]?.withReplies ?? false) || this.withReplies) {
|
if ((this.following[note.userId]?.withReplies ?? false) || this.withReplies) {
|
||||||
|
@ -90,14 +84,17 @@ class HybridTimelineChannel extends Channel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (note.renote && note.text == null && (note.fileIds == null || note.fileIds.length === 0) && !this.withRenotes) return;
|
// 純粋なリノート(引用リノートでないリノート)の場合
|
||||||
|
if (isRenotePacked(note) && !isQuotePacked(note) && note.renote) {
|
||||||
|
if (!this.withRenotes) return;
|
||||||
|
if (note.renote.reply) {
|
||||||
|
const reply = note.renote.reply;
|
||||||
|
// 自分のフォローしていないユーザーの visibility: followers な投稿への返信のリノートは弾く
|
||||||
|
if (reply.visibility === 'followers' && !Object.hasOwn(this.following, reply.userId)) return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する
|
if (this.isNoteMutedOrBlocked(note)) return;
|
||||||
if (isUserRelated(note, this.userIdsWhoMeMuting)) return;
|
|
||||||
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
|
|
||||||
if (isUserRelated(note, this.userIdsWhoBlockingMe)) return;
|
|
||||||
|
|
||||||
if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return;
|
|
||||||
|
|
||||||
if (this.user && note.renoteId && !note.text) {
|
if (this.user && note.renoteId && !note.text) {
|
||||||
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
||||||
|
|
|
@ -4,13 +4,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { checkWordMute } from '@/misc/check-word-mute.js';
|
|
||||||
import { isUserRelated } from '@/misc/is-user-related.js';
|
|
||||||
import type { Packed } from '@/misc/json-schema.js';
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
import { MetaService } from '@/core/MetaService.js';
|
import { MetaService } from '@/core/MetaService.js';
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { RoleService } from '@/core/RoleService.js';
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
|
import { isQuotePacked, isRenotePacked } from '@/misc/is-renote.js';
|
||||||
import Channel, { type MiChannelService } from '../channel.js';
|
import Channel, { type MiChannelService } from '../channel.js';
|
||||||
|
|
||||||
class LocalTimelineChannel extends Channel {
|
class LocalTimelineChannel extends Channel {
|
||||||
|
@ -48,13 +47,12 @@ class LocalTimelineChannel extends Channel {
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
private async onNote(note: Packed<'Note'>) {
|
private async onNote(note: Packed<'Note'>) {
|
||||||
if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return;
|
|
||||||
|
|
||||||
if (note.user.host !== null) return;
|
if (note.user.host !== null) return;
|
||||||
if (note.visibility !== 'public') return;
|
if (note.visibility !== 'public') return;
|
||||||
if (note.channelId != null) return;
|
if (note.channelId != null) return;
|
||||||
|
|
||||||
// ファイルを含まない投稿は除外
|
// ファイルを含まない投稿は除外
|
||||||
|
if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return;
|
||||||
if (this.withFiles && (note.files === undefined || note.files.length === 0)) return;
|
if (this.withFiles && (note.files === undefined || note.files.length === 0)) return;
|
||||||
|
|
||||||
// 関係ない返信は除外
|
// 関係ない返信は除外
|
||||||
|
@ -71,16 +69,19 @@ class LocalTimelineChannel extends Channel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (note.renote && note.text == null && (note.fileIds == null || note.fileIds.length === 0) && !this.withRenotes) return;
|
// 純粋なリノート(引用リノートでないリノート)の場合
|
||||||
|
if (isRenotePacked(note) && !isQuotePacked(note) && note.renote) {
|
||||||
|
if (!this.withRenotes) return;
|
||||||
|
if (note.renote.reply) {
|
||||||
|
const reply = note.renote.reply;
|
||||||
|
// 自分のフォローしていないユーザーの visibility: followers な投稿への返信のリノートは弾く
|
||||||
|
if (reply.visibility === 'followers' && !Object.hasOwn(this.following, reply.userId)) return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する
|
if (this.isNoteMutedOrBlocked(note)) return;
|
||||||
if (isUserRelated(note, this.userIdsWhoMeMuting)) return;
|
|
||||||
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
|
|
||||||
if (isUserRelated(note, this.userIdsWhoBlockingMe)) return;
|
|
||||||
|
|
||||||
if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return;
|
if (this.user && isRenotePacked(note) && !isQuotePacked(note)) {
|
||||||
|
|
||||||
if (this.user && note.renoteId && !note.text) {
|
|
||||||
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
||||||
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
||||||
note.renote.myReaction = myRenoteReaction;
|
note.renote.myReaction = myRenoteReaction;
|
||||||
|
|
|
@ -4,12 +4,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { isUserRelated } from '@/misc/is-user-related.js';
|
|
||||||
import type { Packed } from '@/misc/json-schema.js';
|
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { RoleService } from '@/core/RoleService.js';
|
import { RoleService } from '@/core/RoleService.js';
|
||||||
import type { GlobalEvents } from '@/core/GlobalEventService.js';
|
import type { GlobalEvents } from '@/core/GlobalEventService.js';
|
||||||
|
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
||||||
import Channel, { type MiChannelService } from '../channel.js';
|
import Channel, { type MiChannelService } from '../channel.js';
|
||||||
|
|
||||||
class RoleTimelineChannel extends Channel {
|
class RoleTimelineChannel extends Channel {
|
||||||
|
@ -54,14 +53,18 @@ class RoleTimelineChannel extends Channel {
|
||||||
if (reply.visibility === 'specified' && !reply.visibleUserIds!.includes(this.user!.id)) return;
|
if (reply.visibility === 'specified' && !reply.visibleUserIds!.includes(this.user!.id)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する
|
// 純粋なリノート(引用リノートでないリノート)の場合
|
||||||
if (isUserRelated(note, this.userIdsWhoMeMuting)) return;
|
if (isRenotePacked(note) && !isQuotePacked(note) && note.renote) {
|
||||||
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
|
if (note.renote.reply) {
|
||||||
if (isUserRelated(note, this.userIdsWhoBlockingMe)) return;
|
const reply = note.renote.reply;
|
||||||
|
// 自分のフォローしていないユーザーの visibility: followers な投稿への返信のリノートは弾く
|
||||||
|
if (reply.visibility === 'followers' && !Object.hasOwn(this.following, reply.userId)) return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return;
|
if (this.isNoteMutedOrBlocked(note)) return;
|
||||||
|
|
||||||
if (this.user && note.renoteId && !note.text) {
|
if (this.user && isRenotePacked(note) && !isQuotePacked(note)) {
|
||||||
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
||||||
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
||||||
note.renote.myReaction = myRenoteReaction;
|
note.renote.myReaction = myRenoteReaction;
|
||||||
|
|
|
@ -5,12 +5,11 @@
|
||||||
|
|
||||||
import { Inject, Injectable } from '@nestjs/common';
|
import { Inject, Injectable } from '@nestjs/common';
|
||||||
import type { MiUserListMembership, UserListMembershipsRepository, UserListsRepository } from '@/models/_.js';
|
import type { MiUserListMembership, UserListMembershipsRepository, UserListsRepository } from '@/models/_.js';
|
||||||
import { isUserRelated } from '@/misc/is-user-related.js';
|
|
||||||
import type { Packed } from '@/misc/json-schema.js';
|
import type { Packed } from '@/misc/json-schema.js';
|
||||||
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
import { NoteEntityService } from '@/core/entities/NoteEntityService.js';
|
||||||
import { DI } from '@/di-symbols.js';
|
import { DI } from '@/di-symbols.js';
|
||||||
import { bindThis } from '@/decorators.js';
|
import { bindThis } from '@/decorators.js';
|
||||||
import { isInstanceMuted } from '@/misc/is-instance-muted.js';
|
import { isRenotePacked, isQuotePacked } from '@/misc/is-renote.js';
|
||||||
import Channel, { type MiChannelService } from '../channel.js';
|
import Channel, { type MiChannelService } from '../channel.js';
|
||||||
|
|
||||||
class UserListChannel extends Channel {
|
class UserListChannel extends Channel {
|
||||||
|
@ -85,7 +84,9 @@ class UserListChannel extends Channel {
|
||||||
// チャンネル投稿は無視する
|
// チャンネル投稿は無視する
|
||||||
if (note.channelId) return;
|
if (note.channelId) return;
|
||||||
|
|
||||||
|
// ファイルを含まない投稿は除外
|
||||||
if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return;
|
if (this.withFiles && (note.fileIds == null || note.fileIds.length === 0)) return;
|
||||||
|
if (this.withFiles && (note.files === undefined || note.files.length === 0)) return;
|
||||||
|
|
||||||
if (!Object.hasOwn(this.membershipsMap, note.userId)) return;
|
if (!Object.hasOwn(this.membershipsMap, note.userId)) return;
|
||||||
|
|
||||||
|
@ -108,25 +109,25 @@ class UserListChannel extends Channel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (note.renote && note.text == null && (note.fileIds == null || note.fileIds.length === 0) && !this.withRenotes) return;
|
// 純粋なリノート(引用リノートでないリノート)の場合
|
||||||
|
if (isRenotePacked(note) && !isQuotePacked(note) && note.renote) {
|
||||||
|
if (!this.withRenotes) return;
|
||||||
|
if (note.renote.reply) {
|
||||||
|
const reply = note.renote.reply;
|
||||||
|
// 自分のフォローしていないユーザーの visibility: followers な投稿への返信のリノートは弾く
|
||||||
|
if (reply.visibility === 'followers' && !Object.hasOwn(this.following, reply.userId)) return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 流れてきたNoteがミュートしているユーザーが関わるものだったら無視する
|
if (this.isNoteMutedOrBlocked(note)) return;
|
||||||
if (isUserRelated(note, this.userIdsWhoMeMuting)) return;
|
|
||||||
// 流れてきたNoteがブロックされているユーザーが関わるものだったら無視する
|
|
||||||
if (isUserRelated(note, this.userIdsWhoBlockingMe)) return;
|
|
||||||
|
|
||||||
if (note.renote && !note.text && isUserRelated(note, this.userIdsWhoMeMutingRenotes)) return;
|
if (this.user && isRenotePacked(note) && !isQuotePacked(note)) {
|
||||||
|
|
||||||
if (this.user && note.renoteId && !note.text) {
|
|
||||||
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
if (note.renote && Object.keys(note.renote.reactions).length > 0) {
|
||||||
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
const myRenoteReaction = await this.noteEntityService.populateMyReaction(note.renote, this.user.id);
|
||||||
note.renote.myReaction = myRenoteReaction;
|
note.renote.myReaction = myRenoteReaction;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 流れてきたNoteがミュートしているインスタンスに関わるものだったら無視する
|
|
||||||
if (isInstanceMuted(note, this.userMutedInstances)) return;
|
|
||||||
|
|
||||||
this.connection.cacheNote(note);
|
this.connection.cacheNote(note);
|
||||||
|
|
||||||
this.send('note', note);
|
this.send('note', note);
|
||||||
|
|
|
@ -202,6 +202,10 @@ export class ClientServerService {
|
||||||
// %71ueueとかでリクエストされたら困るため
|
// %71ueueとかでリクエストされたら困るため
|
||||||
const url = decodeURI(request.routeOptions.url ?? '');
|
const url = decodeURI(request.routeOptions.url ?? '');
|
||||||
if (url === bullBoardPath || url.startsWith(bullBoardPath + '/')) {
|
if (url === bullBoardPath || url.startsWith(bullBoardPath + '/')) {
|
||||||
|
if (!url.startsWith(bullBoardPath + '/static/')) {
|
||||||
|
reply.header('Cache-Control', 'private, max-age=0, must-revalidate');
|
||||||
|
}
|
||||||
|
|
||||||
const token = request.cookies.token;
|
const token = request.cookies.token;
|
||||||
if (token == null) {
|
if (token == null) {
|
||||||
reply.code(401).send('Login required');
|
reply.code(401).send('Login required');
|
||||||
|
|
|
@ -3,7 +3,7 @@ extends ./base
|
||||||
block vars
|
block vars
|
||||||
- const user = page.user;
|
- const user = page.user;
|
||||||
- const title = page.title;
|
- const title = page.title;
|
||||||
- const url = `${config.url}/@${user.username}/${page.name}`;
|
- const url = `${config.url}/@${user.username}/pages/${page.name}`;
|
||||||
|
|
||||||
block title
|
block title
|
||||||
= `${title} | ${instanceName}`
|
= `${title} | ${instanceName}`
|
||||||
|
|
|
@ -8,12 +8,13 @@ process.env.NODE_ENV = 'test';
|
||||||
import * as assert from 'assert';
|
import * as assert from 'assert';
|
||||||
import { MiNote } from '@/models/Note.js';
|
import { MiNote } from '@/models/Note.js';
|
||||||
import { MAX_NOTE_TEXT_LENGTH } from '@/const.js';
|
import { MAX_NOTE_TEXT_LENGTH } from '@/const.js';
|
||||||
import { api, initTestDb, post, sendEnvUpdateRequest, signup, uploadFile, uploadUrl } from '../utils.js';
|
import { api, initTestDb, post, role, sendEnvUpdateRequest, signup, uploadFile, uploadUrl } from '../utils.js';
|
||||||
import type * as misskey from 'misskey-js';
|
import type * as misskey from 'misskey-js';
|
||||||
|
|
||||||
describe('Note', () => {
|
describe('Note', () => {
|
||||||
let Notes: any;
|
let Notes: any;
|
||||||
|
|
||||||
|
let root: misskey.entities.SignupResponse;
|
||||||
let alice: misskey.entities.SignupResponse;
|
let alice: misskey.entities.SignupResponse;
|
||||||
let bob: misskey.entities.SignupResponse;
|
let bob: misskey.entities.SignupResponse;
|
||||||
let tom: misskey.entities.SignupResponse;
|
let tom: misskey.entities.SignupResponse;
|
||||||
|
@ -23,6 +24,7 @@ describe('Note', () => {
|
||||||
|
|
||||||
const connection = await initTestDb(true);
|
const connection = await initTestDb(true);
|
||||||
Notes = connection.getRepository(MiNote);
|
Notes = connection.getRepository(MiNote);
|
||||||
|
root = await signup({ username: 'root' });
|
||||||
alice = await signup({ username: 'alice' });
|
alice = await signup({ username: 'alice' });
|
||||||
bob = await signup({ username: 'bob' });
|
bob = await signup({ username: 'bob' });
|
||||||
tom = await signup({ username: 'tom', host: 'example.com' });
|
tom = await signup({ username: 'tom', host: 'example.com' });
|
||||||
|
@ -476,14 +478,14 @@ describe('Note', () => {
|
||||||
value: true,
|
value: true,
|
||||||
},
|
},
|
||||||
} as FIXME,
|
} as FIXME,
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(res.status, 200);
|
assert.strictEqual(res.status, 200);
|
||||||
|
|
||||||
const assign = await api('admin/roles/assign', {
|
const assign = await api('admin/roles/assign', {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(assign.status, 204);
|
assert.strictEqual(assign.status, 204);
|
||||||
assert.strictEqual(file.body!.isSensitive, false);
|
assert.strictEqual(file.body!.isSensitive, false);
|
||||||
|
@ -511,11 +513,11 @@ describe('Note', () => {
|
||||||
await api('admin/roles/unassign', {
|
await api('admin/roles/unassign', {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
});
|
}, root);
|
||||||
|
|
||||||
await api('admin/roles/delete', {
|
await api('admin/roles/delete', {
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
}, alice);
|
}, root);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -647,7 +649,7 @@ describe('Note', () => {
|
||||||
sensitiveWords: [
|
sensitiveWords: [
|
||||||
'test',
|
'test',
|
||||||
],
|
],
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(sensitive.status, 204);
|
assert.strictEqual(sensitive.status, 204);
|
||||||
|
|
||||||
|
@ -666,7 +668,7 @@ describe('Note', () => {
|
||||||
sensitiveWords: [
|
sensitiveWords: [
|
||||||
'/Test/i',
|
'/Test/i',
|
||||||
],
|
],
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(sensitive.status, 204);
|
assert.strictEqual(sensitive.status, 204);
|
||||||
|
|
||||||
|
@ -683,7 +685,7 @@ describe('Note', () => {
|
||||||
sensitiveWords: [
|
sensitiveWords: [
|
||||||
'Test hoge',
|
'Test hoge',
|
||||||
],
|
],
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(sensitive.status, 204);
|
assert.strictEqual(sensitive.status, 204);
|
||||||
|
|
||||||
|
@ -700,7 +702,7 @@ describe('Note', () => {
|
||||||
prohibitedWords: [
|
prohibitedWords: [
|
||||||
'test',
|
'test',
|
||||||
],
|
],
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(prohibited.status, 204);
|
assert.strictEqual(prohibited.status, 204);
|
||||||
|
|
||||||
|
@ -719,7 +721,7 @@ describe('Note', () => {
|
||||||
prohibitedWords: [
|
prohibitedWords: [
|
||||||
'/Test/i',
|
'/Test/i',
|
||||||
],
|
],
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(prohibited.status, 204);
|
assert.strictEqual(prohibited.status, 204);
|
||||||
|
|
||||||
|
@ -736,7 +738,7 @@ describe('Note', () => {
|
||||||
prohibitedWords: [
|
prohibitedWords: [
|
||||||
'Test hoge',
|
'Test hoge',
|
||||||
],
|
],
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(prohibited.status, 204);
|
assert.strictEqual(prohibited.status, 204);
|
||||||
|
|
||||||
|
@ -753,7 +755,7 @@ describe('Note', () => {
|
||||||
prohibitedWords: [
|
prohibitedWords: [
|
||||||
'test',
|
'test',
|
||||||
],
|
],
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(prohibited.status, 204);
|
assert.strictEqual(prohibited.status, 204);
|
||||||
|
|
||||||
|
@ -790,7 +792,7 @@ describe('Note', () => {
|
||||||
value: 0,
|
value: 0,
|
||||||
},
|
},
|
||||||
} as FIXME,
|
} as FIXME,
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(res.status, 200);
|
assert.strictEqual(res.status, 200);
|
||||||
|
|
||||||
|
@ -799,7 +801,7 @@ describe('Note', () => {
|
||||||
const assign = await api('admin/roles/assign', {
|
const assign = await api('admin/roles/assign', {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(assign.status, 204);
|
assert.strictEqual(assign.status, 204);
|
||||||
|
|
||||||
|
@ -815,11 +817,11 @@ describe('Note', () => {
|
||||||
await api('admin/roles/unassign', {
|
await api('admin/roles/unassign', {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
});
|
}, root);
|
||||||
|
|
||||||
await api('admin/roles/delete', {
|
await api('admin/roles/delete', {
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
}, alice);
|
}, root);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('ダイレクト投稿もエラーになる', async () => {
|
test('ダイレクト投稿もエラーになる', async () => {
|
||||||
|
@ -845,7 +847,7 @@ describe('Note', () => {
|
||||||
value: 0,
|
value: 0,
|
||||||
},
|
},
|
||||||
} as FIXME,
|
} as FIXME,
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(res.status, 200);
|
assert.strictEqual(res.status, 200);
|
||||||
|
|
||||||
|
@ -854,7 +856,7 @@ describe('Note', () => {
|
||||||
const assign = await api('admin/roles/assign', {
|
const assign = await api('admin/roles/assign', {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(assign.status, 204);
|
assert.strictEqual(assign.status, 204);
|
||||||
|
|
||||||
|
@ -872,11 +874,11 @@ describe('Note', () => {
|
||||||
await api('admin/roles/unassign', {
|
await api('admin/roles/unassign', {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
});
|
}, root);
|
||||||
|
|
||||||
await api('admin/roles/delete', {
|
await api('admin/roles/delete', {
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
}, alice);
|
}, root);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('ダイレクトの宛先とメンションが同じ場合は重複してカウントしない', async () => {
|
test('ダイレクトの宛先とメンションが同じ場合は重複してカウントしない', async () => {
|
||||||
|
@ -902,7 +904,7 @@ describe('Note', () => {
|
||||||
value: 1,
|
value: 1,
|
||||||
},
|
},
|
||||||
} as FIXME,
|
} as FIXME,
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(res.status, 200);
|
assert.strictEqual(res.status, 200);
|
||||||
|
|
||||||
|
@ -911,7 +913,7 @@ describe('Note', () => {
|
||||||
const assign = await api('admin/roles/assign', {
|
const assign = await api('admin/roles/assign', {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
}, alice);
|
}, root);
|
||||||
|
|
||||||
assert.strictEqual(assign.status, 204);
|
assert.strictEqual(assign.status, 204);
|
||||||
|
|
||||||
|
@ -928,11 +930,11 @@ describe('Note', () => {
|
||||||
await api('admin/roles/unassign', {
|
await api('admin/roles/unassign', {
|
||||||
userId: alice.id,
|
userId: alice.id,
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
});
|
}, root);
|
||||||
|
|
||||||
await api('admin/roles/delete', {
|
await api('admin/roles/delete', {
|
||||||
roleId: res.body.id,
|
roleId: res.body.id,
|
||||||
}, alice);
|
}, root);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -967,4 +969,61 @@ describe('Note', () => {
|
||||||
assert.strictEqual(mainNote.repliesCount, 0);
|
assert.strictEqual(mainNote.repliesCount, 0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('notes/translate', () => {
|
||||||
|
describe('翻訳機能の利用が許可されていない場合', () => {
|
||||||
|
let cannotTranslateRole: misskey.entities.Role;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
cannotTranslateRole = await role(root, {}, { canUseTranslator: false });
|
||||||
|
await api('admin/roles/assign', { roleId: cannotTranslateRole.id, userId: alice.id }, root);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('翻訳機能の利用が許可されていない場合翻訳できない', async () => {
|
||||||
|
const aliceNote = await post(alice, { text: 'Hello' });
|
||||||
|
const res = await api('notes/translate', {
|
||||||
|
noteId: aliceNote.id,
|
||||||
|
targetLang: 'ja',
|
||||||
|
}, alice);
|
||||||
|
|
||||||
|
assert.strictEqual(res.status, 400);
|
||||||
|
assert.strictEqual(res.body.error.code, 'UNAVAILABLE');
|
||||||
|
});
|
||||||
|
|
||||||
|
afterAll(async () => {
|
||||||
|
await api('admin/roles/unassign', { roleId: cannotTranslateRole.id, userId: alice.id }, root);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('存在しないノートは翻訳できない', async () => {
|
||||||
|
const res = await api('notes/translate', { noteId: 'foo', targetLang: 'ja' }, alice);
|
||||||
|
|
||||||
|
assert.strictEqual(res.status, 400);
|
||||||
|
assert.strictEqual(res.body.error.code, 'NO_SUCH_NOTE');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('不可視なノートは翻訳できない', async () => {
|
||||||
|
const aliceNote = await post(alice, { visibility: 'followers', text: 'Hello' });
|
||||||
|
const bobTranslateAttempt = await api('notes/translate', { noteId: aliceNote.id, targetLang: 'ja' }, bob);
|
||||||
|
|
||||||
|
assert.strictEqual(bobTranslateAttempt.status, 400);
|
||||||
|
assert.strictEqual(bobTranslateAttempt.body.error.code, 'CANNOT_TRANSLATE_INVISIBLE_NOTE');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('text: null なノートを翻訳すると空のレスポンスが返ってくる', async () => {
|
||||||
|
const aliceNote = await post(alice, { text: null, poll: { choices: ['kinoko', 'takenoko'] } });
|
||||||
|
const res = await api('notes/translate', { noteId: aliceNote.id, targetLang: 'ja' }, alice);
|
||||||
|
|
||||||
|
assert.strictEqual(res.status, 204);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('サーバーに DeepL 認証キーが登録されていない場合翻訳できない', async () => {
|
||||||
|
const aliceNote = await post(alice, { text: 'Hello' });
|
||||||
|
const res = await api('notes/translate', { noteId: aliceNote.id, targetLang: 'ja' }, alice);
|
||||||
|
|
||||||
|
// NOTE: デフォルトでは登録されていないので落ちる
|
||||||
|
assert.strictEqual(res.status, 400);
|
||||||
|
assert.strictEqual(res.body.error.code, 'UNAVAILABLE');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -65,6 +65,22 @@ describe('Renote Mute', () => {
|
||||||
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), true);
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// #12956
|
||||||
|
test('タイムラインにリノートミュートしているユーザーの通常ノートのリノートが含まれる', async () => {
|
||||||
|
const carolNote = await post(carol, { text: 'hi' });
|
||||||
|
const bobRenote = await post(bob, { renoteId: carolNote.id });
|
||||||
|
|
||||||
|
// redisに追加されるのを待つ
|
||||||
|
await sleep(100);
|
||||||
|
|
||||||
|
const res = await api('notes/local-timeline', {}, alice);
|
||||||
|
|
||||||
|
assert.strictEqual(res.status, 200);
|
||||||
|
assert.strictEqual(Array.isArray(res.body), true);
|
||||||
|
assert.strictEqual(res.body.some((note: any) => note.id === carolNote.id), true);
|
||||||
|
assert.strictEqual(res.body.some((note: any) => note.id === bobRenote.id), true);
|
||||||
|
});
|
||||||
|
|
||||||
test('ストリームにリノートミュートしているユーザーのリノートが流れない', async () => {
|
test('ストリームにリノートミュートしているユーザーのリノートが流れない', async () => {
|
||||||
const bobNote = await post(bob, { text: 'hi' });
|
const bobNote = await post(bob, { text: 'hi' });
|
||||||
|
|
||||||
|
@ -88,4 +104,17 @@ describe('Renote Mute', () => {
|
||||||
|
|
||||||
assert.strictEqual(fired, true);
|
assert.strictEqual(fired, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// #12956
|
||||||
|
test('ストリームにリノートミュートしているユーザーの通常ノートのリノートが流れてくる', async () => {
|
||||||
|
const carolbNote = await post(carol, { text: 'hi' });
|
||||||
|
|
||||||
|
const fired = await waitFire(
|
||||||
|
alice, 'localTimeline',
|
||||||
|
() => api('notes/create', { renoteId: carolbNote.id }, bob),
|
||||||
|
msg => msg.type === 'note' && msg.body.userId === bob.id,
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.strictEqual(fired, true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -65,7 +65,7 @@ describe('Streaming', () => {
|
||||||
takumiNote = await post(takumi, { text: 'piyo' });
|
takumiNote = await post(takumi, { text: 'piyo' });
|
||||||
|
|
||||||
// Follow: ayano => kyoko
|
// Follow: ayano => kyoko
|
||||||
await api('following/create', { userId: kyoko.id }, ayano);
|
await api('following/create', { userId: kyoko.id, withReplies: false }, ayano);
|
||||||
|
|
||||||
// Follow: ayano => akari
|
// Follow: ayano => akari
|
||||||
await follow(ayano, akari);
|
await follow(ayano, akari);
|
||||||
|
@ -511,6 +511,16 @@ describe('Streaming', () => {
|
||||||
|
|
||||||
assert.strictEqual(fired, false);
|
assert.strictEqual(fired, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('withReplies = falseでフォローしてる人によるリプライが流れてくる', async () => {
|
||||||
|
const fired = await waitFire(
|
||||||
|
ayano, 'globalTimeline', // ayano:Global
|
||||||
|
() => api('notes/create', { text: 'foo', replyId: kanakoNote.id }, kyoko), // kyoko posts
|
||||||
|
msg => msg.type === 'note' && msg.body.userId === kyoko.id, // wait kyoko
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.strictEqual(fired, true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('UserList Timeline', () => {
|
describe('UserList Timeline', () => {
|
||||||
|
|
BIN
packages/backend/test/resources/kick_gaba7.m4a
Normal file
BIN
packages/backend/test/resources/kick_gaba7.m4a
Normal file
Binary file not shown.
|
@ -16,6 +16,7 @@ import { LoggerService } from '@/core/LoggerService.js';
|
||||||
import { FileInfoService } from '@/core/FileInfoService.js';
|
import { FileInfoService } from '@/core/FileInfoService.js';
|
||||||
//import { DI } from '@/di-symbols.js';
|
//import { DI } from '@/di-symbols.js';
|
||||||
import { AiService } from '@/core/AiService.js';
|
import { AiService } from '@/core/AiService.js';
|
||||||
|
import { LoggerService } from '@/core/LoggerService.js';
|
||||||
import type { TestingModule } from '@nestjs/testing';
|
import type { TestingModule } from '@nestjs/testing';
|
||||||
import type { MockFunctionMetadata } from 'jest-mock';
|
import type { MockFunctionMetadata } from 'jest-mock';
|
||||||
|
|
||||||
|
@ -37,6 +38,7 @@ describe('FileInfoService', () => {
|
||||||
providers: [
|
providers: [
|
||||||
LoggerService,
|
LoggerService,
|
||||||
AiService,
|
AiService,
|
||||||
|
LoggerService,
|
||||||
FileInfoService,
|
FileInfoService,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
@ -325,8 +327,26 @@ describe('FileInfoService', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
test('MPEG-4 AUDIO (M4A)', async () => {
|
||||||
* video/webmとして検出されてしまう
|
const path = `${resources}/kick_gaba7.m4a`;
|
||||||
|
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as any;
|
||||||
|
delete info.warnings;
|
||||||
|
delete info.blurhash;
|
||||||
|
delete info.sensitive;
|
||||||
|
delete info.porn;
|
||||||
|
delete info.width;
|
||||||
|
delete info.height;
|
||||||
|
delete info.orientation;
|
||||||
|
assert.deepStrictEqual(info, {
|
||||||
|
size: 9817,
|
||||||
|
md5: '74c9279a4abe98789565f1dc1a541a42',
|
||||||
|
type: {
|
||||||
|
mime: 'audio/mp4',
|
||||||
|
ext: 'm4a',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
test('WEBM AUDIO', async () => {
|
test('WEBM AUDIO', async () => {
|
||||||
const path = `${resources}/kick_gaba7.webm`;
|
const path = `${resources}/kick_gaba7.webm`;
|
||||||
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as FIXME;
|
const info = await fileInfoService.getFileInfo(path, { skipSensitiveDetection: true }) as FIXME;
|
||||||
|
@ -339,13 +359,12 @@ describe('FileInfoService', () => {
|
||||||
delete info.orientation;
|
delete info.orientation;
|
||||||
assert.deepStrictEqual(info, {
|
assert.deepStrictEqual(info, {
|
||||||
size: 8879,
|
size: 8879,
|
||||||
md5: '3350083dec312419cfdc06c16413aca7',
|
md5: '53bc1adcb6acbbda67ff9bd484896438',
|
||||||
type: {
|
type: {
|
||||||
mime: 'audio/webm',
|
mime: 'audio/webm',
|
||||||
ext: 'webm',
|
ext: 'webm',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -39,6 +39,12 @@ describe('MfmService', () => {
|
||||||
const output = '<p>foo <i>bar</i></p>';
|
const output = '<p>foo <i>bar</i></p>';
|
||||||
assert.equal(mfmService.toHtml(mfm.parse(input)), output);
|
assert.equal(mfmService.toHtml(mfm.parse(input)), output);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('escape', () => {
|
||||||
|
const input = '```\n<p>Hello, world!</p>\n```';
|
||||||
|
const output = '<p><pre><code><p>Hello, world!</p></code></pre></p>';
|
||||||
|
assert.equal(mfmService.toHtml(mfm.parse(input)), output);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('fromHtml', () => {
|
describe('fromHtml', () => {
|
||||||
|
|
144
packages/backend/test/unit/NoteCreateService.ts
Normal file
144
packages/backend/test/unit/NoteCreateService.ts
Normal file
|
@ -0,0 +1,144 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Test } from '@nestjs/testing';
|
||||||
|
|
||||||
|
import { CoreModule } from '@/core/CoreModule.js';
|
||||||
|
import { NoteCreateService } from '@/core/NoteCreateService.js';
|
||||||
|
import { GlobalModule } from '@/GlobalModule.js';
|
||||||
|
import { MiNote } from '@/models/Note.js';
|
||||||
|
import { IPoll } from '@/models/Poll.js';
|
||||||
|
import { MiDriveFile } from '@/models/DriveFile.js';
|
||||||
|
|
||||||
|
describe('NoteCreateService', () => {
|
||||||
|
let noteCreateService: NoteCreateService;
|
||||||
|
|
||||||
|
beforeAll(async () => {
|
||||||
|
const app = await Test.createTestingModule({
|
||||||
|
imports: [GlobalModule, CoreModule],
|
||||||
|
}).compile();
|
||||||
|
noteCreateService = app.get<NoteCreateService>(NoteCreateService);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('is-renote', () => {
|
||||||
|
const base: MiNote = {
|
||||||
|
id: 'some-note-id',
|
||||||
|
replyId: null,
|
||||||
|
reply: null,
|
||||||
|
renoteId: null,
|
||||||
|
renote: null,
|
||||||
|
threadId: null,
|
||||||
|
text: null,
|
||||||
|
name: null,
|
||||||
|
cw: null,
|
||||||
|
userId: 'some-user-id',
|
||||||
|
user: null,
|
||||||
|
localOnly: false,
|
||||||
|
reactionAcceptance: null,
|
||||||
|
renoteCount: 0,
|
||||||
|
repliesCount: 0,
|
||||||
|
clippedCount: 0,
|
||||||
|
reactions: {},
|
||||||
|
visibility: 'public',
|
||||||
|
uri: null,
|
||||||
|
url: null,
|
||||||
|
fileIds: [],
|
||||||
|
attachedFileTypes: [],
|
||||||
|
visibleUserIds: [],
|
||||||
|
mentions: [],
|
||||||
|
mentionedRemoteUsers: '',
|
||||||
|
reactionAndUserPairCache: [],
|
||||||
|
emojis: [],
|
||||||
|
tags: [],
|
||||||
|
hasPoll: false,
|
||||||
|
channelId: null,
|
||||||
|
channel: null,
|
||||||
|
userHost: null,
|
||||||
|
replyUserId: null,
|
||||||
|
replyUserHost: null,
|
||||||
|
renoteUserId: null,
|
||||||
|
renoteUserHost: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
const poll: IPoll = {
|
||||||
|
choices: ['kinoko', 'takenoko'],
|
||||||
|
multiple: false,
|
||||||
|
expiresAt: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
const file: MiDriveFile = {
|
||||||
|
id: 'some-file-id',
|
||||||
|
userId: null,
|
||||||
|
user: null,
|
||||||
|
userHost: null,
|
||||||
|
md5: '',
|
||||||
|
name: '',
|
||||||
|
type: '',
|
||||||
|
size: 0,
|
||||||
|
comment: null,
|
||||||
|
blurhash: null,
|
||||||
|
properties: {},
|
||||||
|
storedInternal: false,
|
||||||
|
url: '',
|
||||||
|
thumbnailUrl: null,
|
||||||
|
webpublicUrl: null,
|
||||||
|
webpublicType: null,
|
||||||
|
accessKey: null,
|
||||||
|
thumbnailAccessKey: null,
|
||||||
|
webpublicAccessKey: null,
|
||||||
|
uri: null,
|
||||||
|
src: null,
|
||||||
|
folderId: null,
|
||||||
|
folder: null,
|
||||||
|
isSensitive: false,
|
||||||
|
maybeSensitive: false,
|
||||||
|
maybePorn: false,
|
||||||
|
isLink: false,
|
||||||
|
requestHeaders: null,
|
||||||
|
requestIp: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
test('note without renote should not be Renote', () => {
|
||||||
|
const note = { renote: null };
|
||||||
|
expect(noteCreateService['isRenote'](note)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('note with renote should be Renote and not be Quote', () => {
|
||||||
|
const note = { renote: base };
|
||||||
|
expect(noteCreateService['isRenote'](note)).toBe(true);
|
||||||
|
expect(noteCreateService['isQuote'](note)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('note with renote and text should be Quote', () => {
|
||||||
|
const note = { renote: base, text: 'some-text' };
|
||||||
|
expect(noteCreateService['isRenote'](note)).toBe(true);
|
||||||
|
expect(noteCreateService['isQuote'](note)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('note with renote and cw should be Quote', () => {
|
||||||
|
const note = { renote: base, cw: 'some-cw' };
|
||||||
|
expect(noteCreateService['isRenote'](note)).toBe(true);
|
||||||
|
expect(noteCreateService['isQuote'](note)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('note with renote and reply should be Quote', () => {
|
||||||
|
const note = { renote: base, reply: { ...base, id: 'another-note-id' } };
|
||||||
|
expect(noteCreateService['isRenote'](note)).toBe(true);
|
||||||
|
expect(noteCreateService['isQuote'](note)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('note with renote and poll should be Quote', () => {
|
||||||
|
const note = { renote: base, poll };
|
||||||
|
expect(noteCreateService['isRenote'](note)).toBe(true);
|
||||||
|
expect(noteCreateService['isQuote'](note)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('note with renote and non-empty files should be Quote', () => {
|
||||||
|
const note = { renote: base, files: [file] };
|
||||||
|
expect(noteCreateService['isRenote'](note)).toBe(true);
|
||||||
|
expect(noteCreateService['isQuote'](note)).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -3,6 +3,8 @@
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
||||||
|
|
||||||
process.env.NODE_ENV = 'test';
|
process.env.NODE_ENV = 'test';
|
||||||
|
|
||||||
import { jest } from '@jest/globals';
|
import { jest } from '@jest/globals';
|
||||||
|
@ -20,6 +22,7 @@ import { IdService } from '@/core/IdService.js';
|
||||||
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
||||||
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||||
import { NotificationService } from '@/core/NotificationService.js';
|
import { NotificationService } from '@/core/NotificationService.js';
|
||||||
|
import { RoleCondFormulaValue } from '@/models/Role.js';
|
||||||
import { sleep } from '../utils.js';
|
import { sleep } from '../utils.js';
|
||||||
import type { TestingModule } from '@nestjs/testing';
|
import type { TestingModule } from '@nestjs/testing';
|
||||||
import type { MockFunctionMetadata } from 'jest-mock';
|
import type { MockFunctionMetadata } from 'jest-mock';
|
||||||
|
@ -52,12 +55,26 @@ describe('RoleService', () => {
|
||||||
id: genAidx(Date.now()),
|
id: genAidx(Date.now()),
|
||||||
updatedAt: new Date(),
|
updatedAt: new Date(),
|
||||||
lastUsedAt: new Date(),
|
lastUsedAt: new Date(),
|
||||||
|
name: '',
|
||||||
description: '',
|
description: '',
|
||||||
...data,
|
...data,
|
||||||
})
|
})
|
||||||
.then(x => rolesRepository.findOneByOrFail(x.identifiers[0]));
|
.then(x => rolesRepository.findOneByOrFail(x.identifiers[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createConditionalRole(condFormula: RoleCondFormulaValue, data: Partial<MiRole> = {}) {
|
||||||
|
return createRole({
|
||||||
|
name: `[conditional] ${condFormula.type}`,
|
||||||
|
target: 'conditional',
|
||||||
|
condFormula: condFormula,
|
||||||
|
...data,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function aidx() {
|
||||||
|
return genAidx(Date.now());
|
||||||
|
}
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
clock = lolex.install({
|
clock = lolex.install({
|
||||||
now: new Date(),
|
now: new Date(),
|
||||||
|
@ -73,6 +90,7 @@ describe('RoleService', () => {
|
||||||
CacheService,
|
CacheService,
|
||||||
IdService,
|
IdService,
|
||||||
GlobalEventService,
|
GlobalEventService,
|
||||||
|
UserEntityService,
|
||||||
{
|
{
|
||||||
provide: NotificationService,
|
provide: NotificationService,
|
||||||
useFactory: () => ({
|
useFactory: () => ({
|
||||||
|
@ -209,79 +227,6 @@ describe('RoleService', () => {
|
||||||
expect(result.driveCapacityMb).toBe(100);
|
expect(result.driveCapacityMb).toBe(100);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('conditional role', async () => {
|
|
||||||
const user1 = await createUser({
|
|
||||||
id: genAidx(Date.now() - (1000 * 60 * 60 * 24 * 365)),
|
|
||||||
});
|
|
||||||
const user2 = await createUser({
|
|
||||||
id: genAidx(Date.now() - (1000 * 60 * 60 * 24 * 365)),
|
|
||||||
followersCount: 10,
|
|
||||||
});
|
|
||||||
await createRole({
|
|
||||||
name: 'a',
|
|
||||||
policies: {
|
|
||||||
canManageCustomEmojis: {
|
|
||||||
useDefault: false,
|
|
||||||
priority: 0,
|
|
||||||
value: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
target: 'conditional',
|
|
||||||
condFormula: {
|
|
||||||
id: '232a4221-9816-49a6-a967-ae0fac52ec5e',
|
|
||||||
type: 'and',
|
|
||||||
values: [{
|
|
||||||
id: '2a37ef43-2d93-4c4d-87f6-f2fdb7d9b530',
|
|
||||||
type: 'followersMoreThanOrEq',
|
|
||||||
value: 10,
|
|
||||||
}, {
|
|
||||||
id: '1bd67839-b126-4f92-bad0-4e285dab453b',
|
|
||||||
type: 'createdMoreThan',
|
|
||||||
sec: 60 * 60 * 24 * 7,
|
|
||||||
}],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
metaService.fetch.mockResolvedValue({
|
|
||||||
policies: {
|
|
||||||
canManageCustomEmojis: false,
|
|
||||||
},
|
|
||||||
} as FIXME);
|
|
||||||
|
|
||||||
const user1Policies = await roleService.getUserPolicies(user1.id);
|
|
||||||
const user2Policies = await roleService.getUserPolicies(user2.id);
|
|
||||||
expect(user1Policies.canManageCustomEmojis).toBe(false);
|
|
||||||
expect(user2Policies.canManageCustomEmojis).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('コンディショナルロール: マニュアルロールにアサイン済み', async () => {
|
|
||||||
const [user1, user2, role1] = await Promise.all([
|
|
||||||
createUser(),
|
|
||||||
createUser(),
|
|
||||||
createRole({
|
|
||||||
name: 'manual role',
|
|
||||||
}),
|
|
||||||
]);
|
|
||||||
const role2 = await createRole({
|
|
||||||
name: 'conditional role',
|
|
||||||
target: 'conditional',
|
|
||||||
condFormula: {
|
|
||||||
// idはバックエンドのロジックに必要ない?
|
|
||||||
id: 'bdc612bd-9d54-4675-ae83-0499c82ea670',
|
|
||||||
type: 'roleAssignedTo',
|
|
||||||
roleId: role1.id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
await roleService.assign(user2.id, role1.id);
|
|
||||||
|
|
||||||
const [u1role, u2role] = await Promise.all([
|
|
||||||
roleService.getUserRoles(user1.id),
|
|
||||||
roleService.getUserRoles(user2.id),
|
|
||||||
]);
|
|
||||||
expect(u1role.some(r => r.id === role2.id)).toBe(false);
|
|
||||||
expect(u2role.some(r => r.id === role2.id)).toBe(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('expired role', async () => {
|
test('expired role', async () => {
|
||||||
const user = await createUser();
|
const user = await createUser();
|
||||||
const role = await createRole({
|
const role = await createRole({
|
||||||
|
@ -320,6 +265,427 @@ describe('RoleService', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('conditional role', () => {
|
||||||
|
test('~かつ~', async () => {
|
||||||
|
const [user1, user2, user3, user4] = await Promise.all([
|
||||||
|
createUser({ isBot: true, isCat: false, isSuspended: false }),
|
||||||
|
createUser({ isBot: false, isCat: true, isSuspended: false }),
|
||||||
|
createUser({ isBot: true, isCat: true, isSuspended: false }),
|
||||||
|
createUser({ isBot: false, isCat: false, isSuspended: true }),
|
||||||
|
]);
|
||||||
|
const role1 = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'isBot',
|
||||||
|
});
|
||||||
|
const role2 = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'isCat',
|
||||||
|
});
|
||||||
|
const role3 = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'isSuspended',
|
||||||
|
});
|
||||||
|
const role4 = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'and',
|
||||||
|
values: [role1.condFormula, role2.condFormula],
|
||||||
|
});
|
||||||
|
|
||||||
|
const actual1 = await roleService.getUserRoles(user1.id);
|
||||||
|
const actual2 = await roleService.getUserRoles(user2.id);
|
||||||
|
const actual3 = await roleService.getUserRoles(user3.id);
|
||||||
|
const actual4 = await roleService.getUserRoles(user4.id);
|
||||||
|
expect(actual1.some(r => r.id === role4.id)).toBe(false);
|
||||||
|
expect(actual2.some(r => r.id === role4.id)).toBe(false);
|
||||||
|
expect(actual3.some(r => r.id === role4.id)).toBe(true);
|
||||||
|
expect(actual4.some(r => r.id === role4.id)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('~または~', async () => {
|
||||||
|
const [user1, user2, user3, user4] = await Promise.all([
|
||||||
|
createUser({ isBot: true, isCat: false, isSuspended: false }),
|
||||||
|
createUser({ isBot: false, isCat: true, isSuspended: false }),
|
||||||
|
createUser({ isBot: true, isCat: true, isSuspended: false }),
|
||||||
|
createUser({ isBot: false, isCat: false, isSuspended: true }),
|
||||||
|
]);
|
||||||
|
const role1 = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'isBot',
|
||||||
|
});
|
||||||
|
const role2 = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'isCat',
|
||||||
|
});
|
||||||
|
const role3 = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'isSuspended',
|
||||||
|
});
|
||||||
|
const role4 = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'or',
|
||||||
|
values: [role1.condFormula, role2.condFormula],
|
||||||
|
});
|
||||||
|
|
||||||
|
const actual1 = await roleService.getUserRoles(user1.id);
|
||||||
|
const actual2 = await roleService.getUserRoles(user2.id);
|
||||||
|
const actual3 = await roleService.getUserRoles(user3.id);
|
||||||
|
const actual4 = await roleService.getUserRoles(user4.id);
|
||||||
|
expect(actual1.some(r => r.id === role4.id)).toBe(true);
|
||||||
|
expect(actual2.some(r => r.id === role4.id)).toBe(true);
|
||||||
|
expect(actual3.some(r => r.id === role4.id)).toBe(true);
|
||||||
|
expect(actual4.some(r => r.id === role4.id)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('~ではない', async () => {
|
||||||
|
const [user1, user2, user3] = await Promise.all([
|
||||||
|
createUser({ isBot: true, isCat: false, isSuspended: false }),
|
||||||
|
createUser({ isBot: false, isCat: true, isSuspended: false }),
|
||||||
|
createUser({ isBot: true, isCat: true, isSuspended: false }),
|
||||||
|
]);
|
||||||
|
const role1 = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'isBot',
|
||||||
|
});
|
||||||
|
const role2 = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'isCat',
|
||||||
|
});
|
||||||
|
const role4 = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'not',
|
||||||
|
value: role1.condFormula,
|
||||||
|
});
|
||||||
|
|
||||||
|
const actual1 = await roleService.getUserRoles(user1.id);
|
||||||
|
const actual2 = await roleService.getUserRoles(user2.id);
|
||||||
|
const actual3 = await roleService.getUserRoles(user3.id);
|
||||||
|
expect(actual1.some(r => r.id === role4.id)).toBe(false);
|
||||||
|
expect(actual2.some(r => r.id === role4.id)).toBe(true);
|
||||||
|
expect(actual3.some(r => r.id === role4.id)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('マニュアルロールにアサイン済み', async () => {
|
||||||
|
const [user1, user2, role1] = await Promise.all([
|
||||||
|
createUser(),
|
||||||
|
createUser(),
|
||||||
|
createRole({
|
||||||
|
name: 'manual role',
|
||||||
|
}),
|
||||||
|
]);
|
||||||
|
const role2 = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'roleAssignedTo',
|
||||||
|
roleId: role1.id,
|
||||||
|
});
|
||||||
|
await roleService.assign(user2.id, role1.id);
|
||||||
|
|
||||||
|
const [u1role, u2role] = await Promise.all([
|
||||||
|
roleService.getUserRoles(user1.id),
|
||||||
|
roleService.getUserRoles(user2.id),
|
||||||
|
]);
|
||||||
|
expect(u1role.some(r => r.id === role2.id)).toBe(false);
|
||||||
|
expect(u2role.some(r => r.id === role2.id)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('ローカルユーザのみ', async () => {
|
||||||
|
const [user1, user2] = await Promise.all([
|
||||||
|
createUser({ host: null }),
|
||||||
|
createUser({ host: 'example.com' }),
|
||||||
|
]);
|
||||||
|
const role = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'isLocal',
|
||||||
|
});
|
||||||
|
|
||||||
|
const actual1 = await roleService.getUserRoles(user1.id);
|
||||||
|
const actual2 = await roleService.getUserRoles(user2.id);
|
||||||
|
expect(actual1.some(r => r.id === role.id)).toBe(true);
|
||||||
|
expect(actual2.some(r => r.id === role.id)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('リモートユーザのみ', async () => {
|
||||||
|
const [user1, user2] = await Promise.all([
|
||||||
|
createUser({ host: null }),
|
||||||
|
createUser({ host: 'example.com' }),
|
||||||
|
]);
|
||||||
|
const role = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'isRemote',
|
||||||
|
});
|
||||||
|
|
||||||
|
const actual1 = await roleService.getUserRoles(user1.id);
|
||||||
|
const actual2 = await roleService.getUserRoles(user2.id);
|
||||||
|
expect(actual1.some(r => r.id === role.id)).toBe(false);
|
||||||
|
expect(actual2.some(r => r.id === role.id)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('サスペンド済みユーザである', async () => {
|
||||||
|
const [user1, user2] = await Promise.all([
|
||||||
|
createUser({ isSuspended: false }),
|
||||||
|
createUser({ isSuspended: true }),
|
||||||
|
]);
|
||||||
|
const role = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'isSuspended',
|
||||||
|
});
|
||||||
|
|
||||||
|
const actual1 = await roleService.getUserRoles(user1.id);
|
||||||
|
const actual2 = await roleService.getUserRoles(user2.id);
|
||||||
|
expect(actual1.some(r => r.id === role.id)).toBe(false);
|
||||||
|
expect(actual2.some(r => r.id === role.id)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('鍵アカウントユーザである', async () => {
|
||||||
|
const [user1, user2] = await Promise.all([
|
||||||
|
createUser({ isLocked: false }),
|
||||||
|
createUser({ isLocked: true }),
|
||||||
|
]);
|
||||||
|
const role = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'isLocked',
|
||||||
|
});
|
||||||
|
|
||||||
|
const actual1 = await roleService.getUserRoles(user1.id);
|
||||||
|
const actual2 = await roleService.getUserRoles(user2.id);
|
||||||
|
expect(actual1.some(r => r.id === role.id)).toBe(false);
|
||||||
|
expect(actual2.some(r => r.id === role.id)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('botユーザである', async () => {
|
||||||
|
const [user1, user2] = await Promise.all([
|
||||||
|
createUser({ isBot: false }),
|
||||||
|
createUser({ isBot: true }),
|
||||||
|
]);
|
||||||
|
const role = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'isBot',
|
||||||
|
});
|
||||||
|
|
||||||
|
const actual1 = await roleService.getUserRoles(user1.id);
|
||||||
|
const actual2 = await roleService.getUserRoles(user2.id);
|
||||||
|
expect(actual1.some(r => r.id === role.id)).toBe(false);
|
||||||
|
expect(actual2.some(r => r.id === role.id)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('猫である', async () => {
|
||||||
|
const [user1, user2] = await Promise.all([
|
||||||
|
createUser({ isCat: false }),
|
||||||
|
createUser({ isCat: true }),
|
||||||
|
]);
|
||||||
|
const role = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'isCat',
|
||||||
|
});
|
||||||
|
|
||||||
|
const actual1 = await roleService.getUserRoles(user1.id);
|
||||||
|
const actual2 = await roleService.getUserRoles(user2.id);
|
||||||
|
expect(actual1.some(r => r.id === role.id)).toBe(false);
|
||||||
|
expect(actual2.some(r => r.id === role.id)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('「ユーザを見つけやすくする」が有効なアカウント', async () => {
|
||||||
|
const [user1, user2] = await Promise.all([
|
||||||
|
createUser({ isExplorable: false }),
|
||||||
|
createUser({ isExplorable: true }),
|
||||||
|
]);
|
||||||
|
const role = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'isExplorable',
|
||||||
|
});
|
||||||
|
|
||||||
|
const actual1 = await roleService.getUserRoles(user1.id);
|
||||||
|
const actual2 = await roleService.getUserRoles(user2.id);
|
||||||
|
expect(actual1.some(r => r.id === role.id)).toBe(false);
|
||||||
|
expect(actual2.some(r => r.id === role.id)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('ユーザが作成されてから指定期間経過した', async () => {
|
||||||
|
const base = new Date();
|
||||||
|
base.setMinutes(base.getMinutes() - 5);
|
||||||
|
|
||||||
|
const d1 = new Date(base);
|
||||||
|
const d2 = new Date(base);
|
||||||
|
const d3 = new Date(base);
|
||||||
|
d1.setSeconds(d1.getSeconds() - 1);
|
||||||
|
d3.setSeconds(d3.getSeconds() + 1);
|
||||||
|
|
||||||
|
const [user1, user2, user3] = await Promise.all([
|
||||||
|
// 4:59
|
||||||
|
createUser({ id: genAidx(d1.getTime()) }),
|
||||||
|
// 5:00
|
||||||
|
createUser({ id: genAidx(d2.getTime()) }),
|
||||||
|
// 5:01
|
||||||
|
createUser({ id: genAidx(d3.getTime()) }),
|
||||||
|
]);
|
||||||
|
const role = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'createdLessThan',
|
||||||
|
// 5 minutes
|
||||||
|
sec: 300,
|
||||||
|
});
|
||||||
|
|
||||||
|
const actual1 = await roleService.getUserRoles(user1.id);
|
||||||
|
const actual2 = await roleService.getUserRoles(user2.id);
|
||||||
|
const actual3 = await roleService.getUserRoles(user3.id);
|
||||||
|
expect(actual1.some(r => r.id === role.id)).toBe(false);
|
||||||
|
expect(actual2.some(r => r.id === role.id)).toBe(false);
|
||||||
|
expect(actual3.some(r => r.id === role.id)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('ユーザが作成されてから指定期間経っていない', async () => {
|
||||||
|
const base = new Date();
|
||||||
|
base.setMinutes(base.getMinutes() - 5);
|
||||||
|
|
||||||
|
const d1 = new Date(base);
|
||||||
|
const d2 = new Date(base);
|
||||||
|
const d3 = new Date(base);
|
||||||
|
d1.setSeconds(d1.getSeconds() - 1);
|
||||||
|
d3.setSeconds(d3.getSeconds() + 1);
|
||||||
|
|
||||||
|
const [user1, user2, user3] = await Promise.all([
|
||||||
|
// 4:59
|
||||||
|
createUser({ id: genAidx(d1.getTime()) }),
|
||||||
|
// 5:00
|
||||||
|
createUser({ id: genAidx(d2.getTime()) }),
|
||||||
|
// 5:01
|
||||||
|
createUser({ id: genAidx(d3.getTime()) }),
|
||||||
|
]);
|
||||||
|
const role = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'createdMoreThan',
|
||||||
|
// 5 minutes
|
||||||
|
sec: 300,
|
||||||
|
});
|
||||||
|
|
||||||
|
const actual1 = await roleService.getUserRoles(user1.id);
|
||||||
|
const actual2 = await roleService.getUserRoles(user2.id);
|
||||||
|
const actual3 = await roleService.getUserRoles(user3.id);
|
||||||
|
expect(actual1.some(r => r.id === role.id)).toBe(true);
|
||||||
|
expect(actual2.some(r => r.id === role.id)).toBe(false);
|
||||||
|
expect(actual3.some(r => r.id === role.id)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('フォロワー数が指定値以下', async () => {
|
||||||
|
const [user1, user2, user3] = await Promise.all([
|
||||||
|
createUser({ followersCount: 99 }),
|
||||||
|
createUser({ followersCount: 100 }),
|
||||||
|
createUser({ followersCount: 101 }),
|
||||||
|
]);
|
||||||
|
const role = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'followersLessThanOrEq',
|
||||||
|
value: 100,
|
||||||
|
});
|
||||||
|
|
||||||
|
const actual1 = await roleService.getUserRoles(user1.id);
|
||||||
|
const actual2 = await roleService.getUserRoles(user2.id);
|
||||||
|
const actual3 = await roleService.getUserRoles(user3.id);
|
||||||
|
expect(actual1.some(r => r.id === role.id)).toBe(true);
|
||||||
|
expect(actual2.some(r => r.id === role.id)).toBe(true);
|
||||||
|
expect(actual3.some(r => r.id === role.id)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('フォロワー数が指定値以下', async () => {
|
||||||
|
const [user1, user2, user3] = await Promise.all([
|
||||||
|
createUser({ followersCount: 99 }),
|
||||||
|
createUser({ followersCount: 100 }),
|
||||||
|
createUser({ followersCount: 101 }),
|
||||||
|
]);
|
||||||
|
const role = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'followersMoreThanOrEq',
|
||||||
|
value: 100,
|
||||||
|
});
|
||||||
|
|
||||||
|
const actual1 = await roleService.getUserRoles(user1.id);
|
||||||
|
const actual2 = await roleService.getUserRoles(user2.id);
|
||||||
|
const actual3 = await roleService.getUserRoles(user3.id);
|
||||||
|
expect(actual1.some(r => r.id === role.id)).toBe(false);
|
||||||
|
expect(actual2.some(r => r.id === role.id)).toBe(true);
|
||||||
|
expect(actual3.some(r => r.id === role.id)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('フォロー数が指定値以下', async () => {
|
||||||
|
const [user1, user2, user3] = await Promise.all([
|
||||||
|
createUser({ followingCount: 99 }),
|
||||||
|
createUser({ followingCount: 100 }),
|
||||||
|
createUser({ followingCount: 101 }),
|
||||||
|
]);
|
||||||
|
const role = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'followingLessThanOrEq',
|
||||||
|
value: 100,
|
||||||
|
});
|
||||||
|
|
||||||
|
const actual1 = await roleService.getUserRoles(user1.id);
|
||||||
|
const actual2 = await roleService.getUserRoles(user2.id);
|
||||||
|
const actual3 = await roleService.getUserRoles(user3.id);
|
||||||
|
expect(actual1.some(r => r.id === role.id)).toBe(true);
|
||||||
|
expect(actual2.some(r => r.id === role.id)).toBe(true);
|
||||||
|
expect(actual3.some(r => r.id === role.id)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('フォロー数が指定値以上', async () => {
|
||||||
|
const [user1, user2, user3] = await Promise.all([
|
||||||
|
createUser({ followingCount: 99 }),
|
||||||
|
createUser({ followingCount: 100 }),
|
||||||
|
createUser({ followingCount: 101 }),
|
||||||
|
]);
|
||||||
|
const role = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'followingMoreThanOrEq',
|
||||||
|
value: 100,
|
||||||
|
});
|
||||||
|
|
||||||
|
const actual1 = await roleService.getUserRoles(user1.id);
|
||||||
|
const actual2 = await roleService.getUserRoles(user2.id);
|
||||||
|
const actual3 = await roleService.getUserRoles(user3.id);
|
||||||
|
expect(actual1.some(r => r.id === role.id)).toBe(false);
|
||||||
|
expect(actual2.some(r => r.id === role.id)).toBe(true);
|
||||||
|
expect(actual3.some(r => r.id === role.id)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('ノート数が指定値以下', async () => {
|
||||||
|
const [user1, user2, user3] = await Promise.all([
|
||||||
|
createUser({ notesCount: 9 }),
|
||||||
|
createUser({ notesCount: 10 }),
|
||||||
|
createUser({ notesCount: 11 }),
|
||||||
|
]);
|
||||||
|
const role = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'notesLessThanOrEq',
|
||||||
|
value: 10,
|
||||||
|
});
|
||||||
|
|
||||||
|
const actual1 = await roleService.getUserRoles(user1.id);
|
||||||
|
const actual2 = await roleService.getUserRoles(user2.id);
|
||||||
|
const actual3 = await roleService.getUserRoles(user3.id);
|
||||||
|
expect(actual1.some(r => r.id === role.id)).toBe(true);
|
||||||
|
expect(actual2.some(r => r.id === role.id)).toBe(true);
|
||||||
|
expect(actual3.some(r => r.id === role.id)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('ノート数が指定値以上', async () => {
|
||||||
|
const [user1, user2, user3] = await Promise.all([
|
||||||
|
createUser({ notesCount: 9 }),
|
||||||
|
createUser({ notesCount: 10 }),
|
||||||
|
createUser({ notesCount: 11 }),
|
||||||
|
]);
|
||||||
|
const role = await createConditionalRole({
|
||||||
|
id: aidx(),
|
||||||
|
type: 'notesMoreThanOrEq',
|
||||||
|
value: 10,
|
||||||
|
});
|
||||||
|
|
||||||
|
const actual1 = await roleService.getUserRoles(user1.id);
|
||||||
|
const actual2 = await roleService.getUserRoles(user2.id);
|
||||||
|
const actual3 = await roleService.getUserRoles(user3.id);
|
||||||
|
expect(actual1.some(r => r.id === role.id)).toBe(false);
|
||||||
|
expect(actual2.some(r => r.id === role.id)).toBe(true);
|
||||||
|
expect(actual3.some(r => r.id === role.id)).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('assign', () => {
|
describe('assign', () => {
|
||||||
test('公開ロールの場合は通知される', async () => {
|
test('公開ロールの場合は通知される', async () => {
|
||||||
const user = await createUser();
|
const user = await createUser();
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { GlobalModule } from '@/GlobalModule.js';
|
||||||
import { CoreModule } from '@/core/CoreModule.js';
|
import { CoreModule } from '@/core/CoreModule.js';
|
||||||
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
||||||
import { LoggerService } from '@/core/LoggerService.js';
|
import { LoggerService } from '@/core/LoggerService.js';
|
||||||
import type { IActor, IApDocument, ICollection, IPost } from '@/core/activitypub/type.js';
|
import type { IActor, IApDocument, ICollection, IObject, IPost } from '@/core/activitypub/type.js';
|
||||||
import { MiMeta, MiNote } from '@/models/_.js';
|
import { MiMeta, MiNote } from '@/models/_.js';
|
||||||
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
import { secureRndstr } from '@/misc/secure-rndstr.js';
|
||||||
import { DownloadService } from '@/core/DownloadService.js';
|
import { DownloadService } from '@/core/DownloadService.js';
|
||||||
|
@ -295,7 +295,7 @@ describe('ActivityPub', () => {
|
||||||
await createRandomRemoteUser(resolver, personService),
|
await createRandomRemoteUser(resolver, personService),
|
||||||
imageObject,
|
imageObject,
|
||||||
);
|
);
|
||||||
assert.ok(!driveFile.isLink);
|
assert.ok(driveFile && !driveFile.isLink);
|
||||||
|
|
||||||
const sensitiveImageObject: IApDocument = {
|
const sensitiveImageObject: IApDocument = {
|
||||||
type: 'Document',
|
type: 'Document',
|
||||||
|
@ -308,7 +308,7 @@ describe('ActivityPub', () => {
|
||||||
await createRandomRemoteUser(resolver, personService),
|
await createRandomRemoteUser(resolver, personService),
|
||||||
sensitiveImageObject,
|
sensitiveImageObject,
|
||||||
);
|
);
|
||||||
assert.ok(!sensitiveDriveFile.isLink);
|
assert.ok(sensitiveDriveFile && !sensitiveDriveFile.isLink);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('cacheRemoteFiles=false disables caching', async () => {
|
test('cacheRemoteFiles=false disables caching', async () => {
|
||||||
|
@ -324,7 +324,7 @@ describe('ActivityPub', () => {
|
||||||
await createRandomRemoteUser(resolver, personService),
|
await createRandomRemoteUser(resolver, personService),
|
||||||
imageObject,
|
imageObject,
|
||||||
);
|
);
|
||||||
assert.ok(driveFile.isLink);
|
assert.ok(driveFile && driveFile.isLink);
|
||||||
|
|
||||||
const sensitiveImageObject: IApDocument = {
|
const sensitiveImageObject: IApDocument = {
|
||||||
type: 'Document',
|
type: 'Document',
|
||||||
|
@ -337,7 +337,7 @@ describe('ActivityPub', () => {
|
||||||
await createRandomRemoteUser(resolver, personService),
|
await createRandomRemoteUser(resolver, personService),
|
||||||
sensitiveImageObject,
|
sensitiveImageObject,
|
||||||
);
|
);
|
||||||
assert.ok(sensitiveDriveFile.isLink);
|
assert.ok(sensitiveDriveFile && sensitiveDriveFile.isLink);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('cacheRemoteSensitiveFiles=false only affects sensitive files', async () => {
|
test('cacheRemoteSensitiveFiles=false only affects sensitive files', async () => {
|
||||||
|
@ -353,7 +353,7 @@ describe('ActivityPub', () => {
|
||||||
await createRandomRemoteUser(resolver, personService),
|
await createRandomRemoteUser(resolver, personService),
|
||||||
imageObject,
|
imageObject,
|
||||||
);
|
);
|
||||||
assert.ok(!driveFile.isLink);
|
assert.ok(driveFile && !driveFile.isLink);
|
||||||
|
|
||||||
const sensitiveImageObject: IApDocument = {
|
const sensitiveImageObject: IApDocument = {
|
||||||
type: 'Document',
|
type: 'Document',
|
||||||
|
@ -366,7 +366,19 @@ describe('ActivityPub', () => {
|
||||||
await createRandomRemoteUser(resolver, personService),
|
await createRandomRemoteUser(resolver, personService),
|
||||||
sensitiveImageObject,
|
sensitiveImageObject,
|
||||||
);
|
);
|
||||||
assert.ok(sensitiveDriveFile.isLink);
|
assert.ok(sensitiveDriveFile && sensitiveDriveFile.isLink);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('Link is not an attachment files', async () => {
|
||||||
|
const linkObject: IObject = {
|
||||||
|
type: 'Link',
|
||||||
|
href: 'https://example.com/',
|
||||||
|
};
|
||||||
|
const driveFile = await imageService.createImage(
|
||||||
|
await createRandomRemoteUser(resolver, personService),
|
||||||
|
linkObject,
|
||||||
|
);
|
||||||
|
assert.strictEqual(driveFile, null);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
88
packages/backend/test/unit/misc/is-renote.ts
Normal file
88
packages/backend/test/unit/misc/is-renote.ts
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { isQuote, isRenote } from '@/misc/is-renote.js';
|
||||||
|
import { MiNote } from '@/models/Note.js';
|
||||||
|
|
||||||
|
const base: MiNote = {
|
||||||
|
id: 'some-note-id',
|
||||||
|
replyId: null,
|
||||||
|
reply: null,
|
||||||
|
renoteId: null,
|
||||||
|
renote: null,
|
||||||
|
threadId: null,
|
||||||
|
text: null,
|
||||||
|
name: null,
|
||||||
|
cw: null,
|
||||||
|
userId: 'some-user-id',
|
||||||
|
user: null,
|
||||||
|
localOnly: false,
|
||||||
|
reactionAcceptance: null,
|
||||||
|
renoteCount: 0,
|
||||||
|
repliesCount: 0,
|
||||||
|
clippedCount: 0,
|
||||||
|
reactions: {},
|
||||||
|
visibility: 'public',
|
||||||
|
uri: null,
|
||||||
|
url: null,
|
||||||
|
fileIds: [],
|
||||||
|
attachedFileTypes: [],
|
||||||
|
visibleUserIds: [],
|
||||||
|
mentions: [],
|
||||||
|
mentionedRemoteUsers: '',
|
||||||
|
reactionAndUserPairCache: [],
|
||||||
|
emojis: [],
|
||||||
|
tags: [],
|
||||||
|
hasPoll: false,
|
||||||
|
channelId: null,
|
||||||
|
channel: null,
|
||||||
|
userHost: null,
|
||||||
|
replyUserId: null,
|
||||||
|
replyUserHost: null,
|
||||||
|
renoteUserId: null,
|
||||||
|
renoteUserHost: null,
|
||||||
|
};
|
||||||
|
|
||||||
|
describe('misc:is-renote', () => {
|
||||||
|
test('note without renoteId should not be Renote', () => {
|
||||||
|
expect(isRenote(base)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('note with renoteId should be Renote and not be Quote', () => {
|
||||||
|
const note: MiNote = { ...base, renoteId: 'some-renote-id' };
|
||||||
|
expect(isRenote(note)).toBe(true);
|
||||||
|
expect(isQuote(note as any)).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('note with renoteId and text should be Quote', () => {
|
||||||
|
const note: MiNote = { ...base, renoteId: 'some-renote-id', text: 'some-text' };
|
||||||
|
expect(isRenote(note)).toBe(true);
|
||||||
|
expect(isQuote(note as any)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('note with renoteId and cw should be Quote', () => {
|
||||||
|
const note: MiNote = { ...base, renoteId: 'some-renote-id', cw: 'some-cw' };
|
||||||
|
expect(isRenote(note)).toBe(true);
|
||||||
|
expect(isQuote(note as any)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('note with renoteId and replyId should be Quote', () => {
|
||||||
|
const note: MiNote = { ...base, renoteId: 'some-renote-id', replyId: 'some-reply-id' };
|
||||||
|
expect(isRenote(note)).toBe(true);
|
||||||
|
expect(isQuote(note as any)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('note with renoteId and poll should be Quote', () => {
|
||||||
|
const note: MiNote = { ...base, renoteId: 'some-renote-id', hasPoll: true };
|
||||||
|
expect(isRenote(note)).toBe(true);
|
||||||
|
expect(isQuote(note as any)).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('note with renoteId and non-empty fileIds should be Quote', () => {
|
||||||
|
const note: MiNote = { ...base, renoteId: 'some-renote-id', fileIds: ['some-file-id'] };
|
||||||
|
expect(isRenote(note)).toBe(true);
|
||||||
|
expect(isQuote(note as any)).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
|
@ -31,7 +31,7 @@
|
||||||
"@twemoji/parser": "15.1.1",
|
"@twemoji/parser": "15.1.1",
|
||||||
"@vitejs/plugin-vue": "5.0.4",
|
"@vitejs/plugin-vue": "5.0.4",
|
||||||
"@vue/compiler-sfc": "3.4.15",
|
"@vue/compiler-sfc": "3.4.15",
|
||||||
"aiscript-vscode": "github:aiscript-dev/aiscript-vscode#v0.1.2",
|
"aiscript-vscode": "github:aiscript-dev/aiscript-vscode#v0.1.4",
|
||||||
"astring": "1.8.6",
|
"astring": "1.8.6",
|
||||||
"broadcast-channel": "7.0.0",
|
"broadcast-channel": "7.0.0",
|
||||||
"buraha": "0.0.1",
|
"buraha": "0.0.1",
|
||||||
|
|
|
@ -20,7 +20,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</div>
|
</div>
|
||||||
<div class="detail">
|
<div class="detail">
|
||||||
<div>
|
<div>
|
||||||
<Mfm :text="report.comment"/>
|
<Mfm :text="report.comment" :linkBehavior="'window'"/>
|
||||||
</div>
|
</div>
|
||||||
<hr/>
|
<hr/>
|
||||||
<div>{{ i18n.ts.reporter }}: <MkA :to="`/admin/user/${report.reporter.id}`" class="_link" :behavior="'window'">@{{ report.reporter.username }}</MkA></div>
|
<div>{{ i18n.ts.reporter }}: <MkA :to="`/admin/user/${report.reporter.id}`" class="_link" :behavior="'window'">@{{ report.reporter.username }}</MkA></div>
|
||||||
|
|
|
@ -23,6 +23,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
v-else class="_button"
|
v-else class="_button"
|
||||||
:class="[$style.root, { [$style.inline]: inline, [$style.primary]: primary, [$style.gradate]: gradate, [$style.danger]: danger, [$style.rounded]: rounded, [$style.full]: full, [$style.small]: small, [$style.large]: large, [$style.transparent]: transparent, [$style.asLike]: asLike }]"
|
:class="[$style.root, { [$style.inline]: inline, [$style.primary]: primary, [$style.gradate]: gradate, [$style.danger]: danger, [$style.rounded]: rounded, [$style.full]: full, [$style.small]: small, [$style.large]: large, [$style.transparent]: transparent, [$style.asLike]: asLike }]"
|
||||||
:to="to ?? '#'"
|
:to="to ?? '#'"
|
||||||
|
:behavior="linkBehavior"
|
||||||
@mousedown="onMousedown"
|
@mousedown="onMousedown"
|
||||||
>
|
>
|
||||||
<div ref="ripples" :class="$style.ripples" :data-children-class="$style.ripple"></div>
|
<div ref="ripples" :class="$style.ripples" :data-children-class="$style.ripple"></div>
|
||||||
|
@ -43,6 +44,7 @@ const props = defineProps<{
|
||||||
inline?: boolean;
|
inline?: boolean;
|
||||||
link?: boolean;
|
link?: boolean;
|
||||||
to?: string;
|
to?: string;
|
||||||
|
linkBehavior?: null | 'window' | 'browser';
|
||||||
autofocus?: boolean;
|
autofocus?: boolean;
|
||||||
wait?: boolean;
|
wait?: boolean;
|
||||||
danger?: boolean;
|
danger?: boolean;
|
||||||
|
|
|
@ -4,37 +4,59 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div :class="$style.root" class="_panel">
|
<MkA :to="`/clips/${clip.id}`" :class="$style.link">
|
||||||
<b>{{ clip.name }}</b>
|
<div :class="$style.root" class="_panel _gaps_s">
|
||||||
<div v-if="clip.description" :class="$style.description">{{ clip.description }}</div>
|
<b>{{ clip.name }}</b>
|
||||||
<div v-if="clip.lastClippedAt">{{ i18n.ts.updatedAt }}: <MkTime :time="clip.lastClippedAt" mode="detail"/></div>
|
<div :class="$style.description">
|
||||||
<div :class="$style.user">
|
<div v-if="clip.description"><Mfm :text="clip.description" :plain="true" :nowrap="true"/></div>
|
||||||
<MkAvatar :user="clip.user" :class="$style.userAvatar" indicator link preview/> <MkUserName :user="clip.user" :nowrap="false"/>
|
<div v-if="clip.lastClippedAt">{{ i18n.ts.updatedAt }}: <MkTime :time="clip.lastClippedAt" mode="detail"/></div>
|
||||||
|
<div v-if="clip.notesCount != null">{{ i18n.ts.notesCount }}: {{ number(clip.notesCount) }} / {{ $i?.policies.noteEachClipsLimit }} ({{ i18n.tsx.remainingN({ n: remaining }) }})</div>
|
||||||
|
</div>
|
||||||
|
<div :class="$style.divider"></div>
|
||||||
|
<div>
|
||||||
|
<MkAvatar :user="clip.user" :class="$style.userAvatar" indicator link preview/> <MkUserName :user="clip.user" :nowrap="false"/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</MkA>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import * as Misskey from 'misskey-js';
|
||||||
|
import { computed } from 'vue';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
|
import { $i } from '@/account.js';
|
||||||
|
import number from '@/filters/number.js';
|
||||||
|
|
||||||
defineProps<{
|
const props = defineProps<{
|
||||||
clip: any;
|
clip: Misskey.entities.Clip;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const remaining = computed(() => {
|
||||||
|
return ($i?.policies && props.clip.notesCount != null) ? ($i.policies.noteEachClipsLimit - props.clip.notesCount) : i18n.ts.unknown;
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" module>
|
<style lang="scss" module>
|
||||||
.root {
|
.link {
|
||||||
display: block;
|
display: block;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.root {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.description {
|
.divider {
|
||||||
padding: 8px 0;
|
height: 1px;
|
||||||
|
background: var(--divider);
|
||||||
}
|
}
|
||||||
|
|
||||||
.user {
|
.description {
|
||||||
padding-top: 16px;
|
font-size: 90%;
|
||||||
border-top: solid 0.5px var(--divider);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.userAvatar {
|
.userAvatar {
|
||||||
|
|
|
@ -204,7 +204,7 @@ function onKeydown(evt: KeyboardEvent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function onInputKeydown(evt: KeyboardEvent) {
|
function onInputKeydown(evt: KeyboardEvent) {
|
||||||
if (evt.key === 'Enter') {
|
if (evt.key === 'Enter' && !okDisabled.value && okButtonDisabledReason.value === null) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
evt.stopPropagation();
|
evt.stopPropagation();
|
||||||
ok();
|
ok();
|
||||||
|
|
|
@ -94,6 +94,18 @@ async function onClick() {
|
||||||
userId: props.user.id,
|
userId: props.user.id,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
if (defaultStore.state.alwaysConfirmFollow) {
|
||||||
|
const { canceled } = await os.confirm({
|
||||||
|
type: 'question',
|
||||||
|
text: i18n.tsx.followConfirm({ name: props.user.name || props.user.username }),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (canceled) {
|
||||||
|
wait.value = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (userDetailed.value.hasPendingFollowRequestFromYou) {
|
if (userDetailed.value.hasPendingFollowRequestFromYou) {
|
||||||
await misskeyApi('following/requests/cancel', {
|
await misskeyApi('following/requests/cancel', {
|
||||||
userId: props.user.id,
|
userId: props.user.id,
|
||||||
|
|
|
@ -12,6 +12,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
:[attr]="self ? url.substring(local.length) : url"
|
:[attr]="self ? url.substring(local.length) : url"
|
||||||
:rel="rel ?? 'nofollow noopener'"
|
:rel="rel ?? 'nofollow noopener'"
|
||||||
:target="target"
|
:target="target"
|
||||||
|
:behavior="props.behavior"
|
||||||
:title="url"
|
:title="url"
|
||||||
@click="(ev: MouseEvent) => warningExternalWebsite(ev, url)"
|
@click="(ev: MouseEvent) => warningExternalWebsite(ev, url)"
|
||||||
>
|
>
|
||||||
|
@ -27,10 +28,12 @@ import { useTooltip } from '@/scripts/use-tooltip.js';
|
||||||
import { warningExternalWebsite } from '@/scripts/warning-external-website.js';
|
import { warningExternalWebsite } from '@/scripts/warning-external-website.js';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import { isEnabledUrlPreview } from '@/instance.js';
|
import { isEnabledUrlPreview } from '@/instance.js';
|
||||||
|
import { MkABehavior } from '@/components/global/MkA.vue';
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
url: string;
|
url: string;
|
||||||
rel?: null | string;
|
rel?: null | string;
|
||||||
|
behavior?: MkABehavior;
|
||||||
}>(), {
|
}>(), {
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,15 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
|
ref="playerEl"
|
||||||
|
v-hotkey="keymap"
|
||||||
|
tabindex="0"
|
||||||
:class="[
|
:class="[
|
||||||
$style.audioContainer,
|
$style.audioContainer,
|
||||||
(audio.isSensitive && defaultStore.state.highlightSensitiveMedia) && $style.sensitive,
|
(audio.isSensitive && defaultStore.state.highlightSensitiveMedia) && $style.sensitive,
|
||||||
]"
|
]"
|
||||||
@contextmenu.stop
|
@contextmenu.stop
|
||||||
|
@keydown.stop
|
||||||
>
|
>
|
||||||
<button v-if="hide" :class="$style.hidden" @click="showHiddenContent">
|
<button v-if="hide" :class="$style.hidden" @click="showHiddenContent">
|
||||||
<div :class="$style.hiddenTextWrapper">
|
<div :class="$style.hiddenTextWrapper">
|
||||||
|
@ -18,6 +22,19 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<span style="display: block;">{{ i18n.ts.clickToShow }}</span>
|
<span style="display: block;">{{ i18n.ts.clickToShow }}</span>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
<div v-else-if="defaultStore.reactiveState.useNativeUIForVideoAudioPlayer.value" :class="$style.nativeAudioContainer">
|
||||||
|
<audio
|
||||||
|
ref="audioEl"
|
||||||
|
preload="metadata"
|
||||||
|
controls
|
||||||
|
:class="$style.nativeAudio"
|
||||||
|
@keydown.prevent
|
||||||
|
>
|
||||||
|
<source :src="audio.url">
|
||||||
|
</audio>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div v-else :class="$style.audioControls">
|
<div v-else :class="$style.audioControls">
|
||||||
<audio
|
<audio
|
||||||
ref="audioEl"
|
ref="audioEl"
|
||||||
|
@ -73,6 +90,41 @@ const props = defineProps<{
|
||||||
audio: Misskey.entities.DriveFile;
|
audio: Misskey.entities.DriveFile;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
|
const keymap = {
|
||||||
|
'up': () => {
|
||||||
|
if (hasFocus() && audioEl.value) {
|
||||||
|
volume.value = Math.min(volume.value + 0.1, 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'down': () => {
|
||||||
|
if (hasFocus() && audioEl.value) {
|
||||||
|
volume.value = Math.max(volume.value - 0.1, 0);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'left': () => {
|
||||||
|
if (hasFocus() && audioEl.value) {
|
||||||
|
audioEl.value.currentTime = Math.max(audioEl.value.currentTime - 5, 0);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'right': () => {
|
||||||
|
if (hasFocus() && audioEl.value) {
|
||||||
|
audioEl.value.currentTime = Math.min(audioEl.value.currentTime + 5, audioEl.value.duration);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'space': () => {
|
||||||
|
if (hasFocus()) {
|
||||||
|
togglePlayPause();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// PlayerElもしくはその子要素にフォーカスがあるかどうか
|
||||||
|
function hasFocus() {
|
||||||
|
if (!playerEl.value) return false;
|
||||||
|
return playerEl.value === document.activeElement || playerEl.value.contains(document.activeElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
const playerEl = shallowRef<HTMLDivElement>();
|
||||||
const audioEl = shallowRef<HTMLAudioElement>();
|
const audioEl = shallowRef<HTMLAudioElement>();
|
||||||
|
|
||||||
// eslint-disable-next-line vue/no-setup-props-destructure
|
// eslint-disable-next-line vue/no-setup-props-destructure
|
||||||
|
@ -84,6 +136,30 @@ const menuShowing = ref(false);
|
||||||
function showMenu(ev: MouseEvent) {
|
function showMenu(ev: MouseEvent) {
|
||||||
const menu: MenuItem[] = [
|
const menu: MenuItem[] = [
|
||||||
// TODO: 再生キューに追加
|
// TODO: 再生キューに追加
|
||||||
|
{
|
||||||
|
type: 'switch',
|
||||||
|
text: i18n.ts._mediaControls.loop,
|
||||||
|
icon: 'ti ti-repeat',
|
||||||
|
ref: loop,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'radio',
|
||||||
|
text: i18n.ts._mediaControls.playbackRate,
|
||||||
|
icon: 'ti ti-clock-play',
|
||||||
|
ref: speed,
|
||||||
|
options: {
|
||||||
|
'0.25x': 0.25,
|
||||||
|
'0.5x': 0.5,
|
||||||
|
'0.75x': 0.75,
|
||||||
|
'1.0x': 1,
|
||||||
|
'1.25x': 1.25,
|
||||||
|
'1.5x': 1.5,
|
||||||
|
'2.0x': 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'divider',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
text: i18n.ts.hide,
|
text: i18n.ts.hide,
|
||||||
icon: 'ti ti-eye-off',
|
icon: 'ti ti-eye-off',
|
||||||
|
@ -174,6 +250,8 @@ const rangePercent = computed({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const volume = ref(.25);
|
const volume = ref(.25);
|
||||||
|
const speed = ref(1);
|
||||||
|
const loop = ref(false); // TODO: ドライブファイルのフラグに置き換える
|
||||||
const bufferedEnd = ref(0);
|
const bufferedEnd = ref(0);
|
||||||
const bufferedDataRatio = computed(() => {
|
const bufferedDataRatio = computed(() => {
|
||||||
if (!audioEl.value) return 0;
|
if (!audioEl.value) return 0;
|
||||||
|
@ -203,6 +281,7 @@ function toggleMute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let onceInit = false;
|
let onceInit = false;
|
||||||
|
let mediaTickFrameId: number | null = null;
|
||||||
let stopAudioElWatch: () => void;
|
let stopAudioElWatch: () => void;
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
@ -222,8 +301,12 @@ function init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
elapsedTimeMs.value = audioEl.value.currentTime * 1000;
|
elapsedTimeMs.value = audioEl.value.currentTime * 1000;
|
||||||
|
|
||||||
|
if (audioEl.value.loop !== loop.value) {
|
||||||
|
loop.value = audioEl.value.loop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
window.requestAnimationFrame(updateMediaTick);
|
mediaTickFrameId = window.requestAnimationFrame(updateMediaTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMediaTick();
|
updateMediaTick();
|
||||||
|
@ -261,6 +344,14 @@ watch(volume, (to) => {
|
||||||
if (audioEl.value) audioEl.value.volume = to;
|
if (audioEl.value) audioEl.value.volume = to;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(speed, (to) => {
|
||||||
|
if (audioEl.value) audioEl.value.playbackRate = to;
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(loop, (to) => {
|
||||||
|
if (audioEl.value) audioEl.value.loop = to;
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
init();
|
init();
|
||||||
});
|
});
|
||||||
|
@ -279,6 +370,10 @@ onDeactivated(() => {
|
||||||
hide.value = (defaultStore.state.nsfw === 'force' || defaultStore.state.dataSaver.media) ? true : (props.audio.isSensitive && defaultStore.state.nsfw !== 'ignore');
|
hide.value = (defaultStore.state.nsfw === 'force' || defaultStore.state.dataSaver.media) ? true : (props.audio.isSensitive && defaultStore.state.nsfw !== 'ignore');
|
||||||
stopAudioElWatch();
|
stopAudioElWatch();
|
||||||
onceInit = false;
|
onceInit = false;
|
||||||
|
if (mediaTickFrameId) {
|
||||||
|
window.cancelAnimationFrame(mediaTickFrameId);
|
||||||
|
mediaTickFrameId = null;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -289,6 +384,10 @@ onDeactivated(() => {
|
||||||
border: .5px solid var(--divider);
|
border: .5px solid var(--divider);
|
||||||
border-radius: var(--radius);
|
border-radius: var(--radius);
|
||||||
overflow: clip;
|
overflow: clip;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.sensitive {
|
.sensitive {
|
||||||
|
@ -394,4 +493,15 @@ onDeactivated(() => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.nativeAudioContainer {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nativeAudio {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -6,6 +6,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template>
|
<template>
|
||||||
<div
|
<div
|
||||||
ref="playerEl"
|
ref="playerEl"
|
||||||
|
v-hotkey="keymap"
|
||||||
|
tabindex="0"
|
||||||
:class="[
|
:class="[
|
||||||
$style.videoContainer,
|
$style.videoContainer,
|
||||||
controlsShowing && $style.active,
|
controlsShowing && $style.active,
|
||||||
|
@ -14,15 +16,37 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
@mouseover="onMouseOver"
|
@mouseover="onMouseOver"
|
||||||
@mouseleave="onMouseLeave"
|
@mouseleave="onMouseLeave"
|
||||||
@contextmenu.stop
|
@contextmenu.stop
|
||||||
|
@keydown.stop
|
||||||
>
|
>
|
||||||
<button v-if="hide" :class="$style.hidden" @click="showHiddenContent">
|
<button v-if="hide" :class="$style.hidden" @click="showHiddenContent">
|
||||||
<div :class="$style.hiddenTextWrapper">
|
<div :class="$style.hiddenTextWrapper">
|
||||||
<b v-if="video.isSensitive" style="display: block;"><i class="ti ti-eye-exclamation"></i> {{ i18n.ts.sensitive }}{{ defaultStore.state.dataSaver.media ? ` (${i18n.ts.video}${video.size ? ' ' + bytes(video.size) : ''})` : '' }}</b>
|
<b v-if="video.isSensitive" style="display: block;"><i class="ti ti-eye-exclamation"></i> {{ i18n.ts.sensitive }}{{ defaultStore.state.dataSaver.media ? ` (${i18n.ts.video}${video.size ? ' ' + bytes(video.size) : ''})` : '' }}</b>
|
||||||
<b v-else style="display: block;"><i class="ti ti-photo"></i> {{ defaultStore.state.dataSaver.media && video.size ? bytes(video.size) : i18n.ts.video }}</b>
|
<b v-else style="display: block;"><i class="ti ti-movie"></i> {{ defaultStore.state.dataSaver.media && video.size ? bytes(video.size) : i18n.ts.video }}</b>
|
||||||
<span style="display: block;">{{ i18n.ts.clickToShow }}</span>
|
<span style="display: block;">{{ i18n.ts.clickToShow }}</span>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<div v-else :class="$style.videoRoot" @click.self="togglePlayPause">
|
|
||||||
|
<div v-else-if="defaultStore.reactiveState.useNativeUIForVideoAudioPlayer.value" :class="$style.videoRoot">
|
||||||
|
<video
|
||||||
|
ref="videoEl"
|
||||||
|
:class="$style.video"
|
||||||
|
:poster="video.thumbnailUrl ?? undefined"
|
||||||
|
:title="video.comment ?? undefined"
|
||||||
|
:alt="video.comment"
|
||||||
|
preload="metadata"
|
||||||
|
controls
|
||||||
|
@keydown.prevent
|
||||||
|
>
|
||||||
|
<source :src="video.url">
|
||||||
|
</video>
|
||||||
|
<i class="ti ti-eye-off" :class="$style.hide" @click="hide = true"></i>
|
||||||
|
<div :class="$style.indicators">
|
||||||
|
<div v-if="video.comment" :class="$style.indicator">ALT</div>
|
||||||
|
<div v-if="video.isSensitive" :class="$style.indicator" style="color: var(--warn);" :title="i18n.ts.sensitive"><i class="ti ti-eye-exclamation"></i></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div v-else :class="$style.videoRoot">
|
||||||
<video
|
<video
|
||||||
ref="videoEl"
|
ref="videoEl"
|
||||||
:class="$style.video"
|
:class="$style.video"
|
||||||
|
@ -31,6 +55,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
:alt="video.comment"
|
:alt="video.comment"
|
||||||
preload="metadata"
|
preload="metadata"
|
||||||
playsinline
|
playsinline
|
||||||
|
@keydown.prevent
|
||||||
|
@click.self="togglePlayPause"
|
||||||
>
|
>
|
||||||
<source :src="video.url">
|
<source :src="video.url">
|
||||||
</video>
|
</video>
|
||||||
|
@ -105,6 +131,40 @@ const props = withDefaults(defineProps<{
|
||||||
videoControls: true,
|
videoControls: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const keymap = {
|
||||||
|
'up': () => {
|
||||||
|
if (hasFocus() && videoEl.value) {
|
||||||
|
volume.value = Math.min(volume.value + 0.1, 1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'down': () => {
|
||||||
|
if (hasFocus() && videoEl.value) {
|
||||||
|
volume.value = Math.max(volume.value - 0.1, 0);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'left': () => {
|
||||||
|
if (hasFocus() && videoEl.value) {
|
||||||
|
videoEl.value.currentTime = Math.max(videoEl.value.currentTime - 5, 0);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'right': () => {
|
||||||
|
if (hasFocus() && videoEl.value) {
|
||||||
|
videoEl.value.currentTime = Math.min(videoEl.value.currentTime + 5, videoEl.value.duration);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'space': () => {
|
||||||
|
if (hasFocus()) {
|
||||||
|
togglePlayPause();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// PlayerElもしくはその子要素にフォーカスがあるかどうか
|
||||||
|
function hasFocus() {
|
||||||
|
if (!playerEl.value) return false;
|
||||||
|
return playerEl.value === document.activeElement || playerEl.value.contains(document.activeElement);
|
||||||
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line vue/no-setup-props-destructure
|
// eslint-disable-next-line vue/no-setup-props-destructure
|
||||||
const hide = ref((defaultStore.state.nsfw === 'force' || defaultStore.state.dataSaver.media) ? true : (props.video.isSensitive && defaultStore.state.nsfw !== 'ignore'));
|
const hide = ref((defaultStore.state.nsfw === 'force' || defaultStore.state.dataSaver.media) ? true : (props.video.isSensitive && defaultStore.state.nsfw !== 'ignore'));
|
||||||
|
|
||||||
|
@ -114,6 +174,35 @@ const menuShowing = ref(false);
|
||||||
function showMenu(ev: MouseEvent) {
|
function showMenu(ev: MouseEvent) {
|
||||||
const menu: MenuItem[] = [
|
const menu: MenuItem[] = [
|
||||||
// TODO: 再生キューに追加
|
// TODO: 再生キューに追加
|
||||||
|
{
|
||||||
|
type: 'switch',
|
||||||
|
text: i18n.ts._mediaControls.loop,
|
||||||
|
icon: 'ti ti-repeat',
|
||||||
|
ref: loop,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'radio',
|
||||||
|
text: i18n.ts._mediaControls.playbackRate,
|
||||||
|
icon: 'ti ti-clock-play',
|
||||||
|
ref: speed,
|
||||||
|
options: {
|
||||||
|
'0.25x': 0.25,
|
||||||
|
'0.5x': 0.5,
|
||||||
|
'0.75x': 0.75,
|
||||||
|
'1.0x': 1,
|
||||||
|
'1.25x': 1.25,
|
||||||
|
'1.5x': 1.5,
|
||||||
|
'2.0x': 2,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
...(document.pictureInPictureEnabled ? [{
|
||||||
|
text: i18n.ts._mediaControls.pip,
|
||||||
|
icon: 'ti ti-picture-in-picture',
|
||||||
|
action: togglePictureInPicture,
|
||||||
|
}] : []),
|
||||||
|
{
|
||||||
|
type: 'divider',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
text: i18n.ts.hide,
|
text: i18n.ts.hide,
|
||||||
icon: 'ti ti-eye-off',
|
icon: 'ti ti-eye-off',
|
||||||
|
@ -217,6 +306,8 @@ const rangePercent = computed({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const volume = ref(.25);
|
const volume = ref(.25);
|
||||||
|
const speed = ref(1);
|
||||||
|
const loop = ref(false); // TODO: ドライブファイルのフラグに置き換える
|
||||||
const bufferedEnd = ref(0);
|
const bufferedEnd = ref(0);
|
||||||
const bufferedDataRatio = computed(() => {
|
const bufferedDataRatio = computed(() => {
|
||||||
if (!videoEl.value) return 0;
|
if (!videoEl.value) return 0;
|
||||||
|
@ -274,6 +365,16 @@ function toggleFullscreen() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function togglePictureInPicture() {
|
||||||
|
if (videoEl.value) {
|
||||||
|
if (document.pictureInPictureElement) {
|
||||||
|
document.exitPictureInPicture();
|
||||||
|
} else {
|
||||||
|
videoEl.value.requestPictureInPicture();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function toggleMute() {
|
function toggleMute() {
|
||||||
if (volume.value === 0) {
|
if (volume.value === 0) {
|
||||||
volume.value = .25;
|
volume.value = .25;
|
||||||
|
@ -283,6 +384,7 @@ function toggleMute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
let onceInit = false;
|
let onceInit = false;
|
||||||
|
let mediaTickFrameId: number | null = null;
|
||||||
let stopVideoElWatch: () => void;
|
let stopVideoElWatch: () => void;
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
@ -302,8 +404,12 @@ function init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
elapsedTimeMs.value = videoEl.value.currentTime * 1000;
|
elapsedTimeMs.value = videoEl.value.currentTime * 1000;
|
||||||
|
|
||||||
|
if (videoEl.value.loop !== loop.value) {
|
||||||
|
loop.value = videoEl.value.loop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
window.requestAnimationFrame(updateMediaTick);
|
mediaTickFrameId = window.requestAnimationFrame(updateMediaTick);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateMediaTick();
|
updateMediaTick();
|
||||||
|
@ -347,6 +453,14 @@ watch(volume, (to) => {
|
||||||
if (videoEl.value) videoEl.value.volume = to;
|
if (videoEl.value) videoEl.value.volume = to;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(speed, (to) => {
|
||||||
|
if (videoEl.value) videoEl.value.playbackRate = to;
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(loop, (to) => {
|
||||||
|
if (videoEl.value) videoEl.value.loop = to;
|
||||||
|
});
|
||||||
|
|
||||||
watch(hide, (to) => {
|
watch(hide, (to) => {
|
||||||
if (to && isFullscreen.value) {
|
if (to && isFullscreen.value) {
|
||||||
document.exitFullscreen();
|
document.exitFullscreen();
|
||||||
|
@ -372,6 +486,10 @@ onDeactivated(() => {
|
||||||
hide.value = (defaultStore.state.nsfw === 'force' || defaultStore.state.dataSaver.media) ? true : (props.video.isSensitive && defaultStore.state.nsfw !== 'ignore');
|
hide.value = (defaultStore.state.nsfw === 'force' || defaultStore.state.dataSaver.media) ? true : (props.video.isSensitive && defaultStore.state.nsfw !== 'ignore');
|
||||||
stopVideoElWatch();
|
stopVideoElWatch();
|
||||||
onceInit = false;
|
onceInit = false;
|
||||||
|
if (mediaTickFrameId) {
|
||||||
|
window.cancelAnimationFrame(mediaTickFrameId);
|
||||||
|
mediaTickFrameId = null;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -380,6 +498,10 @@ onDeactivated(() => {
|
||||||
container-type: inline-size;
|
container-type: inline-size;
|
||||||
position: relative;
|
position: relative;
|
||||||
overflow: clip;
|
overflow: clip;
|
||||||
|
|
||||||
|
&:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.sensitive {
|
.sensitive {
|
||||||
|
@ -482,7 +604,6 @@ onDeactivated(() => {
|
||||||
display: block;
|
display: block;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
pointer-events: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.videoOverlayPlayButton {
|
.videoOverlayPlayButton {
|
||||||
|
|
|
@ -4,7 +4,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<MkA v-user-preview="canonical" :class="[$style.root, { [$style.isMe]: isMe }]" :to="url" :style="{ background: bgCss }">
|
<MkA v-user-preview="canonical" :class="[$style.root, { [$style.isMe]: isMe }]" :to="url" :style="{ background: bgCss }" :behavior="behavior">
|
||||||
<img :class="$style.icon" :src="avatarUrl" alt="">
|
<img :class="$style.icon" :src="avatarUrl" alt="">
|
||||||
<span>
|
<span>
|
||||||
<span>@{{ username }}</span>
|
<span>@{{ username }}</span>
|
||||||
|
@ -21,10 +21,12 @@ import { host as localHost } from '@/config.js';
|
||||||
import { $i } from '@/account.js';
|
import { $i } from '@/account.js';
|
||||||
import { defaultStore } from '@/store.js';
|
import { defaultStore } from '@/store.js';
|
||||||
import { getStaticImageUrl } from '@/scripts/media-proxy.js';
|
import { getStaticImageUrl } from '@/scripts/media-proxy.js';
|
||||||
|
import { MkABehavior } from '@/components/global/MkA.vue';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
username: string;
|
username: string;
|
||||||
host: string;
|
host: string;
|
||||||
|
behavior?: MkABehavior;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const canonical = props.host === localHost ? `@${props.username}` : `@${props.username}@${toUnicode(props.host)}`;
|
const canonical = props.host === localHost ? `@${props.username}` : `@${props.username}@${toUnicode(props.host)}`;
|
||||||
|
|
|
@ -42,9 +42,26 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<button v-else-if="item.type === 'switch'" role="menuitemcheckbox" :tabindex="i" class="_button" :class="[$style.item, $style.switch, { [$style.switchDisabled]: item.disabled } ]" @click="switchItem(item)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
|
<button v-else-if="item.type === 'switch'" role="menuitemcheckbox" :tabindex="i" class="_button" :class="[$style.item, $style.switch, { [$style.switchDisabled]: item.disabled } ]" @click="switchItem(item)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
|
||||||
<MkSwitchButton :class="$style.switchButton" :checked="item.ref" :disabled="item.disabled" @toggle="switchItem(item)"/>
|
<i v-if="item.icon" class="ti-fw" :class="[$style.icon, item.icon]"></i>
|
||||||
|
<MkSwitchButton v-else :class="$style.switchButton" :checked="item.ref" :disabled="item.disabled" @toggle="switchItem(item)"/>
|
||||||
<div :class="$style.item_content">
|
<div :class="$style.item_content">
|
||||||
<span :class="[$style.item_content_text, $style.switchText]">{{ item.text }}</span>
|
<span :class="[$style.item_content_text, { [$style.switchText]: !item.icon }]">{{ item.text }}</span>
|
||||||
|
<MkSwitchButton v-if="item.icon" :class="[$style.switchButton, $style.caret]" :checked="item.ref" :disabled="item.disabled" @toggle="switchItem(item)"/>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
<button v-else-if="item.type === 'radio'" class="_button" role="menuitem" :tabindex="i" :class="[$style.item, $style.parent, { [$style.childShowing]: childShowingItem === item }]" @mouseenter="preferClick ? null : showRadioOptions(item, $event)" @click="!preferClick ? null : showRadioOptions(item, $event)">
|
||||||
|
<i v-if="item.icon" class="ti-fw" :class="[$style.icon, item.icon]" style="pointer-events: none;"></i>
|
||||||
|
<div :class="$style.item_content">
|
||||||
|
<span :class="$style.item_content_text" style="pointer-events: none;">{{ item.text }}</span>
|
||||||
|
<span :class="$style.caret" style="pointer-events: none;"><i class="ti ti-chevron-right ti-fw"></i></span>
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
<button v-else-if="item.type === 'radioOption'" :tabindex="i" class="_button" role="menuitem" :class="[$style.item, { [$style.radioActive]: item.active }]" @click="clicked(item.action, $event, false)" @mouseenter.passive="onItemMouseEnter(item)" @mouseleave.passive="onItemMouseLeave(item)">
|
||||||
|
<div :class="$style.icon">
|
||||||
|
<span :class="[$style.radio, { [$style.radioChecked]: item.active }]"></span>
|
||||||
|
</div>
|
||||||
|
<div :class="$style.item_content">
|
||||||
|
<span :class="$style.item_content_text">{{ item.text }}</span>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
<button v-else-if="item.type === 'parent'" class="_button" role="menuitem" :tabindex="i" :class="[$style.item, $style.parent, { [$style.childShowing]: childShowingItem === item }]" @mouseenter="preferClick ? null : showChildren(item, $event)" @click="!preferClick ? null : showChildren(item, $event)">
|
<button v-else-if="item.type === 'parent'" class="_button" role="menuitem" :tabindex="i" :class="[$style.item, $style.parent, { [$style.childShowing]: childShowingItem === item }]" @mouseenter="preferClick ? null : showChildren(item, $event)" @click="!preferClick ? null : showChildren(item, $event)">
|
||||||
|
@ -77,7 +94,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
import { ComputedRef, computed, defineAsyncComponent, isRef, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue';
|
import { ComputedRef, computed, defineAsyncComponent, isRef, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue';
|
||||||
import { focusPrev, focusNext } from '@/scripts/focus.js';
|
import { focusPrev, focusNext } from '@/scripts/focus.js';
|
||||||
import MkSwitchButton from '@/components/MkSwitch.button.vue';
|
import MkSwitchButton from '@/components/MkSwitch.button.vue';
|
||||||
import { MenuItem, InnerMenuItem, MenuPending, MenuAction, MenuSwitch, MenuParent } from '@/types/menu.js';
|
import { MenuItem, InnerMenuItem, MenuPending, MenuAction, MenuSwitch, MenuRadio, MenuRadioOption, MenuParent } from '@/types/menu.js';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { isTouchUsing } from '@/scripts/touch.js';
|
import { isTouchUsing } from '@/scripts/touch.js';
|
||||||
|
@ -168,6 +185,31 @@ function onItemMouseLeave(item) {
|
||||||
if (childCloseTimer) window.clearTimeout(childCloseTimer);
|
if (childCloseTimer) window.clearTimeout(childCloseTimer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function showRadioOptions(item: MenuRadio, ev: MouseEvent) {
|
||||||
|
const children: MenuItem[] = Object.keys(item.options).map<MenuRadioOption>(key => {
|
||||||
|
const value = item.options[key];
|
||||||
|
return {
|
||||||
|
type: 'radioOption',
|
||||||
|
text: key,
|
||||||
|
action: () => {
|
||||||
|
item.ref = value;
|
||||||
|
},
|
||||||
|
active: computed(() => item.ref === value),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
if (props.asDrawer) {
|
||||||
|
os.popupMenu(children, ev.currentTarget ?? ev.target).finally(() => {
|
||||||
|
emit('close');
|
||||||
|
});
|
||||||
|
emit('hide');
|
||||||
|
} else {
|
||||||
|
childTarget.value = (ev.currentTarget ?? ev.target) as HTMLElement;
|
||||||
|
childMenu.value = children;
|
||||||
|
childShowingItem.value = item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function showChildren(item: MenuParent, ev: MouseEvent) {
|
async function showChildren(item: MenuParent, ev: MouseEvent) {
|
||||||
const children: MenuItem[] = await (async () => {
|
const children: MenuItem[] = await (async () => {
|
||||||
if (childrenCache.has(item)) {
|
if (childrenCache.has(item)) {
|
||||||
|
@ -196,8 +238,10 @@ async function showChildren(item: MenuParent, ev: MouseEvent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function clicked(fn: MenuAction, ev: MouseEvent) {
|
function clicked(fn: MenuAction, ev: MouseEvent, doClose = true) {
|
||||||
fn(ev);
|
fn(ev);
|
||||||
|
|
||||||
|
if (!doClose) return;
|
||||||
close(true);
|
close(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,6 +394,15 @@ onBeforeUnmount(() => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.radioActive {
|
||||||
|
color: var(--accent) !important;
|
||||||
|
opacity: 1;
|
||||||
|
|
||||||
|
&:before {
|
||||||
|
background-color: var(--accentedBg) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&:not(:active):focus-visible {
|
&:not(:active):focus-visible {
|
||||||
box-shadow: 0 0 0 2px var(--focus) inset;
|
box-shadow: 0 0 0 2px var(--focus) inset;
|
||||||
}
|
}
|
||||||
|
@ -417,11 +470,11 @@ onBeforeUnmount(() => {
|
||||||
|
|
||||||
.switchButton {
|
.switchButton {
|
||||||
margin-left: -2px;
|
margin-left: -2px;
|
||||||
|
--height: 1.35em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.switchText {
|
.switchText {
|
||||||
margin-left: 8px;
|
margin-left: 8px;
|
||||||
margin-top: 2px;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
@ -461,4 +514,32 @@ onBeforeUnmount(() => {
|
||||||
margin: 8px 0;
|
margin: 8px 0;
|
||||||
border-top: solid 0.5px var(--divider);
|
border-top: solid 0.5px var(--divider);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.radio {
|
||||||
|
display: inline-block;
|
||||||
|
position: relative;
|
||||||
|
width: 1em;
|
||||||
|
height: 1em;
|
||||||
|
vertical-align: -.125em;
|
||||||
|
border-radius: 50%;
|
||||||
|
border: solid 2px var(--divider);
|
||||||
|
background-color: var(--panel);
|
||||||
|
|
||||||
|
&.radioChecked {
|
||||||
|
border-color: var(--accent);
|
||||||
|
|
||||||
|
&::after {
|
||||||
|
content: "";
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
width: 50%;
|
||||||
|
height: 50%;
|
||||||
|
border-radius: 50%;
|
||||||
|
background-color: var(--accent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -237,6 +237,7 @@ if (noteViewInterruptors.length > 0) {
|
||||||
|
|
||||||
const isRenote = (
|
const isRenote = (
|
||||||
note.value.renote != null &&
|
note.value.renote != null &&
|
||||||
|
note.value.reply == null &&
|
||||||
note.value.text == null &&
|
note.value.text == null &&
|
||||||
note.value.cw == null &&
|
note.value.cw == null &&
|
||||||
note.value.fileIds && note.value.fileIds.length === 0 &&
|
note.value.fileIds && note.value.fileIds.length === 0 &&
|
||||||
|
|
|
@ -68,7 +68,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<div :class="$style.noteContent">
|
<div :class="$style.noteContent">
|
||||||
<p v-if="appearNote.cw != null" :class="$style.cw">
|
<p v-if="appearNote.cw != null" :class="$style.cw">
|
||||||
<Mfm v-if="appearNote.cw != ''" style="margin-right: 8px;" :text="appearNote.cw" :author="appearNote.user" :nyaize="'respect'"/>
|
<Mfm v-if="appearNote.cw != ''" style="margin-right: 8px;" :text="appearNote.cw" :author="appearNote.user" :nyaize="'respect'"/>
|
||||||
<MkCwButton v-model="showContent" :text="appearNote.text" :files="appearNote.files" :poll="appearNote.poll"/>
|
<MkCwButton v-model="showContent" :text="appearNote.text" :renote="appearNote.renote" :files="appearNote.files" :poll="appearNote.poll"/>
|
||||||
</p>
|
</p>
|
||||||
<div v-show="appearNote.cw == null || showContent">
|
<div v-show="appearNote.cw == null || showContent">
|
||||||
<span v-if="appearNote.isHidden" style="opacity: 0.5">({{ i18n.ts.private }})</span>
|
<span v-if="appearNote.isHidden" style="opacity: 0.5">({{ i18n.ts.private }})</span>
|
||||||
|
@ -267,7 +267,9 @@ if (noteViewInterruptors.length > 0) {
|
||||||
|
|
||||||
const isRenote = (
|
const isRenote = (
|
||||||
note.value.renote != null &&
|
note.value.renote != null &&
|
||||||
|
note.value.reply == null &&
|
||||||
note.value.text == null &&
|
note.value.text == null &&
|
||||||
|
note.value.cw == null &&
|
||||||
note.value.fileIds && note.value.fileIds.length === 0 &&
|
note.value.fileIds && note.value.fileIds.length === 0 &&
|
||||||
note.value.poll == null
|
note.value.poll == null
|
||||||
);
|
);
|
||||||
|
|
|
@ -58,8 +58,8 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<span v-else-if="notification.type === 'achievementEarned'">{{ i18n.ts._notification.achievementEarned }}</span>
|
<span v-else-if="notification.type === 'achievementEarned'">{{ i18n.ts._notification.achievementEarned }}</span>
|
||||||
<span v-else-if="notification.type === 'test'">{{ i18n.ts._notification.testNotification }}</span>
|
<span v-else-if="notification.type === 'test'">{{ i18n.ts._notification.testNotification }}</span>
|
||||||
<MkA v-else-if="notification.type === 'follow' || notification.type === 'mention' || notification.type === 'reply' || notification.type === 'renote' || notification.type === 'quote' || notification.type === 'reaction' || notification.type === 'receiveFollowRequest' || notification.type === 'followRequestAccepted'" v-user-preview="notification.user.id" :class="$style.headerName" :to="userPage(notification.user)"><MkUserName :user="notification.user"/></MkA>
|
<MkA v-else-if="notification.type === 'follow' || notification.type === 'mention' || notification.type === 'reply' || notification.type === 'renote' || notification.type === 'quote' || notification.type === 'reaction' || notification.type === 'receiveFollowRequest' || notification.type === 'followRequestAccepted'" v-user-preview="notification.user.id" :class="$style.headerName" :to="userPage(notification.user)"><MkUserName :user="notification.user"/></MkA>
|
||||||
<span v-else-if="notification.type === 'reaction:grouped' && notification.note.reactionAcceptance === 'likeOnly'">{{ i18n.tsx._notification.likedBySomeUsers({ n: notification.reactions.length }) }}</span>
|
<span v-else-if="notification.type === 'reaction:grouped' && notification.note.reactionAcceptance === 'likeOnly'">{{ i18n.tsx._notification.likedBySomeUsers({ n: getActualReactedUsersCount(notification) }) }}</span>
|
||||||
<span v-else-if="notification.type === 'reaction:grouped'">{{ i18n.tsx._notification.reactedBySomeUsers({ n: notification.reactions.length }) }}</span>
|
<span v-else-if="notification.type === 'reaction:grouped'">{{ i18n.tsx._notification.reactedBySomeUsers({ n: getActualReactedUsersCount(notification) }) }}</span>
|
||||||
<span v-else-if="notification.type === 'renote:grouped'">{{ i18n.tsx._notification.renotedBySomeUsers({ n: notification.users.length }) }}</span>
|
<span v-else-if="notification.type === 'renote:grouped'">{{ i18n.tsx._notification.renotedBySomeUsers({ n: notification.users.length }) }}</span>
|
||||||
<span v-else-if="notification.type === 'app'">{{ notification.header }}</span>
|
<span v-else-if="notification.type === 'app'">{{ notification.header }}</span>
|
||||||
<MkTime v-if="withTime" :time="notification.createdAt" :class="$style.headerTime"/>
|
<MkTime v-if="withTime" :time="notification.createdAt" :class="$style.headerTime"/>
|
||||||
|
@ -72,7 +72,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</MkA>
|
</MkA>
|
||||||
<MkA v-else-if="notification.type === 'renote' || notification.type === 'renote:grouped'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note.renote)">
|
<MkA v-else-if="notification.type === 'renote' || notification.type === 'renote:grouped'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note.renote)">
|
||||||
<i class="ti ti-quote" :class="$style.quote"></i>
|
<i class="ti ti-quote" :class="$style.quote"></i>
|
||||||
<Mfm :text="getNoteSummary(notification.note.renote)" :plain="true" :nowrap="true" :author="notification.note.renote.user"/>
|
<Mfm :text="getNoteSummary(notification.note.renote)" :plain="true" :nowrap="true" :author="notification.note.renote?.user"/>
|
||||||
<i class="ti ti-quote" :class="$style.quote"></i>
|
<i class="ti ti-quote" :class="$style.quote"></i>
|
||||||
</MkA>
|
</MkA>
|
||||||
<MkA v-else-if="notification.type === 'reply'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
|
<MkA v-else-if="notification.type === 'reply'" :class="$style.text" :to="notePage(notification.note)" :title="getNoteSummary(notification.note)">
|
||||||
|
@ -176,6 +176,11 @@ const rejectFollowRequest = () => {
|
||||||
followRequestDone.value = true;
|
followRequestDone.value = true;
|
||||||
misskeyApi('following/requests/reject', { userId: props.notification.user.id });
|
misskeyApi('following/requests/reject', { userId: props.notification.user.id });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function getActualReactedUsersCount(notification: Misskey.entities.Notification) {
|
||||||
|
if (notification.type !== 'reaction:grouped') return 0;
|
||||||
|
return new Set(notification.reactions.map((reaction) => reaction.user.id)).size;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" module>
|
<style lang="scss" module>
|
||||||
|
|
|
@ -260,7 +260,13 @@ const maxTextLength = computed((): number => {
|
||||||
|
|
||||||
const canPost = computed((): boolean => {
|
const canPost = computed((): boolean => {
|
||||||
return !props.mock && !posting.value && !posted.value &&
|
return !props.mock && !posting.value && !posted.value &&
|
||||||
(1 <= textLength.value || 1 <= files.value.length || !!poll.value || !!props.renote) &&
|
(
|
||||||
|
1 <= textLength.value ||
|
||||||
|
1 <= files.value.length ||
|
||||||
|
poll.value != null ||
|
||||||
|
props.renote != null ||
|
||||||
|
(props.reply != null && quoteId.value != null)
|
||||||
|
) &&
|
||||||
(textLength.value <= maxTextLength.value) &&
|
(textLength.value <= maxTextLength.value) &&
|
||||||
(!poll.value || poll.value.choices.length >= 2);
|
(!poll.value || poll.value.choices.length >= 2);
|
||||||
});
|
});
|
||||||
|
@ -389,7 +395,7 @@ function addMissingMention() {
|
||||||
for (const x of extractMentions(ast)) {
|
for (const x of extractMentions(ast)) {
|
||||||
if (!visibleUsers.value.some(u => (u.username === x.username) && (u.host === x.host))) {
|
if (!visibleUsers.value.some(u => (u.username === x.username) && (u.host === x.host))) {
|
||||||
misskeyApi('users/show', { username: x.username, host: x.host }).then(user => {
|
misskeyApi('users/show', { username: x.username, host: x.host }).then(user => {
|
||||||
visibleUsers.value.push(user);
|
pushVisibleUser(user);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -682,6 +688,7 @@ function saveDraft() {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
||||||
files: files.value.filter(f => f?.id && f.type && f.name),
|
files: files.value.filter(f => f?.id && f.type && f.name),
|
||||||
poll: poll.value,
|
poll: poll.value,
|
||||||
|
visibleUserIds: visibility.value === 'specified' ? visibleUsers.value.map(x => x.id) : undefined,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -958,6 +965,15 @@ onMounted(() => {
|
||||||
if (draft.data.poll) {
|
if (draft.data.poll) {
|
||||||
poll.value = draft.data.poll;
|
poll.value = draft.data.poll;
|
||||||
}
|
}
|
||||||
|
if (draft.data.visibleUserIds) {
|
||||||
|
misskeyApi('users/show', { userIds: draft.data.visibleUserIds }).then(users => {
|
||||||
|
for (let i = 0; i < users.length; i++) {
|
||||||
|
if (users[i].id === draft.data.visibleUserIds[i]) {
|
||||||
|
pushVisibleUser(users[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,7 @@ watch([() => props.note.reactions, () => props.maxNumber], ([newSource, maxNumbe
|
||||||
.root {
|
.root {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
margin: 4px -2px 0 -2px;
|
margin: 4px -2px 0 -2px;
|
||||||
|
|
||||||
&:empty {
|
&:empty {
|
||||||
|
|
|
@ -41,13 +41,15 @@ const toggle = () => {
|
||||||
|
|
||||||
<style lang="scss" module>
|
<style lang="scss" module>
|
||||||
.button {
|
.button {
|
||||||
|
--height: 21px;
|
||||||
|
|
||||||
position: relative;
|
position: relative;
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
width: 32px;
|
width: calc(var(--height) * 1.6);
|
||||||
height: 23px;
|
height: calc(var(--height) + 2px); // 枠線
|
||||||
outline: none;
|
outline: none;
|
||||||
background: var(--switchOffBg);
|
background: var(--switchOffBg);
|
||||||
background-clip: content-box;
|
background-clip: content-box;
|
||||||
|
@ -69,9 +71,10 @@ const toggle = () => {
|
||||||
|
|
||||||
.knob {
|
.knob {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
box-sizing: border-box;
|
||||||
top: 3px;
|
top: 3px;
|
||||||
width: 15px;
|
width: calc(var(--height) - 6px);
|
||||||
height: 15px;
|
height: calc(var(--height) - 6px);
|
||||||
border-radius: 999px;
|
border-radius: 999px;
|
||||||
transition: all 0.2s ease;
|
transition: all 0.2s ease;
|
||||||
|
|
||||||
|
@ -82,7 +85,7 @@ const toggle = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
.knobChecked {
|
.knobChecked {
|
||||||
left: 12px;
|
left: calc(calc(100% - var(--height)) + 3px);
|
||||||
background: var(--switchOnFg);
|
background: var(--switchOnFg);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -9,6 +9,10 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export type MkABehavior = 'window' | 'browser' | null;
|
||||||
|
</script>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, shallowRef } from 'vue';
|
import { computed, shallowRef } from 'vue';
|
||||||
import * as os from '@/os.js';
|
import * as os from '@/os.js';
|
||||||
|
@ -20,12 +24,14 @@ import { useRouter } from '@/router/supplier.js';
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
to: string;
|
to: string;
|
||||||
activeClass?: null | string;
|
activeClass?: null | string;
|
||||||
behavior?: null | 'window' | 'browser';
|
behavior?: MkABehavior;
|
||||||
}>(), {
|
}>(), {
|
||||||
activeClass: null,
|
activeClass: null,
|
||||||
behavior: null,
|
behavior: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const linkBehaviour = props.behavior;
|
||||||
|
|
||||||
const el = shallowRef<HTMLElement>();
|
const el = shallowRef<HTMLElement>();
|
||||||
|
|
||||||
defineExpose({ $el: el });
|
defineExpose({ $el: el });
|
||||||
|
|
|
@ -16,7 +16,7 @@ import MkCode from '@/components/MkCode.vue';
|
||||||
import MkCodeInline from '@/components/MkCodeInline.vue';
|
import MkCodeInline from '@/components/MkCodeInline.vue';
|
||||||
import MkGoogle from '@/components/MkGoogle.vue';
|
import MkGoogle from '@/components/MkGoogle.vue';
|
||||||
import MkSparkle from '@/components/MkSparkle.vue';
|
import MkSparkle from '@/components/MkSparkle.vue';
|
||||||
import MkA from '@/components/global/MkA.vue';
|
import MkA, { MkABehavior } from '@/components/global/MkA.vue';
|
||||||
import { host } from '@/config.js';
|
import { host } from '@/config.js';
|
||||||
import { defaultStore } from '@/store.js';
|
import { defaultStore } from '@/store.js';
|
||||||
import { nyaize as doNyaize } from '@/scripts/nyaize.js';
|
import { nyaize as doNyaize } from '@/scripts/nyaize.js';
|
||||||
|
@ -43,6 +43,7 @@ type MfmProps = {
|
||||||
parsedNodes?: mfm.MfmNode[] | null;
|
parsedNodes?: mfm.MfmNode[] | null;
|
||||||
enableEmojiMenu?: boolean;
|
enableEmojiMenu?: boolean;
|
||||||
enableEmojiMenuReaction?: boolean;
|
enableEmojiMenuReaction?: boolean;
|
||||||
|
linkBehavior?: MkABehavior;
|
||||||
};
|
};
|
||||||
|
|
||||||
type MfmEvents = {
|
type MfmEvents = {
|
||||||
|
@ -342,6 +343,7 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
|
||||||
key: Math.random(),
|
key: Math.random(),
|
||||||
url: token.props.url,
|
url: token.props.url,
|
||||||
rel: 'nofollow noopener',
|
rel: 'nofollow noopener',
|
||||||
|
behavior: props.linkBehavior,
|
||||||
})];
|
})];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,6 +352,7 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
|
||||||
key: Math.random(),
|
key: Math.random(),
|
||||||
url: token.props.url,
|
url: token.props.url,
|
||||||
rel: 'nofollow noopener',
|
rel: 'nofollow noopener',
|
||||||
|
behavior: props.linkBehavior,
|
||||||
}, genEl(token.children, scale, true))];
|
}, genEl(token.children, scale, true))];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,6 +361,7 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
|
||||||
key: Math.random(),
|
key: Math.random(),
|
||||||
host: (token.props.host == null && props.author?.host ? props.author.host : token.props.host) ?? host,
|
host: (token.props.host == null && props.author?.host ? props.author.host : token.props.host) ?? host,
|
||||||
username: token.props.username,
|
username: token.props.username,
|
||||||
|
behavior: props.linkBehavior,
|
||||||
})];
|
})];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -366,6 +370,7 @@ export default function (props: MfmProps, { emit }: { emit: SetupContext<MfmEven
|
||||||
key: Math.random(),
|
key: Math.random(),
|
||||||
to: isNote ? `/tags/${encodeURIComponent(token.props.hashtag)}` : `/user-tags/${encodeURIComponent(token.props.hashtag)}`,
|
to: isNote ? `/tags/${encodeURIComponent(token.props.hashtag)}` : `/user-tags/${encodeURIComponent(token.props.hashtag)}`,
|
||||||
style: 'color:var(--hashtag);',
|
style: 'color:var(--hashtag);',
|
||||||
|
behavior: props.linkBehavior,
|
||||||
}, `#${token.props.hashtag}`)];
|
}, `#${token.props.hashtag}`)];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ const invalid = Number.isNaN(_time);
|
||||||
const absolute = !invalid ? dateTimeFormat.format(_time) : i18n.ts._ago.invalid;
|
const absolute = !invalid ? dateTimeFormat.format(_time) : i18n.ts._ago.invalid;
|
||||||
|
|
||||||
// eslint-disable-next-line vue/no-setup-props-destructure
|
// eslint-disable-next-line vue/no-setup-props-destructure
|
||||||
const now = ref((props.origin ?? new Date()).getTime());
|
const now = ref(props.origin?.getTime() ?? Date.now());
|
||||||
const ago = computed(() => (now.value - _time) / 1000/*ms*/);
|
const ago = computed(() => (now.value - _time) / 1000/*ms*/);
|
||||||
|
|
||||||
const relative = computed<string>(() => {
|
const relative = computed<string>(() => {
|
||||||
|
@ -77,7 +77,7 @@ let tickId: number;
|
||||||
let currentInterval: number;
|
let currentInterval: number;
|
||||||
|
|
||||||
function tick() {
|
function tick() {
|
||||||
now.value = (new Date()).getTime();
|
now.value = Date.now();
|
||||||
const nextInterval = ago.value < 60 ? 10000 : ago.value < 3600 ? 60000 : 180000;
|
const nextInterval = ago.value < 60 ? 10000 : ago.value < 3600 ? 60000 : 180000;
|
||||||
|
|
||||||
if (currentInterval !== nextInterval) {
|
if (currentInterval !== nextInterval) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
:[attr]="self ? props.url.substring(local.length) : props.url"
|
:[attr]="self ? props.url.substring(local.length) : props.url"
|
||||||
:rel="rel ?? 'nofollow noopener'"
|
:rel="rel ?? 'nofollow noopener'"
|
||||||
:target="target"
|
:target="target"
|
||||||
|
:behavior = "props.behavior"
|
||||||
@click="(ev: MouseEvent) => warningExternalWebsite(ev, props.url)"
|
@click="(ev: MouseEvent) => warningExternalWebsite(ev, props.url)"
|
||||||
@contextmenu.stop="() => {}"
|
@contextmenu.stop="() => {}"
|
||||||
>
|
>
|
||||||
|
@ -39,11 +40,13 @@ import { useTooltip } from '@/scripts/use-tooltip.js';
|
||||||
import { safeURIDecode } from '@/scripts/safe-uri-decode.js';
|
import { safeURIDecode } from '@/scripts/safe-uri-decode.js';
|
||||||
import { warningExternalWebsite } from '@/scripts/warning-external-website.js';
|
import { warningExternalWebsite } from '@/scripts/warning-external-website.js';
|
||||||
import { isEnabledUrlPreview } from '@/instance.js';
|
import { isEnabledUrlPreview } from '@/instance.js';
|
||||||
|
import { MkABehavior } from '@/components/global/MkA.vue';
|
||||||
|
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
url: string;
|
url: string;
|
||||||
rel?: string;
|
rel?: string;
|
||||||
showUrlPreview?: boolean;
|
showUrlPreview?: boolean;
|
||||||
|
behavior?: MkABehavior;
|
||||||
}>(), {
|
}>(), {
|
||||||
showUrlPreview: true,
|
showUrlPreview: true,
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,6 +14,7 @@ import XText from './page.text.vue';
|
||||||
import XSection from './page.section.vue';
|
import XSection from './page.section.vue';
|
||||||
import XImage from './page.image.vue';
|
import XImage from './page.image.vue';
|
||||||
import XNote from './page.note.vue';
|
import XNote from './page.note.vue';
|
||||||
|
import XDynamic from './page.dynamic.vue';
|
||||||
|
|
||||||
function getComponent(type: string) {
|
function getComponent(type: string) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -21,6 +22,20 @@ function getComponent(type: string) {
|
||||||
case 'section': return XSection;
|
case 'section': return XSection;
|
||||||
case 'image': return XImage;
|
case 'image': return XImage;
|
||||||
case 'note': return XNote;
|
case 'note': return XNote;
|
||||||
|
|
||||||
|
// 動的ページの代替用ブロック
|
||||||
|
case 'button':
|
||||||
|
case 'if':
|
||||||
|
case 'textarea':
|
||||||
|
case 'post':
|
||||||
|
case 'canvas':
|
||||||
|
case 'numberInput':
|
||||||
|
case 'textInput':
|
||||||
|
case 'switch':
|
||||||
|
case 'radioButton':
|
||||||
|
case 'counter':
|
||||||
|
return XDynamic;
|
||||||
|
|
||||||
default: return null;
|
default: return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
43
packages/frontend/src/components/page/page.dynamic.vue
Normal file
43
packages/frontend/src/components/page/page.dynamic.vue
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
<!--
|
||||||
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
||||||
|
SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- 動的ページのブロックの代替。利用できないということを表示する -->
|
||||||
|
<template>
|
||||||
|
<div :class="$style.root">
|
||||||
|
<div :class="$style.heading"><i class="ti ti-dice-5"></i> {{ i18n.ts._pages.blocks.dynamic }}</div>
|
||||||
|
<I18n :src="i18n.ts._pages.blocks.dynamicDescription" tag="div" :class="$style.text">
|
||||||
|
<template #play>
|
||||||
|
<MkA to="/play" class="_link">Play</MkA>
|
||||||
|
</template>
|
||||||
|
</I18n>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import * as Misskey from 'misskey-js';
|
||||||
|
import { i18n } from '@/i18n.js';
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
block: Misskey.entities.PageBlock,
|
||||||
|
page: Misskey.entities.Page,
|
||||||
|
}>();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" module>
|
||||||
|
.root {
|
||||||
|
border: 1px solid var(--divider);
|
||||||
|
border-radius: var(--radius);
|
||||||
|
padding: var(--margin);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heading {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text {
|
||||||
|
font-size: 90%;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template>
|
<template>
|
||||||
<div class="_gaps" :class="$style.textRoot">
|
<div class="_gaps" :class="$style.textRoot">
|
||||||
<Mfm :text="block.text ?? ''" :isNote="false"/>
|
<Mfm :text="block.text ?? ''" :isNote="false"/>
|
||||||
<div v-if="isEnabledUrlPreview">
|
<div v-if="isEnabledUrlPreview" class="_gaps_s">
|
||||||
<MkUrlPreview v-for="url in urls" :key="url" :url="url"/>
|
<MkUrlPreview v-for="url in urls" :key="url" :url="url"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -9,6 +9,11 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<MkSelect v-model="type" :class="$style.typeSelect">
|
<MkSelect v-model="type" :class="$style.typeSelect">
|
||||||
<option value="isLocal">{{ i18n.ts._role._condition.isLocal }}</option>
|
<option value="isLocal">{{ i18n.ts._role._condition.isLocal }}</option>
|
||||||
<option value="isRemote">{{ i18n.ts._role._condition.isRemote }}</option>
|
<option value="isRemote">{{ i18n.ts._role._condition.isRemote }}</option>
|
||||||
|
<option value="isSuspended">{{ i18n.ts._role._condition.isSuspended }}</option>
|
||||||
|
<option value="isLocked">{{ i18n.ts._role._condition.isLocked }}</option>
|
||||||
|
<option value="isBot">{{ i18n.ts._role._condition.isBot }}</option>
|
||||||
|
<option value="isCat">{{ i18n.ts._role._condition.isCat }}</option>
|
||||||
|
<option value="isExplorable">{{ i18n.ts._role._condition.isExplorable }}</option>
|
||||||
<option value="roleAssignedTo">{{ i18n.ts._role._condition.roleAssignedTo }}</option>
|
<option value="roleAssignedTo">{{ i18n.ts._role._condition.roleAssignedTo }}</option>
|
||||||
<option value="createdLessThan">{{ i18n.ts._role._condition.createdLessThan }}</option>
|
<option value="createdLessThan">{{ i18n.ts._role._condition.createdLessThan }}</option>
|
||||||
<option value="createdMoreThan">{{ i18n.ts._role._condition.createdMoreThan }}</option>
|
<option value="createdMoreThan">{{ i18n.ts._role._condition.createdMoreThan }}</option>
|
||||||
|
|
|
@ -9,11 +9,16 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<MkSpacer :contentMax="800">
|
<MkSpacer :contentMax="800">
|
||||||
<div v-if="clip" class="_gaps">
|
<div v-if="clip" class="_gaps">
|
||||||
<div class="_panel">
|
<div class="_panel">
|
||||||
<div v-if="clip.description" :class="$style.description">
|
<div class="_gaps_s" :class="$style.description">
|
||||||
<Mfm :text="clip.description" :isNote="false"/>
|
<div v-if="clip.description">
|
||||||
|
<Mfm :text="clip.description" :isNote="false"/>
|
||||||
|
</div>
|
||||||
|
<div v-else>({{ i18n.ts.noDescription }})</div>
|
||||||
|
<div>
|
||||||
|
<MkButton v-if="favorited" v-tooltip="i18n.ts.unfavorite" asLike rounded primary @click="unfavorite()"><i class="ti ti-heart"></i><span v-if="clip.favoritedCount > 0" style="margin-left: 6px;">{{ clip.favoritedCount }}</span></MkButton>
|
||||||
|
<MkButton v-else v-tooltip="i18n.ts.favorite" asLike rounded @click="favorite()"><i class="ti ti-heart"></i><span v-if="clip.favoritedCount > 0" style="margin-left: 6px;">{{ clip.favoritedCount }}</span></MkButton>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<MkButton v-if="favorited" v-tooltip="i18n.ts.unfavorite" asLike rounded primary @click="unfavorite()"><i class="ti ti-heart"></i><span v-if="clip.favoritedCount > 0" style="margin-left: 6px;">{{ clip.favoritedCount }}</span></MkButton>
|
|
||||||
<MkButton v-else v-tooltip="i18n.ts.favorite" asLike rounded @click="favorite()"><i class="ti ti-heart"></i><span v-if="clip.favoritedCount > 0" style="margin-left: 6px;">{{ clip.favoritedCount }}</span></MkButton>
|
|
||||||
<div :class="$style.user">
|
<div :class="$style.user">
|
||||||
<MkAvatar :user="clip.user" :class="$style.avatar" indicator link preview/> <MkUserName :user="clip.user" :nowrap="false"/>
|
<MkAvatar :user="clip.user" :class="$style.avatar" indicator link preview/> <MkUserName :user="clip.user" :nowrap="false"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -48,7 +48,7 @@ import MkInput from '@/components/MkInput.vue';
|
||||||
import MkSelect from '@/components/MkSelect.vue';
|
import MkSelect from '@/components/MkSelect.vue';
|
||||||
import { useRouter } from '@/router/supplier.js';
|
import { useRouter } from '@/router/supplier.js';
|
||||||
|
|
||||||
const PRESET_DEFAULT = `/// @ 0.16.0
|
const PRESET_DEFAULT = `/// @ 0.18.0
|
||||||
|
|
||||||
var name = ""
|
var name = ""
|
||||||
|
|
||||||
|
@ -60,13 +60,13 @@ Ui:render([
|
||||||
Ui:C:button({
|
Ui:C:button({
|
||||||
text: "Hello"
|
text: "Hello"
|
||||||
onClick: @() {
|
onClick: @() {
|
||||||
Mk:dialog(null \`Hello, {name}!\`)
|
Mk:dialog(null, \`Hello, {name}!\`)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
])
|
])
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const PRESET_OMIKUJI = `/// @ 0.16.0
|
const PRESET_OMIKUJI = `/// @ 0.18.0
|
||||||
// ユーザーごとに日替わりのおみくじのプリセット
|
// ユーザーごとに日替わりのおみくじのプリセット
|
||||||
|
|
||||||
// 選択肢
|
// 選択肢
|
||||||
|
@ -81,11 +81,11 @@ let choices = [
|
||||||
"大凶"
|
"大凶"
|
||||||
]
|
]
|
||||||
|
|
||||||
// シードが「ユーザーID+今日の日付」である乱数生成器を用意
|
// シードが「PlayID+ユーザーID+今日の日付」である乱数生成器を用意
|
||||||
let random = Math:gen_rng(\`{USER_ID}{Date:year()}{Date:month()}{Date:day()}\`)
|
let random = Math:gen_rng(\`{THIS_ID}{USER_ID}{Date:year()}{Date:month()}{Date:day()}\`)
|
||||||
|
|
||||||
// ランダムに選択肢を選ぶ
|
// ランダムに選択肢を選ぶ
|
||||||
let chosen = choices[random(0 (choices.len - 1))]
|
let chosen = choices[random(0, (choices.len - 1))]
|
||||||
|
|
||||||
// 結果のテキスト
|
// 結果のテキスト
|
||||||
let result = \`今日のあなたの運勢は **{chosen}** です。\`
|
let result = \`今日のあなたの運勢は **{chosen}** です。\`
|
||||||
|
@ -109,7 +109,7 @@ Ui:render([
|
||||||
])
|
])
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const PRESET_SHUFFLE = `/// @ 0.16.0
|
const PRESET_SHUFFLE = `/// @ 0.18.0
|
||||||
// 巻き戻し可能な文字シャッフルのプリセット
|
// 巻き戻し可能な文字シャッフルのプリセット
|
||||||
|
|
||||||
let string = "ペペロンチーノ"
|
let string = "ペペロンチーノ"
|
||||||
|
@ -123,13 +123,13 @@ var cursor = 0
|
||||||
|
|
||||||
@do() {
|
@do() {
|
||||||
if (cursor != 0) {
|
if (cursor != 0) {
|
||||||
results = results.slice(0 (cursor + 1))
|
results = results.slice(0, (cursor + 1))
|
||||||
cursor = 0
|
cursor = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
let chars = []
|
let chars = []
|
||||||
for (let i, length) {
|
for (let i, length) {
|
||||||
let r = Math:rnd(0 (length - 1))
|
let r = Math:rnd(0, (length - 1))
|
||||||
chars.push(string.pick(r))
|
chars.push(string.pick(r))
|
||||||
}
|
}
|
||||||
let result = chars.join("")
|
let result = chars.join("")
|
||||||
|
@ -163,11 +163,11 @@ var cursor = 0
|
||||||
text: "←"
|
text: "←"
|
||||||
disabled: !(results.len > 1 && (results.len - cursor) > 1)
|
disabled: !(results.len > 1 && (results.len - cursor) > 1)
|
||||||
onClick: back
|
onClick: back
|
||||||
} {
|
}, {
|
||||||
text: "→"
|
text: "→"
|
||||||
disabled: !(results.len > 1 && cursor > 0)
|
disabled: !(results.len > 1 && cursor > 0)
|
||||||
onClick: forward
|
onClick: forward
|
||||||
} {
|
}, {
|
||||||
text: "引き直す"
|
text: "引き直す"
|
||||||
onClick: do
|
onClick: do
|
||||||
}]
|
}]
|
||||||
|
@ -188,27 +188,27 @@ var cursor = 0
|
||||||
do()
|
do()
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const PRESET_QUIZ = `/// @ 0.16.0
|
const PRESET_QUIZ = `/// @ 0.18.0
|
||||||
let title = '地理クイズ'
|
let title = '地理クイズ'
|
||||||
|
|
||||||
let qas = [{
|
let qas = [{
|
||||||
q: 'オーストラリアの首都は?'
|
q: 'オーストラリアの首都は?'
|
||||||
choices: ['シドニー' 'キャンベラ' 'メルボルン']
|
choices: ['シドニー', 'キャンベラ', 'メルボルン']
|
||||||
a: 'キャンベラ'
|
a: 'キャンベラ'
|
||||||
aDescription: '最大の都市はシドニーですが首都はキャンベラです。'
|
aDescription: '最大の都市はシドニーですが首都はキャンベラです。'
|
||||||
} {
|
}, {
|
||||||
q: '国土面積2番目の国は?'
|
q: '国土面積2番目の国は?'
|
||||||
choices: ['カナダ' 'アメリカ' '中国']
|
choices: ['カナダ', 'アメリカ', '中国']
|
||||||
a: 'カナダ'
|
a: 'カナダ'
|
||||||
aDescription: '大きい順にロシア、カナダ、アメリカ、中国です。'
|
aDescription: '大きい順にロシア、カナダ、アメリカ、中国です。'
|
||||||
} {
|
}, {
|
||||||
q: '二重内陸国ではないのは?'
|
q: '二重内陸国ではないのは?'
|
||||||
choices: ['リヒテンシュタイン' 'ウズベキスタン' 'レソト']
|
choices: ['リヒテンシュタイン', 'ウズベキスタン', 'レソト']
|
||||||
a: 'レソト'
|
a: 'レソト'
|
||||||
aDescription: 'レソトは(一重)内陸国です。'
|
aDescription: 'レソトは(一重)内陸国です。'
|
||||||
} {
|
}, {
|
||||||
q: '閘門がない運河は?'
|
q: '閘門がない運河は?'
|
||||||
choices: ['キール運河' 'スエズ運河' 'パナマ運河']
|
choices: ['キール運河', 'スエズ運河', 'パナマ運河']
|
||||||
a: 'スエズ運河'
|
a: 'スエズ運河'
|
||||||
aDescription: 'スエズ運河は高低差がないので閘門はありません。'
|
aDescription: 'スエズ運河は高低差がないので閘門はありません。'
|
||||||
}]
|
}]
|
||||||
|
@ -244,9 +244,9 @@ each (let qa, qas) {
|
||||||
})
|
})
|
||||||
Ui:C:container({
|
Ui:C:container({
|
||||||
children: []
|
children: []
|
||||||
} \`{qa.id}:a\`)
|
}, \`{qa.id}:a\`)
|
||||||
]
|
]
|
||||||
} qa.id))
|
}, qa.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
@finish() {
|
@finish() {
|
||||||
|
@ -296,12 +296,12 @@ qaEls.push(Ui:C:container({
|
||||||
onClick: finish
|
onClick: finish
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
} 'footer'))
|
}, 'footer'))
|
||||||
|
|
||||||
Ui:render(qaEls)
|
Ui:render(qaEls)
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const PRESET_TIMELINE = `/// @ 0.16.0
|
const PRESET_TIMELINE = `/// @ 0.18.0
|
||||||
// APIリクエストを行いローカルタイムラインを表示するプリセット
|
// APIリクエストを行いローカルタイムラインを表示するプリセット
|
||||||
|
|
||||||
@fetch() {
|
@fetch() {
|
||||||
|
@ -315,7 +315,7 @@ const PRESET_TIMELINE = `/// @ 0.16.0
|
||||||
])
|
])
|
||||||
|
|
||||||
// タイムライン取得
|
// タイムライン取得
|
||||||
let notes = Mk:api("notes/local-timeline" {})
|
let notes = Mk:api("notes/local-timeline", {})
|
||||||
|
|
||||||
// それぞれのノートごとにUI要素作成
|
// それぞれのノートごとにUI要素作成
|
||||||
let noteEls = []
|
let noteEls = []
|
||||||
|
|
|
@ -15,11 +15,15 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<MkAsUi v-if="root" :component="root" :components="components"/>
|
<MkAsUi v-if="root" :component="root" :components="components"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="actions _panel">
|
<div class="actions _panel">
|
||||||
<MkButton v-if="flash.isLiked" v-tooltip="i18n.ts.unlike" asLike class="button" rounded primary @click="unlike()"><i class="ti ti-heart"></i><span v-if="flash.likedCount > 0" style="margin-left: 6px;">{{ flash.likedCount }}</span></MkButton>
|
<div class="items">
|
||||||
<MkButton v-else v-tooltip="i18n.ts.like" asLike class="button" rounded @click="like()"><i class="ti ti-heart"></i><span v-if="flash.likedCount > 0" style="margin-left: 6px;">{{ flash.likedCount }}</span></MkButton>
|
<MkButton v-tooltip="i18n.ts.reload" class="button" rounded @click="reset"><i class="ti ti-reload"></i></MkButton>
|
||||||
<MkButton v-tooltip="i18n.ts.shareWithNote" class="button" rounded @click="shareWithNote"><i class="ti ti-repeat ti-fw"></i></MkButton>
|
</div>
|
||||||
<MkButton v-tooltip="i18n.ts.copyLink" class="button" rounded @click="copyLink"><i class="ti ti-link ti-fw"></i></MkButton>
|
<div class="items">
|
||||||
<MkButton v-if="isSupportShare()" v-tooltip="i18n.ts.share" class="button" rounded @click="share"><i class="ti ti-share ti-fw"></i></MkButton>
|
<MkButton v-if="flash.isLiked" v-tooltip="i18n.ts.unlike" asLike class="button" rounded primary @click="unlike()"><i class="ti ti-heart"></i><span v-if="flash?.likedCount && flash.likedCount > 0" style="margin-left: 6px;">{{ flash.likedCount }}</span></MkButton>
|
||||||
|
<MkButton v-else v-tooltip="i18n.ts.like" asLike class="button" rounded @click="like()"><i class="ti ti-heart"></i><span v-if="flash?.likedCount && flash.likedCount > 0" style="margin-left: 6px;">{{ flash.likedCount }}</span></MkButton>
|
||||||
|
<MkButton v-tooltip="i18n.ts.copyLink" class="button" rounded @click="copyLink"><i class="ti ti-link ti-fw"></i></MkButton>
|
||||||
|
<MkButton v-tooltip="i18n.ts.share" class="button" rounded @click="share"><i class="ti ti-share ti-fw"></i></MkButton>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else :class="$style.ready">
|
<div v-else :class="$style.ready">
|
||||||
|
@ -49,7 +53,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<MkA v-if="$i && $i.id === flash.userId" :to="`/play/${flash.id}/edit`" style="color: var(--accent);">{{ i18n.ts._play.editThisPage }}</MkA>
|
<MkA v-if="$i && $i.id === flash.userId" :to="`/play/${flash.id}/edit`" style="color: var(--accent);">{{ i18n.ts._play.editThisPage }}</MkA>
|
||||||
<MkAd :prefer="['square', 'horizontal', 'horizontal-big']"/>
|
<MkAd :prefer="['square', 'horizontal', 'horizontal-big']"/>
|
||||||
</div>
|
</div>
|
||||||
<MkError v-else-if="error" @retry="fetchPage()"/>
|
<MkError v-else-if="error" @retry="fetchFlash()"/>
|
||||||
<MkLoading v-else/>
|
<MkLoading v-else/>
|
||||||
</Transition>
|
</Transition>
|
||||||
</MkSpacer>
|
</MkSpacer>
|
||||||
|
@ -94,12 +98,33 @@ function fetchFlash() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function share(ev: MouseEvent) {
|
||||||
|
if (!flash.value) return;
|
||||||
|
|
||||||
|
os.popupMenu([
|
||||||
|
{
|
||||||
|
text: i18n.ts.shareWithNote,
|
||||||
|
icon: 'ti ti-pencil',
|
||||||
|
action: shareWithNote,
|
||||||
|
},
|
||||||
|
...(isSupportShare() ? [{
|
||||||
|
text: i18n.ts.share,
|
||||||
|
icon: 'ti ti-share',
|
||||||
|
action: shareWithNavigator,
|
||||||
|
}] : []),
|
||||||
|
], ev.currentTarget ?? ev.target);
|
||||||
|
}
|
||||||
|
|
||||||
function copyLink() {
|
function copyLink() {
|
||||||
|
if (!flash.value) return;
|
||||||
|
|
||||||
copyToClipboard(`${url}/play/${flash.value.id}`);
|
copyToClipboard(`${url}/play/${flash.value.id}`);
|
||||||
os.success();
|
os.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
function share() {
|
function shareWithNavigator() {
|
||||||
|
if (!flash.value) return;
|
||||||
|
|
||||||
navigator.share({
|
navigator.share({
|
||||||
title: flash.value.title,
|
title: flash.value.title,
|
||||||
text: flash.value.summary,
|
text: flash.value.summary,
|
||||||
|
@ -108,21 +133,28 @@ function share() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function shareWithNote() {
|
function shareWithNote() {
|
||||||
|
if (!flash.value) return;
|
||||||
|
|
||||||
os.post({
|
os.post({
|
||||||
initialText: `${flash.value.title} ${url}/play/${flash.value.id}`,
|
initialText: `${flash.value.title}\n${url}/play/${flash.value.id}`,
|
||||||
|
instant: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function like() {
|
function like() {
|
||||||
|
if (!flash.value) return;
|
||||||
|
|
||||||
os.apiWithDialog('flash/like', {
|
os.apiWithDialog('flash/like', {
|
||||||
flashId: flash.value.id,
|
flashId: flash.value.id,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
flash.value.isLiked = true;
|
flash.value!.isLiked = true;
|
||||||
flash.value.likedCount++;
|
flash.value!.likedCount++;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function unlike() {
|
async function unlike() {
|
||||||
|
if (!flash.value) return;
|
||||||
|
|
||||||
const confirm = await os.confirm({
|
const confirm = await os.confirm({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
text: i18n.ts.unlikeConfirm,
|
text: i18n.ts.unlikeConfirm,
|
||||||
|
@ -131,8 +163,8 @@ async function unlike() {
|
||||||
os.apiWithDialog('flash/unlike', {
|
os.apiWithDialog('flash/unlike', {
|
||||||
flashId: flash.value.id,
|
flashId: flash.value.id,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
flash.value.isLiked = false;
|
flash.value!.isLiked = false;
|
||||||
flash.value.likedCount--;
|
flash.value!.likedCount--;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +184,7 @@ function start() {
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
if (aiscript.value) aiscript.value.abort();
|
if (aiscript.value) aiscript.value.abort();
|
||||||
|
if (!flash.value) return;
|
||||||
|
|
||||||
aiscript.value = new Interpreter({
|
aiscript.value = new Interpreter({
|
||||||
...createAiScriptEnv({
|
...createAiScriptEnv({
|
||||||
|
@ -193,12 +226,17 @@ async function run() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onDeactivated(() => {
|
function reset() {
|
||||||
if (aiscript.value) aiscript.value.abort();
|
if (aiscript.value) aiscript.value.abort();
|
||||||
|
started.value = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
onDeactivated(() => {
|
||||||
|
reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
if (aiscript.value) aiscript.value.abort();
|
reset();
|
||||||
});
|
});
|
||||||
|
|
||||||
const headerActions = computed(() => []);
|
const headerActions = computed(() => []);
|
||||||
|
@ -265,11 +303,19 @@ definePageMetadata(() => ({
|
||||||
}
|
}
|
||||||
|
|
||||||
> .actions {
|
> .actions {
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 12px;
|
|
||||||
margin-top: 16px;
|
margin-top: 16px;
|
||||||
padding: 16px;
|
|
||||||
|
> .items {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 12px;
|
||||||
|
padding: 16px;
|
||||||
|
border-bottom: 1px solid var(--divider);
|
||||||
|
|
||||||
|
&:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,16 +11,12 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<div v-if="tab === 'my'" key="my" class="_gaps">
|
<div v-if="tab === 'my'" key="my" class="_gaps">
|
||||||
<MkButton primary rounded class="add" @click="create"><i class="ti ti-plus"></i> {{ i18n.ts.add }}</MkButton>
|
<MkButton primary rounded class="add" @click="create"><i class="ti ti-plus"></i> {{ i18n.ts.add }}</MkButton>
|
||||||
|
|
||||||
<MkPagination v-slot="{items}" ref="pagingComponent" :pagination="pagination" class="_gaps">
|
<MkPagination v-slot="{ items }" ref="pagingComponent" :pagination="pagination" class="_gaps">
|
||||||
<MkA v-for="item in items" :key="item.id" :to="`/clips/${item.id}`">
|
<MkClipPreview v-for="item in items" :key="item.id" :clip="item"/>
|
||||||
<MkClipPreview :clip="item"/>
|
|
||||||
</MkA>
|
|
||||||
</MkPagination>
|
</MkPagination>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="tab === 'favorites'" key="favorites" class="_gaps">
|
<div v-else-if="tab === 'favorites'" key="favorites" class="_gaps">
|
||||||
<MkA v-for="item in favorites" :key="item.id" :to="`/clips/${item.id}`">
|
<MkClipPreview v-for="item in favorites" :key="item.id" :clip="item"/>
|
||||||
<MkClipPreview :clip="item"/>
|
|
||||||
</MkA>
|
|
||||||
</div>
|
</div>
|
||||||
</MkHorizontalSwipe>
|
</MkHorizontalSwipe>
|
||||||
</MkSpacer>
|
</MkSpacer>
|
||||||
|
|
|
@ -26,9 +26,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<div v-if="clips && clips.length > 0" class="_margin">
|
<div v-if="clips && clips.length > 0" class="_margin">
|
||||||
<div style="font-weight: bold; padding: 12px;">{{ i18n.ts.clip }}</div>
|
<div style="font-weight: bold; padding: 12px;">{{ i18n.ts.clip }}</div>
|
||||||
<div class="_gaps">
|
<div class="_gaps">
|
||||||
<MkA v-for="item in clips" :key="item.id" :to="`/clips/${item.id}`">
|
<MkClipPreview v-for="item in clips" :key="item.id" :clip="item"/>
|
||||||
<MkClipPreview :clip="item"/>
|
|
||||||
</MkA>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="!showPrev" class="_buttons" :class="$style.loadPrev">
|
<div v-if="!showPrev" class="_buttons" :class="$style.loadPrev">
|
||||||
|
|
|
@ -12,6 +12,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
:leaveActiveClass="defaultStore.state.animation ? $style.fadeLeaveActive : ''"
|
:leaveActiveClass="defaultStore.state.animation ? $style.fadeLeaveActive : ''"
|
||||||
:enterFromClass="defaultStore.state.animation ? $style.fadeEnterFrom : ''"
|
:enterFromClass="defaultStore.state.animation ? $style.fadeEnterFrom : ''"
|
||||||
:leaveToClass="defaultStore.state.animation ? $style.fadeLeaveTo : ''"
|
:leaveToClass="defaultStore.state.animation ? $style.fadeLeaveTo : ''"
|
||||||
|
mode="out-in"
|
||||||
>
|
>
|
||||||
<div v-if="page" :key="page.id" class="_gaps">
|
<div v-if="page" :key="page.id" class="_gaps">
|
||||||
<div :class="$style.pageMain">
|
<div :class="$style.pageMain">
|
||||||
|
@ -41,8 +42,14 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
</div>
|
</div>
|
||||||
<div :class="$style.pageBannerTitle" class="_gaps_s">
|
<div :class="$style.pageBannerTitle" class="_gaps_s">
|
||||||
<h1>{{ page.title || page.name }}</h1>
|
<h1>{{ page.title || page.name }}</h1>
|
||||||
<div v-if="page.user" :class="$style.pageBannerTitleUser">
|
<div :class="$style.pageBannerTitleSub">
|
||||||
<MkAvatar :user="page.user" :class="$style.avatar" indicator link preview/> <MkA :to="`/@${username}`"><MkUserName :user="page.user" :nowrap="false"/></MkA>
|
<div v-if="page.user" :class="$style.pageBannerTitleUser">
|
||||||
|
<MkAvatar :user="page.user" :class="$style.avatar" indicator link preview/> <MkA :to="`/@${username}`"><MkUserName :user="page.user" :nowrap="false"/></MkA>
|
||||||
|
</div>
|
||||||
|
<div :class="$style.pageBannerTitleSubActions">
|
||||||
|
<MkA v-if="page.userId === $i?.id" v-tooltip="i18n.ts._pages.editThisPage" :to="`/pages/edit/${page.id}`" class="_button" :class="$style.generalActionButton"><i class="ti ti-pencil ti-fw"></i></MkA>
|
||||||
|
<button v-tooltip="i18n.ts.share" class="_button" :class="$style.generalActionButton" @click="share"><i class="ti ti-share ti-fw"></i></button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -355,8 +362,15 @@ definePageMetadata(() => ({
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pageBannerTitleSub {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
.pageBannerTitleUser {
|
.pageBannerTitleUser {
|
||||||
--height: 32px;
|
--height: 32px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
|
||||||
.avatar {
|
.avatar {
|
||||||
height: var(--height);
|
height: var(--height);
|
||||||
|
@ -365,6 +379,14 @@ definePageMetadata(() => ({
|
||||||
|
|
||||||
line-height: var(--height);
|
line-height: var(--height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pageBannerTitleSubActions {
|
||||||
|
flex-shrink: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: var(--marginHalf);
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -151,6 +151,7 @@ import MkSwitch from '@/components/MkSwitch.vue';
|
||||||
import { deepClone } from '@/scripts/clone.js';
|
import { deepClone } from '@/scripts/clone.js';
|
||||||
import { useInterval } from '@/scripts/use-interval.js';
|
import { useInterval } from '@/scripts/use-interval.js';
|
||||||
import { signinRequired } from '@/account.js';
|
import { signinRequired } from '@/account.js';
|
||||||
|
import { url } from '@/config.js';
|
||||||
import { i18n } from '@/i18n.js';
|
import { i18n } from '@/i18n.js';
|
||||||
import { misskeyApi } from '@/scripts/misskey-api.js';
|
import { misskeyApi } from '@/scripts/misskey-api.js';
|
||||||
import { userPage } from '@/filters/user.js';
|
import { userPage } from '@/filters/user.js';
|
||||||
|
@ -442,7 +443,7 @@ function autoplay() {
|
||||||
|
|
||||||
function share() {
|
function share() {
|
||||||
os.post({
|
os.post({
|
||||||
initialText: `#MisskeyReversi ${location.href}`,
|
initialText: `#MisskeyReversi\n${url}/reversi/g/${game.value.id}`,
|
||||||
instant: true,
|
instant: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,10 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<div style="height: 100cqh; overflow: auto; text-align: center;">
|
<div style="height: 100cqh; overflow: auto; text-align: center;">
|
||||||
<MkSpacer :marginMin="20" :marginMax="28">
|
<MkSpacer :marginMin="20" :marginMax="28">
|
||||||
<div class="_gaps">
|
<div class="_gaps">
|
||||||
|
<MkInfo>
|
||||||
|
<Mfm :text="i18n.tsx._2fa.detailedGuide({ link: `[${i18n.ts.here}](https://misskey-hub.net/docs/for-users/stepped-guides/how-to-enable-2fa/)`})"/>
|
||||||
|
</MkInfo>
|
||||||
|
|
||||||
<I18n :src="i18n.ts._2fa.step1" tag="div">
|
<I18n :src="i18n.ts._2fa.step1" tag="div">
|
||||||
<template #a>
|
<template #a>
|
||||||
<a href="https://authy.com/" rel="nofollow noopener" target="_blank" class="_link">Authy</a>
|
<a href="https://authy.com/" rel="nofollow noopener" target="_blank" class="_link">Authy</a>
|
||||||
|
@ -33,8 +37,12 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<a href="https://support.google.com/accounts/answer/1066447" rel="nofollow noopener" target="_blank" class="_link">Google Authenticator</a>
|
<a href="https://support.google.com/accounts/answer/1066447" rel="nofollow noopener" target="_blank" class="_link">Google Authenticator</a>
|
||||||
</template>
|
</template>
|
||||||
</I18n>
|
</I18n>
|
||||||
<div>{{ i18n.ts._2fa.step2 }}<br>{{ i18n.ts._2fa.step2Click }}</div>
|
<div>{{ i18n.ts._2fa.step2 }}</div>
|
||||||
<a :href="twoFactorData.url"><img :class="$style.qr" :src="twoFactorData.qr"></a>
|
<div>
|
||||||
|
<a :class="$style.qrRoot" :href="twoFactorData.url"><img :class="$style.qr" :src="twoFactorData.qr"></a>
|
||||||
|
<!-- QRコード側にマージンが入っているので直下でOK -->
|
||||||
|
<div><MkButton inline rounded link :to="twoFactorData.url" :linkBehavior="'browser'">{{ i18n.ts.launchApp }}</MkButton></div>
|
||||||
|
</div>
|
||||||
<MkKeyValue :copy="twoFactorData.url">
|
<MkKeyValue :copy="twoFactorData.url">
|
||||||
<template #key>{{ i18n.ts._2fa.step2Uri }}</template>
|
<template #key>{{ i18n.ts._2fa.step2Uri }}</template>
|
||||||
<template #value>{{ twoFactorData.url }}</template>
|
<template #value>{{ twoFactorData.url }}</template>
|
||||||
|
@ -187,8 +195,14 @@ async function allDone() {
|
||||||
transform: translateX(-50px);
|
transform: translateX(-50px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.qr {
|
.qrRoot {
|
||||||
|
display: block;
|
||||||
|
margin: 0 auto;
|
||||||
width: 200px;
|
width: 200px;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.qr {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -23,7 +23,7 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
<div class="_gaps_s">
|
<div class="_gaps_s">
|
||||||
<MkInfo>
|
<MkInfo>
|
||||||
<Mfm :text="i18n.tsx._2fa.howto2fa({ link: `[${i18n.ts.here}](https://go.misskey.io/howto-2fa)`})"/>
|
<Mfm :text="i18n.tsx._2fa.detailedGuide({ link: `[${i18n.ts.here}](https://go.misskey.io/howto-2fa)`})"/>
|
||||||
</MkInfo>
|
</MkInfo>
|
||||||
<MkInfo v-if="$i.securityKeysList.length > 0">{{ i18n.ts._2fa.whyTOTPOnlyRenew }}</MkInfo>
|
<MkInfo v-if="$i.securityKeysList.length > 0">{{ i18n.ts._2fa.whyTOTPOnlyRenew }}</MkInfo>
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,10 @@ SPDX-License-Identifier: AGPL-3.0-only
|
||||||
<template #label>{{ i18n.ts.keepOriginalUploading }}</template>
|
<template #label>{{ i18n.ts.keepOriginalUploading }}</template>
|
||||||
<template #caption>{{ i18n.ts.keepOriginalUploadingDescription }}</template>
|
<template #caption>{{ i18n.ts.keepOriginalUploadingDescription }}</template>
|
||||||
</MkSwitch>
|
</MkSwitch>
|
||||||
|
<MkSwitch v-model="keepOriginalFilename">
|
||||||
|
<template #label>{{ i18n.ts.keepOriginalFilename }}</template>
|
||||||
|
<template #caption>{{ i18n.ts.keepOriginalFilenameDescription }}</template>
|
||||||
|
</MkSwitch>
|
||||||
<MkSwitch v-model="alwaysMarkNsfw" @update:modelValue="saveProfile()">
|
<MkSwitch v-model="alwaysMarkNsfw" @update:modelValue="saveProfile()">
|
||||||
<template #label>{{ i18n.ts.alwaysMarkSensitive }}</template>
|
<template #label>{{ i18n.ts.alwaysMarkSensitive }}</template>
|
||||||
</MkSwitch>
|
</MkSwitch>
|
||||||
|
@ -96,6 +100,7 @@ const meterStyle = computed(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const keepOriginalUploading = computed(defaultStore.makeGetterSetter('keepOriginalUploading'));
|
const keepOriginalUploading = computed(defaultStore.makeGetterSetter('keepOriginalUploading'));
|
||||||
|
const keepOriginalFilename = computed(defaultStore.makeGetterSetter('keepOriginalFilename'));
|
||||||
|
|
||||||
misskeyApi('drive').then(info => {
|
misskeyApi('drive').then(info => {
|
||||||
capacity.value = info.capacity;
|
capacity.value = info.capacity;
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue