Skip to content

fix: 人の登録したオブジェクトが見れてしまう問題解決#88

Merged
takusandayooo merged 1 commit intomainfrom
object-visibility-leak
Dec 21, 2025
Merged

fix: 人の登録したオブジェクトが見れてしまう問題解決#88
takusandayooo merged 1 commit intomainfrom
object-visibility-leak

Conversation

@takusandayooo
Copy link
Copy Markdown
Contributor

@takusandayooo takusandayooo commented Dec 21, 2025

close #85

Summary by CodeRabbit

  • バグ修正
    • 他のユーザーが作成したアイテムが既に存在する日付を選択した場合、編集画面が開かなくなるように改善しました。これにより、他のユーザーのアイテムが誤って編集されることを防ぎます。

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Dec 21, 2025

コードレビュー報告書 (´ω`) ✨

Walkthrough

おじさんがしっかり確認してきたヨ〜!frontend/src/routes/$roomId/$editId.lazy.tsx の handleDayClick 関数に、他のユーザーが作成したアイテムが既に存在する日付での編集UI起動を防ぐガード処理を追加してますネ 🎵。ルーム開始日からの日数差分でアイテムを特定して、所有権確認後の早期リターン処理になってますダヨ〜。

Changes

Cohort / File(s) 変更内容
Edit UI ガード処理
frontend/src/routes/$roomId/$editId.lazy.tsx
handleDayClick 関数に所有権チェックロジックを追加。他ユーザー作成アイテムの日付では編集UIを開かずにリターン (´ω`)v

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10分くらいネ 🌟

ファイル数が少なくて、追加ロジックも限定的ダヨ〜。ガード処理の日付比較ロジックと所有権チェック部分を確認する程度で大丈夫ですヨ〜。

Possibly related PRs

おじさんこの辺りの要件、詳しいネ✨ 何か質問があったら、一緒に確認してみようカナ?

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PRタイトルは「人の登録したオブジェクトが見れてしまう問題解決」で、コード変更内容(他ユーザーが作成したアイテムが表示されるのを防ぐガード処理)と完全に一致しており、明確で具体的な説明がされている。
Linked Issues check ✅ Passed PR#88が Issue#85 を参照しており、コード変更(handleDayClickにおける他ユーザー所有アイテムへのアクセス防止ガード)は Issue#85 の「人の登録したオブジェクトが見れてしまう問題」に直接対応している。
Out of Scope Changes check ✅ Passed 変更は$roomId/$editId.lazy.tsxファイルの単一の関数(handleDayClick)への限定的な追加で、Issue#85の解決に必要な範囲内に収まっており、スコープ外の変更は見当たらない。
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch object-visibility-leak

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

🚀 Deploy Preview Ready!

Application Status URL Version ID
🎨 frontend ✅ Ready Open Preview 3c952dcd

🔨 Latest Commit: 3039dbd
📅 Deployed at: 2025/12/21 11:09:22 (JST)

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
frontend/src/routes/$roomId/$editId.lazy.tsx (1)

298-312: 他人のアイテム編集をブロックする処理、おじさん確認したヨ〜!✨

セキュリティ修正としてはバッチリだネ🎵(^_^)v でもおじさん気づいちゃったんだけど、ちょっと改善ポイントがあるカナ〜💡

  1. コードの重複があるヨ〜😅 Lines 300-306の日付計算ロジックが、Lines 282-295のtargetCalendarItem useMemoとまったく同じなんダヨネ。おじさん的には既に計算済みのtargetCalendarItemを再利用した方がスッキリすると思うナ〜✨

  2. ユーザーへのフィードバックが足りないカモ🤔 現状だとconsole.logだけで、クリックしても何も起きないから、ユーザーが「あれ?壊れてる?」って思っちゃうかもネ💦 トースト通知とか、視覚的なフィードバックを追加するといいんじゃないカナ〜?おじさん詳しいから、shadcn/uiのuseToastを使う方法も知ってるヨ🌟

🔎 おじさんからの改善提案ダヨ〜

既存のtargetCalendarItemを再利用する案:

  const handleDayClick = (day: number) => {
-   // 他人の作成したアイテムがある場合はクリックを無効化
-   if (room && calendarItems && user) {
-     const startDate = new Date(room.startAt);
-     const existingItem = calendarItems.find((item) => {
-       const openDate = new Date(item.openDate);
-       const diffTime = openDate.getTime() - startDate.getTime();
-       const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24)) + 1;
-       return diffDays === day;
-     });
-
-     if (existingItem && existingItem.userId !== user.id) {
-       console.log("他人のアイテムは編集できません");
-       return;
-     }
-   }
+   // 選択された日のアイテムを一時的に計算(targetCalendarItemはselectedDayに依存するため)
+   const existingItem = room && calendarItems ? calendarItems.find((item) => {
+     const startDate = new Date(room.startAt);
+     const openDate = new Date(item.openDate);
+     const diffTime = openDate.getTime() - startDate.getTime();
+     const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24)) + 1;
+     return diffDays === day;
+   }) : null;
+
+   // 他人の作成したアイテムがある場合はクリックを無効化
+   if (existingItem && user && existingItem.userId !== user.id) {
+     // TODO: トースト通知などでユーザーにフィードバックを提供
+     console.log("他人のアイテムは編集できません");
+     return;
+   }

    const drawerIndex = day - 1;
    setSelectedDay(day);

ユーザーフィードバック追加の例(shadcn/ui useToastを使用):

ファイルの先頭でimport追加:

import { useToast } from "@/hooks/use-toast";

RouteComponentの中で:

function RouteComponent() {
  const { toast } = useToast();
  // ... 他のstate定義

handleDayClick内で:

  if (existingItem && user && existingItem.userId !== user.id) {
    toast({
      title: "編集できません",
      description: "他のユーザーが登録したオブジェクトは編集できません。",
      variant: "destructive",
    });
    return;
  }
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb688e5 and 564f8cd.

📒 Files selected for processing (1)
  • frontend/src/routes/$roomId/$editId.lazy.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{tsx,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{tsx,jsx}: Convert Figma-generated custom Tailwind CSS values to standard Tailwind values: rounded-[24px] → rounded-3xl, gap-[32px] → gap-8, p-[12px] → p-3, text-[20px] → text-xl, etc.
Use design system colors defined in frontend/src/styles.css instead of custom hex values or rgba: use bg-primary, text-foreground, border-border, etc.
Prioritize shadcn/ui components from frontend/src/components/ui/ (Button, Input, Dialog, Field, Label, Calendar, Popover, RadioGroup, Separator, Switch, Spinner) instead of creating custom components
Remove data-node-id attributes from Figma-generated code
Remove non-standard Tailwind classes like content-stretch
Use project default font instead of custom font specifications like font-['Noto_Sans_JP:Bold',sans-serif]
Adjust absolute positioning values (left-[232px] top-[216px]) based on actual use case rather than using Figma-generated coordinates

Files:

  • frontend/src/routes/$roomId/$editId.lazy.tsx

@takusandayooo takusandayooo merged commit cce1b90 into main Dec 21, 2025
5 checks passed
@takusandayooo takusandayooo deleted the object-visibility-leak branch December 21, 2025 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

人の登録したオブジェクトが見れてしまう.

1 participant