enhance: ファイルが添付されたノートのみ通知する設定を追加#17737
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughFollowing notifications now support ChangesFollowing notification modes
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant NotificationMenu
participant FollowingUpdate
participant NoteCreateService
participant NotificationStore
User->>NotificationMenu: Select notification mode
NotificationMenu->>FollowingUpdate: Update notify preference
NoteCreateService->>NotificationStore: Create notification for matching notes
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. Comment |
|
このPRによるapi.jsonの差分 差分はこちら--- base
+++ head
@@ -50263,6 +50263,7 @@
"type": "string",
"enum": [
"normal",
+ "withFile",
"none"
]
},
@@ -50472,6 +50473,7 @@
"type": "string",
"enum": [
"normal",
+ "withFile",
"none"
]
},
@@ -88844,6 +88846,7 @@
"type": "string",
"enum": [
"normal",
+ "withFile",
"none"
]
}, |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #17737 +/- ##
============================================
+ Coverage 15.00% 26.40% +11.39%
============================================
Files 248 1183 +935
Lines 12402 40321 +27919
Branches 4224 11135 +6911
============================================
+ Hits 1861 10647 +8786
- Misses 8239 23797 +15558
- Partials 2302 5877 +3575 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/backend/src/core/NoteCreateService.ts (1)
773-790: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winDo not fetch
withFilefollowers for text-only notes.Text-only posts now load and iterate file-only followers even though they can never receive a notification. Compute
hasFilesbefore the query and filter tonormalunless files exist.Suggested change
if (data.reply == null) { + const hasFiles = note.fileIds.length > 0; this.followingsRepository.findBy({ followeeId: user.id, - notify: In(['normal', 'withFile']), + notify: hasFiles ? In(['normal', 'withFile']) : 'normal', }).then(async followings => { if (note.visibility !== 'specified') { const isPureRenote = this.isRenote(data) && !this.isQuote(data) ? true : false; - const hasFiles = data.files != null && data.files.length > 0; for (const following of followings) { // ... - if (following.notify === 'normal' || (following.notify === 'withFile' && hasFiles)) { - this.notificationService.createNotification(/* ... */); - } + this.notificationService.createNotification(/* ... */); } } }); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/backend/src/core/NoteCreateService.ts` around lines 773 - 790, Compute hasFiles before the followings query in the note creation flow, then query with notify restricted to normal for text-only notes and normal/withFile when files exist. Keep the existing notification iteration and filtering in the visible followings callback, including isRenoteMuted handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/backend/test/e2e/note-notify.ts`:
- Around line 168-190: Replace both fixed setTimeout(100) delays in the note
notification test with bounded polling of i/notifications using vi.waitFor or
the test’s established equivalent. Ensure the first poll confirms no
notification for the file-less note before proceeding, and the second waits
until the file-backed note notification appears, while preserving the existing
assertions and API calls.
---
Nitpick comments:
In `@packages/backend/src/core/NoteCreateService.ts`:
- Around line 773-790: Compute hasFiles before the followings query in the note
creation flow, then query with notify restricted to normal for text-only notes
and normal/withFile when files exist. Keep the existing notification iteration
and filtering in the visible followings callback, including isRenoteMuted
handling.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9a5e4f16-551d-4e27-a8cf-b5529c87ba0f
📒 Files selected for processing (11)
locales/ja-JP.ymlpackages/backend/src/core/NoteCreateService.tspackages/backend/src/models/Following.tspackages/backend/src/models/json-schema/user.tspackages/backend/src/server/api/endpoints/following/update-all.tspackages/backend/src/server/api/endpoints/following/update.tspackages/backend/test/e2e/note-notify.tspackages/frontend/src/pages/settings/notifications.vuepackages/frontend/src/utility/get-user-menu.tspackages/i18n/src/autogen/locale.tspackages/misskey-js/src/autogen/types.ts
| // redisに追加されるのを待つ | ||
| await setTimeout(100); | ||
|
|
||
| const beforeRes = await api('i/notifications', {}, alice); | ||
| assert.strictEqual(beforeRes.status, 200); | ||
| const noteNotifsBefore = beforeRes.body.filter((n: { type: string; note?: { id: string } }) => | ||
| n.type === 'note' && n.note?.id === textOnlyRes.body.createdNote.id, | ||
| ); | ||
| assert.strictEqual(noteNotifsBefore.length, 0, 'ファイルなし投稿で通知が来てしまった'); | ||
|
|
||
| // --- ケース2: ファイル付き投稿 → 通知が来ること --- | ||
| const file = await uploadUrl(bob, 'https://raw.githubusercontent.com/misskey-dev/misskey/develop/packages/backend/test/resources/192.jpg'); | ||
|
|
||
| const fileNoteRes = await api('notes/create', { | ||
| fileIds: [file.id], | ||
| }, bob); | ||
| assert.strictEqual(fileNoteRes.status, 200); | ||
| assert.deepStrictEqual(fileNoteRes.body.createdNote.fileIds, [file.id]); | ||
|
|
||
| // redisに追加されるのを待つ | ||
| await setTimeout(100); | ||
|
|
||
| const res = await api('i/notifications', {}, alice); |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- note-notify.ts around cited lines ---'
sed -n '130,230p' packages/backend/test/e2e/note-notify.ts
echo
echo '--- search for notification polling / retry helpers ---'
rg -n "setTimeout\(100\)|poll|retry|waitFor|eventually|notifications" packages/backend/test -g '*.ts'Repository: misskey-dev/misskey
Length of output: 34789
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- file stats ---'
wc -l packages/backend/test/e2e/note-notify.ts
echo
echo '--- candidate helper files ---'
git ls-files packages/backend/test | sed -n '1,120p'Repository: misskey-dev/misskey
Length of output: 5135
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- search for setTimeout imports/usages in backend e2e tests ---'
rg -n "import .*setTimeout|setTimeout\(" packages/backend/test/e2e -g '*.ts'
echo
echo '--- inspect test utilities for polling helpers ---'
rg -n "waitFor|retry|poll|sleep|delay|settle|promise.*timeout" packages/backend/test packages/backend/src -g '*.ts'Repository: misskey-dev/misskey
Length of output: 50375
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '150,220p' packages/backend/test/e2e/note-notify.tsRepository: misskey-dev/misskey
Length of output: 2658
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- note creation notification call sites ---'
rg -n "createNotification\(|notificationService\." packages/backend/src/core/NoteCreateService.ts packages/backend/src/queue packages/backend/src/core -g '*.ts' | sed -n '1,120p'
echo
echo '--- note-notify test imports ---'
sed -n '1,40p' packages/backend/test/e2e/note-notify.tsRepository: misskey-dev/misskey
Length of output: 5184
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- relevant note create service slice ---'
sed -n '760,860p' packages/backend/src/core/NoteCreateService.ts
echo
echo '--- notification queue / processor slice if any ---'
rg -n "publishNoteStream|queue.*notification|Notification" packages/backend/src/queue packages/backend/src/core -g '*.ts' | sed -n '1,120p'Repository: misskey-dev/misskey
Length of output: 19021
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '780,840p' packages/backend/src/core/NoteCreateService.tsRepository: misskey-dev/misskey
Length of output: 2060
Replace the fixed sleeps with polling in packages/backend/test/e2e/note-notify.ts. notes/create queues notification creation asynchronously, so await setTimeout(100) can still read too early or let a late notification race past the negative check. Use vi.waitFor or another bounded wait on i/notifications instead.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/backend/test/e2e/note-notify.ts` around lines 168 - 190, Replace
both fixed setTimeout(100) delays in the note notification test with bounded
polling of i/notifications using vi.waitFor or the test’s established
equivalent. Ensure the first poll confirms no notification for the file-less
note before proceeding, and the second waits until the file-backed note
notification appears, while preserving the existing assertions and API calls.
⚙️ Backend Diagnostics ReportMemory: After GC
V8 Heap Snapshot Statistics
|
d4db197 to
6d62ff7
Compare
|
non-blocker: (修正ではなく機能追加なので、先にIssueで実装の是非について確認取ったほうが良い可能性はある) |
What
投稿通知設定に「ファイル付き投稿のみ通知」のオプションを追加しました。
これにより「ファイルが添付されたノート」のみの通知を受け取ることができるようになります
Why
ファイルが付いた投稿だけ気軽にチェックしたい人向けに、フィルタできる選択肢を増やしました。
Additional info (optional)
Checklist