Merge remote-tracking branch 'refs/remotes/misskey-original/develop' into develop

# Conflicts:
#	packages/frontend/src/components/MkFollowButton.vue
This commit is contained in:
mattyatea 2024-04-24 03:50:09 +09:00
commit 41e735906a
35 changed files with 892 additions and 257 deletions

View File

@ -5,24 +5,23 @@ on:
branches: branches:
- master - master
- develop - develop
- improve-misskey-js-autogen-check
paths: paths:
- packages/backend/** - packages/backend/**
jobs: jobs:
check-misskey-js-autogen: # pull_request_target safety: permissions: read-all, and there are no secrets used in this job
generate-misskey-js:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
pull-requests: write contents: read
if: ${{ github.event.pull_request.mergeable == null || github.event.pull_request.mergeable == true }}
env:
api_json_name: "api-head.json"
steps: steps:
- name: checkout - name: checkout
uses: actions/checkout@v4.1.1 uses: actions/checkout@v4.1.1
with: with:
submodules: true submodules: true
ref: ${{ github.event.pull_request.head.sha }} ref: refs/pull/${{ github.event.pull_request.number }}/merge
- name: setup pnpm - name: setup pnpm
uses: pnpm/action-setup@v3 uses: pnpm/action-setup@v3
@ -39,79 +38,81 @@ jobs:
- name: install dependencies - name: install dependencies
run: pnpm i --frozen-lockfile run: pnpm i --frozen-lockfile
- name: wait get-api-diff # generate api.json
uses: lewagon/wait-on-check-action@v1.3.3 - name: Copy Config
run: cp .config/example.yml .config/default.yml
- name: Build
run: pnpm build
- name: Generate API JSON
run: pnpm --filter backend generate-api-json
# build misskey js
- name: Build misskey-js
run: |-
cp packages/backend/built/api.json packages/misskey-js/generator/api.json
pnpm run --filter misskey-js-type-generator generate
# packages/misskey-js/generator/built/autogen
- name: Upload Generated
uses: actions/upload-artifact@v4
with: with:
ref: ${{ github.event.pull_request.head.sha }} name: generated-misskey-js
check-regexp: get-from-misskey .+ path: packages/misskey-js/generator/built/autogen
repo-token: ${{ secrets.GITHUB_TOKEN }}
wait-interval: 30
- name: Download artifact # pull_request_target safety: permissions: read-all, and there are no secrets used in this job
uses: actions/github-script@v7.0.1 get-actual-misskey-js:
runs-on: ubuntu-latest
permissions:
contents: read
if: ${{ github.event.pull_request.mergeable == null || github.event.pull_request.mergeable == true }}
steps:
- name: checkout
uses: actions/checkout@v4.1.1
with: with:
script: | submodules: true
const fs = require('fs'); ref: refs/pull/${{ github.event.pull_request.number }}/merge
const workflows = await github.rest.actions.listWorkflowRunsForRepo({ - name: Upload From Merged
owner: context.repo.owner, uses: actions/upload-artifact@v4
repo: context.repo.repo, with:
head_sha: `${{ github.event.pull_request.head.sha }}` name: actual-misskey-js
}).then(x => x.data.workflow_runs); path: packages/misskey-js/src/autogen
console.log(workflows.map(x => ({name: x.name, title: x.display_title}))); # pull_request_target safety: nothing is cloned from repository
comment-misskey-js-autogen:
runs-on: ubuntu-latest
needs: [generate-misskey-js, get-actual-misskey-js]
permissions:
pull-requests: write
steps:
- name: download generated-misskey-js
uses: actions/download-artifact@v4
with:
name: generated-misskey-js
path: misskey-js-generated
const run_id = workflows.find(x => x.name.includes("Get api.json from Misskey")).id; - name: download actual-misskey-js
uses: actions/download-artifact@v4
with:
name: actual-misskey-js
path: misskey-js-actual
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ - name: check misskey-js changes
owner: context.repo.owner, id: check-changes
repo: context.repo.repo, run: |
run_id: run_id, diff -r -u --label=generated --label=on-tree ./misskey-js-generated ./misskey-js-actual > misskey-js.diff || true
});
let matchArtifacts = allArtifacts.data.artifacts.filter((artifact) => { if [ -s misskey-js.diff ]; then
return artifact.name.startsWith("api-artifact-") || artifact.name == "api-artifact" echo "changes=true" >> $GITHUB_OUTPUT
}); else
echo "changes=false" >> $GITHUB_OUTPUT
fi
await Promise.all(matchArtifacts.map(async (artifact) => { - name: Print full diff
let download = await github.rest.actions.downloadArtifact({ run: cat ./misskey-js.diff
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: artifact.id,
archive_format: 'zip',
});
await fs.promises.writeFile(`${process.env.GITHUB_WORKSPACE}/${artifact.name}.zip`, Buffer.from(download.data));
}));
- name: unzip artifacts
run: |-
find . -mindepth 1 -maxdepth 1 -type f -name '*.zip' -exec unzip {} -d . ';'
ls -la
- name: get head checksum
run: |-
checksum=$(realpath head_checksum)
cd packages/misskey-js/src
find autogen -type f -exec sh -c 'echo $(sed -E "s/^\s+\*\s+generatedAt:.+$//" {} | sha256sum | cut -d" " -f 1) {}' \; > $checksum
cd ../../..
- name: build autogen
run: |-
checksum=$(realpath ${api_json_name}_checksum)
mv $api_json_name packages/misskey-js/generator/api.json
cd packages/misskey-js/generator
pnpm run generate
cd built
find autogen -type f -exec sh -c 'echo $(sed -E "s/^\s+\*\s+generatedAt:.+$//" {} | sha256sum | cut -d" " -f 1) {}' \; > $checksum
cd ../../../..
- name: check update for type definitions
run: diff head_checksum ${api_json_name}_checksum
- name: send message - name: send message
if: failure() if: steps.check-changes.outputs.changes == 'true'
uses: thollander/actions-comment-pull-request@v2 uses: thollander/actions-comment-pull-request@v2
with: with:
comment_tag: check-misskey-js-autogen comment_tag: check-misskey-js-autogen
@ -125,7 +126,7 @@ jobs:
``` ```
- name: send message - name: send message
if: success() if: steps.check-changes.outputs.changes == 'false'
uses: thollander/actions-comment-pull-request@v2 uses: thollander/actions-comment-pull-request@v2
with: with:
comment_tag: check-misskey-js-autogen comment_tag: check-misskey-js-autogen

View File

@ -8,7 +8,14 @@
- 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: クリップのノート数を表示するように
- Enhance: コンディショナルロールの条件として以下を新たに追加 (#13667)
- 猫ユーザーか
- botユーザーか
- サスペンド済みユーザーか
- 鍵アカウントユーザーか
- 「アカウントを見つけやすくする」が有効なユーザーか
- Fix: Play作成時に設定した公開範囲が機能していない問題を修正 - Fix: Play作成時に設定した公開範囲が機能していない問題を修正
- Fix: 正規化されていない状態のhashtagが連合されてきたhtmlに含まれているとhashtagが正しくhashtagに復元されない問題を修正
### Client ### Client
- Feat: アップロードするファイルの名前をランダム文字列にできるように - Feat: アップロードするファイルの名前をランダム文字列にできるように
@ -27,6 +34,7 @@
- Enhance: ノートについているリアクションの「もっと!」から、リアクションの一覧を表示できるように - Enhance: ノートについているリアクションの「もっと!」から、リアクションの一覧を表示できるように
- Enhance: リプライにて引用がある場合テキストが空でもノートできるように - Enhance: リプライにて引用がある場合テキストが空でもノートできるように
- 引用したいートのURLをコピーしリプライ投稿画面にペーストして添付することで達成できます - 引用したいートのURLをコピーしリプライ投稿画面にペーストして添付することで達成できます
- Enhance: フォローするかどうかの確認ダイアログを出せるように
- Fix: 一部のページ内リンクが正しく動作しない問題を修正 - Fix: 一部のページ内リンクが正しく動作しない問題を修正
- Fix: 周年の実績が閏年を考慮しない問題を修正 - Fix: 周年の実績が閏年を考慮しない問題を修正
- Fix: ローカルURLのプレビューポップアップが左上に表示される - Fix: ローカルURLのプレビューポップアップが左上に表示される
@ -40,6 +48,7 @@
- Fix: CWのみの引用リートが詳細ページで純粋なリートとして誤って扱われてしまう問題を修正 - Fix: CWのみの引用リートが詳細ページで純粋なリートとして誤って扱われてしまう問題を修正
- Fix: ート詳細ページにおいてCW付き引用リートのCWボタンのラベルに「引用」が含まれていない問題を修正 - Fix: ート詳細ページにおいてCW付き引用リートのCWボタンのラベルに「引用」が含まれていない問題を修正
- Fix: ダイアログの入力で字数制限に違反していてもEnterキーが押せてしまう問題を修正 - Fix: ダイアログの入力で字数制限に違反していてもEnterキーが押せてしまう問題を修正
- Fix: ダイレクト投稿の宛先が保存されない問題を修正
### Server ### Server
- Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに - Enhance: エンドポイント`antennas/update`の必須項目を`antennaId`のみに
@ -52,6 +61,10 @@
- Fix: リプライのみの引用リートと、CWのみの引用リートが純粋なリートとして誤って扱われてしまう問題を修正 - Fix: リプライのみの引用リートと、CWのみの引用リートが純粋なリートとして誤って扱われてしまう問題を修正
- Fix: 登録にメール認証が必須になっている場合、登録されているメールアドレスを削除できないように - Fix: 登録にメール認証が必須になっている場合、登録されているメールアドレスを削除できないように
(Cherry-picked from https://github.com/MisskeyIO/misskey/pull/606) (Cherry-picked from https://github.com/MisskeyIO/misskey/pull/606)
- Fix: nginx経由で/files/にRangeリクエストされた場合に正しく応答できないのを修正
- Fix: 一部のタイムラインのストリーミングでインスタンスミュートが効かない問題を修正
- Fix: グローバルタイムラインで返信が表示されないことがある問題を修正
- Fix: リノートをミュートしたユーザの投稿のリノートがミュートされる問題を修正
## 2024.3.1 ## 2024.3.1

24
locales/index.d.ts vendored
View File

@ -5180,6 +5180,10 @@ export interface Locale extends ILocale {
* *
*/ */
"noDescription": string; "noDescription": string;
/**
*
*/
"alwaysConfirmFollow": string;
"_bubbleGame": { "_bubbleGame": {
/** /**
* *
@ -6844,6 +6848,26 @@ export interface Locale extends ILocale {
* *
*/ */
"isRemote": string; "isRemote": string;
/**
*
*/
"isCat": string;
/**
* botユーザー
*/
"isBot": string;
/**
*
*/
"isSuspended": string;
/**
*
*/
"isLocked": string;
/**
*
*/
"isExplorable": string;
/** /**
* *
*/ */

View File

@ -1291,6 +1291,7 @@ useNativeUIForVideoAudioPlayer: "動画・音声の再生にブラウザのUIを
keepOriginalFilename: "オリジナルのファイル名を保持" keepOriginalFilename: "オリジナルのファイル名を保持"
keepOriginalFilenameDescription: "この設定をオフにすると、アップロード時にファイル名が自動でランダム文字列に置き換えられます。" keepOriginalFilenameDescription: "この設定をオフにすると、アップロード時にファイル名が自動でランダム文字列に置き換えられます。"
noDescription: "説明文はありません" noDescription: "説明文はありません"
alwaysConfirmFollow: "フォローの際常に確認する"
_bubbleGame: _bubbleGame:
howToPlay: "遊び方" howToPlay: "遊び方"
@ -1766,6 +1767,11 @@ _role:
roleAssignedTo: "マニュアルロールにアサイン済み" roleAssignedTo: "マニュアルロールにアサイン済み"
isLocal: "ローカルユーザー" isLocal: "ローカルユーザー"
isRemote: "リモートユーザー" isRemote: "リモートユーザー"
isCat: "猫ユーザー"
isBot: "botユーザー"
isSuspended: "サスペンド済みユーザー"
isLocked: "鍵アカウントユーザー"
isExplorable: "「アカウントを見つけやすくする」が有効なユーザー"
createdLessThan: "アカウント作成から~以内" createdLessThan: "アカウント作成から~以内"
createdMoreThan: "アカウント作成から~経過" createdMoreThan: "アカウント作成から~経過"
followersLessThanOrEq: "フォロワー数が~以下" followersLessThanOrEq: "フォロワー数が~以下"

View File

@ -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>

View File

@ -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 (isRenote(note) && !isQuote(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);

View File

@ -10,6 +10,7 @@ import { Window } 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 '))) {

View File

@ -217,45 +217,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;
} }

View File

@ -4,6 +4,7 @@
*/ */
import type { MiNote } from '@/models/Note.js'; import type { MiNote } from '@/models/Note.js';
import type { Packed } from '@/misc/json-schema.js';
type Renote = type Renote =
MiNote & { MiNote & {
@ -34,3 +35,33 @@ export function isQuote(note: Renote): note is Quote {
note.hasPoll || note.hasPoll ||
note.fileIds.length > 0; 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);
}

View File

@ -48,6 +48,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';
@ -99,6 +100,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,

View File

@ -6,69 +6,149 @@
import { Entity, Column, PrimaryColumn } from 'typeorm'; import { Entity, Column, PrimaryColumn } 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 |

View File

@ -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',
}, },

View File

@ -214,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',
@ -256,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));
@ -552,9 +555,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);
if (!file.size) { file.size = (await fs.promises.stat(result.path)).size; // DB file.sizeは正確とは限らないので
file.size = (await fs.promises.stat(result.path)).size;
}
return { return {
...result, ...result,
url: file.uri, url: file.uri,

View File

@ -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;

View File

@ -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';
@ -40,12 +39,7 @@ class AntennaChannel extends Channel {
if (data.type === 'note') { if (data.type === 'note') {
const note = await this.noteEntityService.pack(data.body.id, this.user, { detail: true }); const note = await this.noteEntityService.pack(data.body.id, this.user, { detail: true });
// 流れてきた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);

View File

@ -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 {
@ -38,14 +38,9 @@ class ChannelChannel extends Channel {
private async onNote(note: Packed<'Note'>) { private async onNote(note: Packed<'Note'>) {
if (note.channelId !== this.channelId) return; if (note.channelId !== this.channelId) 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;

View File

@ -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 {
@ -52,26 +50,11 @@ class GlobalTimelineChannel extends Channel {
if (note.visibility !== 'public') return; if (note.visibility !== 'public') return;
if (note.channelId != null) return; if (note.channelId != null) return;
// 関係ない返信は除外 if (isRenotePacked(note) && !isQuotePacked(note) && !this.withRenotes) return;
if (note.reply && !this.following[note.userId]?.withReplies) {
const reply = note.reply;
// 「チャンネル接続主への返信」でもなければ、「チャンネル接続主が行った返信」でもなければ、「投稿者の投稿者自身への返信」でもない場合
if (reply.userId !== this.user!.id && note.userId !== this.user!.id && reply.userId !== note.userId) return;
}
if (note.renote && note.text == null && (note.fileIds == null || note.fileIds.length === 0) && !this.withRenotes) return; if (this.isNoteMutedOrBlocked(note)) return;
// Ignore notes from instances the user has muted if (this.user && isRenotePacked(note) && !isQuotePacked(note)) {
if (isInstanceMuted(note, new Set<string>(this.userProfile?.mutedInstances ?? []))) return;
// 流れてきた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;

View File

@ -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 {
@ -43,14 +43,9 @@ class HashtagChannel extends Channel {
const matched = this.q.some(tags => tags.every(tag => noteTags.includes(normalizeForSearch(tag)))); const matched = this.q.some(tags => tags.every(tag => noteTags.includes(normalizeForSearch(tag))));
if (!matched) return; if (!matched) 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;

View File

@ -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 {
@ -51,9 +49,6 @@ 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 (note.visibility === 'followers') { if (note.visibility === 'followers') {
if (!isMe && !Object.hasOwn(this.following, note.userId)) return; if (!isMe && !Object.hasOwn(this.following, note.userId)) return;
} else if (note.visibility === 'specified') { } else if (note.visibility === 'specified') {
@ -72,7 +67,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;
@ -81,14 +76,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;

View File

@ -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 {
@ -71,8 +69,7 @@ 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 (this.isNoteMutedOrBlocked(note)) return;
if (isInstanceMuted(note, new Set<string>(this.userProfile!.mutedInstances))) return;
if (note.reply) { if (note.reply) {
const reply = note.reply; const reply = note.reply;
@ -85,14 +82,7 @@ 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) && !this.withRenotes) return;
// 流れてきた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 (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) {

View File

@ -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 {
@ -61,16 +60,11 @@ class LocalTimelineChannel extends Channel {
if (reply.userId !== this.user.id && note.userId !== this.user.id && reply.userId !== note.userId) return; if (reply.userId !== this.user.id && note.userId !== this.user.id && reply.userId !== note.userId) return;
} }
if (note.renote && note.text == null && (note.fileIds == null || note.fileIds.length === 0) && !this.withRenotes) return; if (isRenotePacked(note) && !isQuotePacked(note) && !this.withRenotes) 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;

View File

@ -4,8 +4,6 @@
*/ */
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';
@ -46,12 +44,7 @@ class RoleTimelineChannel extends Channel {
} }
if (note.visibility !== 'public') return; if (note.visibility !== 'public') 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.send('note', note); this.send('note', note);
} else { } else {

View File

@ -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 {
@ -106,25 +105,17 @@ 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) && !this.withRenotes) 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);

View File

@ -63,6 +63,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' });
@ -86,4 +102,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);
});
}); });

View File

@ -63,7 +63,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);
@ -509,6 +509,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', () => {

View File

@ -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 any);
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();

View File

@ -115,7 +115,19 @@ async function onClick() {
userId: props.user.id, userId: props.user.id,
}); });
} else { } else {
if (hasPendingFollowRequestFromYou.value) { 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 (hasPendingFollowRequestFromYou.value) {
await misskeyApi('following/requests/cancel', { await misskeyApi('following/requests/cancel', {
userId: props.user.id, userId: props.user.id,
}); });

View File

@ -419,7 +419,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);
}); });
} }
} }
@ -717,6 +717,7 @@ function saveDraft() {
localOnly: localOnly.value, localOnly: localOnly.value,
files: files.value, files: files.value,
poll: poll.value, poll: poll.value,
visibleUserIds: visibility.value === 'specified' ? visibleUsers.value.map(x => x.id) : undefined,
}, },
}; };
@ -1041,6 +1042,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]);
}
}
});
}
} }
} }

View File

@ -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>

View File

@ -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;
}
} }
} }

View File

@ -209,6 +209,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<MkSwitch v-model="keepScreenOn">{{ i18n.ts.keepScreenOn }}</MkSwitch> <MkSwitch v-model="keepScreenOn">{{ i18n.ts.keepScreenOn }}</MkSwitch>
<MkSwitch v-model="disableStreamingTimeline">{{ i18n.ts.disableStreamingTimeline }}</MkSwitch> <MkSwitch v-model="disableStreamingTimeline">{{ i18n.ts.disableStreamingTimeline }}</MkSwitch>
<MkSwitch v-model="enableHorizontalSwipe">{{ i18n.ts.enableHorizontalSwipe }}</MkSwitch> <MkSwitch v-model="enableHorizontalSwipe">{{ i18n.ts.enableHorizontalSwipe }}</MkSwitch>
<MkSwitch v-model="alwaysConfirmFollow">{{ i18n.ts.alwaysConfirmFollow }}</MkSwitch>
</div> </div>
<MkSelect v-model="serverDisconnectedBehavior"> <MkSelect v-model="serverDisconnectedBehavior">
<template #label>{{ i18n.ts.whenServerDisconnected }}</template> <template #label>{{ i18n.ts.whenServerDisconnected }}</template>
@ -477,6 +478,7 @@ const remoteLocalTimelineName3 = ref(defaultStore.state['remoteLocalTimelineName
const remoteLocalTimelineName4 = ref(defaultStore.state['remoteLocalTimelineName4']); const remoteLocalTimelineName4 = ref(defaultStore.state['remoteLocalTimelineName4']);
const remoteLocalTimelineName5 = ref(defaultStore.state['remoteLocalTimelineName5']); const remoteLocalTimelineName5 = ref(defaultStore.state['remoteLocalTimelineName5']);
const useNativeUIForVideoAudioPlayer = computed(defaultStore.makeGetterSetter('useNativeUIForVideoAudioPlayer')); const useNativeUIForVideoAudioPlayer = computed(defaultStore.makeGetterSetter('useNativeUIForVideoAudioPlayer'));
const alwaysConfirmFollow = computed(defaultStore.makeGetterSetter('alwaysConfirmFollow'));
const remoteLocalTimelineEnable1 = computed(defaultStore.makeGetterSetter('remoteLocalTimelineEnable1')); const remoteLocalTimelineEnable1 = computed(defaultStore.makeGetterSetter('remoteLocalTimelineEnable1'));
const remoteLocalTimelineEnable2 = computed(defaultStore.makeGetterSetter('remoteLocalTimelineEnable2')); const remoteLocalTimelineEnable2 = computed(defaultStore.makeGetterSetter('remoteLocalTimelineEnable2'));
@ -559,6 +561,7 @@ watch([
topBarNameShown, topBarNameShown,
disableStreamingTimeline, disableStreamingTimeline,
enableSeasonalScreenEffect, enableSeasonalScreenEffect,
alwaysConfirmFollow,
], async () => { ], async () => {
await reloadAsk(); await reloadAsk();
}); });

View File

@ -716,6 +716,10 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'device', where: 'device',
default: true, default: true,
}, },
alwaysConfirmFollow: {
where: 'device',
default: true,
},
sound_masterVolume: { sound_masterVolume: {
where: 'device', where: 'device',

View File

@ -1713,6 +1713,7 @@ declare namespace entities {
RoleCondFormulaLogics, RoleCondFormulaLogics,
RoleCondFormulaValueNot, RoleCondFormulaValueNot,
RoleCondFormulaValueIsLocalOrRemote, RoleCondFormulaValueIsLocalOrRemote,
RoleCondFormulaValueUserSettingBooleanSchema,
RoleCondFormulaValueAssignedRole, RoleCondFormulaValueAssignedRole,
RoleCondFormulaValueCreated, RoleCondFormulaValueCreated,
RoleCondFormulaFollowersOrFollowingOrNotes, RoleCondFormulaFollowersOrFollowingOrNotes,
@ -2745,6 +2746,9 @@ type RoleCondFormulaValueIsLocalOrRemote = components['schemas']['RoleCondFormul
// @public (undocumented) // @public (undocumented)
type RoleCondFormulaValueNot = components['schemas']['RoleCondFormulaValueNot']; type RoleCondFormulaValueNot = components['schemas']['RoleCondFormulaValueNot'];
// @public (undocumented)
type RoleCondFormulaValueUserSettingBooleanSchema = components['schemas']['RoleCondFormulaValueUserSettingBooleanSchema'];
// @public (undocumented) // @public (undocumented)
type RoleLite = components['schemas']['RoleLite']; type RoleLite = components['schemas']['RoleLite'];

View File

@ -38,6 +38,7 @@ export type Signin = components['schemas']['Signin'];
export type RoleCondFormulaLogics = components['schemas']['RoleCondFormulaLogics']; export type RoleCondFormulaLogics = components['schemas']['RoleCondFormulaLogics'];
export type RoleCondFormulaValueNot = components['schemas']['RoleCondFormulaValueNot']; export type RoleCondFormulaValueNot = components['schemas']['RoleCondFormulaValueNot'];
export type RoleCondFormulaValueIsLocalOrRemote = components['schemas']['RoleCondFormulaValueIsLocalOrRemote']; export type RoleCondFormulaValueIsLocalOrRemote = components['schemas']['RoleCondFormulaValueIsLocalOrRemote'];
export type RoleCondFormulaValueUserSettingBooleanSchema = components['schemas']['RoleCondFormulaValueUserSettingBooleanSchema'];
export type RoleCondFormulaValueAssignedRole = components['schemas']['RoleCondFormulaValueAssignedRole']; export type RoleCondFormulaValueAssignedRole = components['schemas']['RoleCondFormulaValueAssignedRole'];
export type RoleCondFormulaValueCreated = components['schemas']['RoleCondFormulaValueCreated']; export type RoleCondFormulaValueCreated = components['schemas']['RoleCondFormulaValueCreated'];
export type RoleCondFormulaFollowersOrFollowingOrNotes = components['schemas']['RoleCondFormulaFollowersOrFollowingOrNotes']; export type RoleCondFormulaFollowersOrFollowingOrNotes = components['schemas']['RoleCondFormulaFollowersOrFollowingOrNotes'];

View File

@ -4586,6 +4586,11 @@ export type components = {
/** @enum {string} */ /** @enum {string} */
type: 'isLocal' | 'isRemote'; type: 'isLocal' | 'isRemote';
}; };
RoleCondFormulaValueUserSettingBooleanSchema: {
id: string;
/** @enum {string} */
type: 'isSuspended' | 'isLocked' | 'isBot' | 'isCat' | 'isExplorable';
};
RoleCondFormulaValueAssignedRole: { RoleCondFormulaValueAssignedRole: {
id: string; id: string;
/** @enum {string} */ /** @enum {string} */
@ -4608,7 +4613,7 @@ export type components = {
type: 'followersLessThanOrEq' | 'followersMoreThanOrEq' | 'followingLessThanOrEq' | 'followingMoreThanOrEq' | 'notesLessThanOrEq' | 'notesMoreThanOrEq'; type: 'followersLessThanOrEq' | 'followersMoreThanOrEq' | 'followingLessThanOrEq' | 'followingMoreThanOrEq' | 'notesLessThanOrEq' | 'notesMoreThanOrEq';
value: number; value: number;
}; };
RoleCondFormulaValue: components['schemas']['RoleCondFormulaLogics'] | components['schemas']['RoleCondFormulaValueNot'] | components['schemas']['RoleCondFormulaValueIsLocalOrRemote'] | components['schemas']['RoleCondFormulaValueAssignedRole'] | components['schemas']['RoleCondFormulaValueCreated'] | components['schemas']['RoleCondFormulaFollowersOrFollowingOrNotes']; RoleCondFormulaValue: components['schemas']['RoleCondFormulaLogics'] | components['schemas']['RoleCondFormulaValueNot'] | components['schemas']['RoleCondFormulaValueIsLocalOrRemote'] | components['schemas']['RoleCondFormulaValueUserSettingBooleanSchema'] | components['schemas']['RoleCondFormulaValueAssignedRole'] | components['schemas']['RoleCondFormulaValueCreated'] | components['schemas']['RoleCondFormulaFollowersOrFollowingOrNotes'];
RoleLite: { RoleLite: {
/** /**
* Format: id * Format: id