Spec-driven: article reports & moderation workflow#568
Open
devin-ai-integration[bot] wants to merge 2 commits intomasterfrom
Open
Spec-driven: article reports & moderation workflow#568devin-ai-integration[bot] wants to merge 2 commits intomasterfrom
devin-ai-integration[bot] wants to merge 2 commits intomasterfrom
Conversation
Co-Authored-By: Achal Channarasappa <achal.channarasappa@cognition.ai>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Addresses Devin Review: allows re-reporting after a prior report was resolved, matching spec §5.1 (422 only when an existing PENDING report exists). Co-Authored-By: Achal Channarasappa <achal.channarasappa@cognition.ai>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the article reports & moderation loop (report → queue → resolve) end-to-end per spec. Any authenticated user can file a report against an article; ADMIN users can list pending reports and resolve them as
UPHELD(soft-deletes the article) orDISMISSED.Spec → Implementation mapping
article_reportstable + unique(article_id, reporter_id)+ index(status, created_at)users.role(USER/ADMIN) + seed admin userarticles.deleted_atPOST /articles/{slug}/reportsGET /admin/reports?status=&limit=&offset=POST /admin/reports/{id}/resolve(UPHELD soft-deletes, DISMISSED does not; idempotency guard)AdminReportsApi+ <ref_file file="/home/ubuntu/repos/spring-boot-realworld-example-app/src/main/java/io/spring/application/article/ReportResolutionService.java" />deleted_at IS NULLfilter on every article read endpoint (list, feed, by-slug, cursor paths, author feed, counts)ArticleMapper.xml@PreAuthorize("hasRole('ADMIN')")on admin controller + service-layerisAdmin()check;/admin/**+/articles/*/reportssecured./gradlew spotlessApply testis green locally (all 92 tests pass).Out of scope (per spec §3 / §10)
POST /reportsReview & Testing Checklist for Human
V2__article_reports_and_moderation.sql) — verify it runs cleanly against an empty schema on SQLite and that the seed admin bcrypt hash is acceptable. Deletingdev.dband running./gradlew bootRunis the quickest check.ArticleReadService.xml— I addedA.deleted_at IS NULLto every read path I could find (list, feed, by-slug, cursor-basedfindArticlesWithCursor/findArticlesOfAuthorsWithCursor,countFeedSize,countArticle). Please grep the XML and confirm nothing is missed. Also confirmGET /articles/{slug}/commentsreturns 404 on a soft-deleted article (this works by piggybacking onfindBySlugfiltering — there's no dedicated test for it).GET /articles/{slug}now returns 404 and the article disappears fromGET /articles. The two sides (service marks status, MyBatissoftDeleteArticlesetsdeleted_at, read XML filters) are tested independently but not threaded together in a single integration test.ArticleReportReadService.xml) — LEFT JOINsuserstwice (reporter + moderator) and joinsarticlesfor the slug. Eyeball the result-map aliasing to make sure reporter vs. moderator columns don't alias-collide at runtime.JwtTokenFilternow emitsROLE_USER/ROLE_ADMINauthorities based onuser.isAdmin(). Combined with@EnableGlobalMethodSecurity(prePostEnabled=true)andhasRole("ADMIN")in bothWebSecurityConfigand@PreAuthorize, confirm a USER gets 403 (not 401) on/admin/**and an unauthenticated request gets 401.Notes
spring.jackson.deserialization.UNWRAP_ROOT_VALUE=true+@JsonRootName("report")/@JsonRootName("resolution")to accept{"report": {...}}and{"resolution": {...}}, matching the existingNewArticleParamconvention.MapBindingResult(notBeanPropertyBindingResult) because the rejected field names (reason,report,action,resolution) don't always correspond to bean properties on a concrete target;MapBindingResulttolerates arbitrary field keys and produces the same{"errors": {"<field>": ["..."]}}output viaErrorResourceSerializer./bin/to.gitignore(Eclipse output dir) — unrelated hygiene.Link to Devin session: https://app.devin.ai/sessions/619064b96aa14e2fbd1237208424485f
Requested by: @achalc