Skip to content

feat: block project owners from self-reviewing via service guard and … - #325

Open
Challmejosh wants to merge 1 commit into
HubDApp:mainfrom
Challmejosh:review-owner-project
Open

feat: block project owners from self-reviewing via service guard and …#325
Challmejosh wants to merge 1 commit into
HubDApp:mainfrom
Challmejosh:review-owner-project

Conversation

@Challmejosh

@Challmejosh Challmejosh commented Jul 30, 2026

Copy link
Copy Markdown

Closes #235


Summary

Project owners could previously submit ratings for their own projects, potentially biasing scores. This PR enforces the restriction at both the UI and service layers, and adds a dedicated hook to centralise the ownership check.

Changes

services/review/review.service.ts

  • Added optional ownerAddress parameter to addReview
  • Guards against self-reviews before any other validation or storage write; returns a structured ReviewValidationError so callers need no changes to their error-handling

hooks/useIsProjectOwner.ts (new)

  • Reusable hook that compares the connected wallet's publicKey against a project's ownerAddress
  • Returns false safely when either value is absent (disconnected wallet, unclaimed project)

app/projects/[id]/page.tsx

  • Replaces the inline isOwner expression with useIsProjectOwner
  • Passes project.ownerAddress through to reviewService.addReview so the service-layer guard fires even if the UI is bypassed

Tests

Suite New cases Result
review.service.test.ts — self-review guard 4
useIsProjectOwner.test.ts 6
Full existing suite 29

39 / 39 tests pass.

Acceptance criteria

Criterion Status
Owners cannot submit normal public ratings for their own project ✅ Blocked at service layer
The blocked state explains why ✅ Existing blue info-banner shown to owners
Tests cover owner and non-owner review attempts self-review guard describe block

@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@Challmejosh Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Challmejosh
Challmejosh force-pushed the review-owner-project branch from 7122b0c to 2d262ef Compare August 4, 2026 08:45
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.

Prevent users from reviewing their own projects

2 participants