feat(contracts): implement content flagging mechanism#271
Merged
Kaylahray merged 3 commits intogeevapp:mainfrom Mar 30, 2026
Merged
feat(contracts): implement content flagging mechanism#271Kaylahray merged 3 commits intogeevapp:mainfrom
Kaylahray merged 3 commits intogeevapp:mainfrom
Conversation
3m1n3nc3
requested changes
Mar 30, 2026
Contributor
3m1n3nc3
left a comment
There was a problem hiding this comment.
Please resolve the conflicts
Kaylahray
approved these changes
Mar 30, 2026
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.
Pull Request Template
Description
What was added
types.rsDataKey::FlagRecord(u64, Address)— tracks whether a specific user has flagged a specific content IDDataKey::FlagCount(u64)— running tally of total flags per content IDError::AlreadyFlagged— returned when a user attempts to flag the same ID more than oncegovernance.rs(new)A new
GovernanceContractwith three public functions:flag_content(env, user, target_id)user. Requires auth, rejects duplicates, increments count, emitsContentFlaggedevent.get_flag_count(env, target_id)has_flagged(env, user, target_id)lib.rsgovernancemodule and re-exportedGovernanceContract/GovernanceContractClient.Anti-spam design
Each flag is keyed by
(target_id, user_address)in persistent storage. A second call from the same user on the same ID returnsError::AlreadyFlaggedimmediately, making spam-flagging impossible at the contract level.Tests (
test.rs)test_flag_content_increments_counttest_flag_content_multiple_userstest_flag_content_duplicate_panicstest_has_flagged_returns_false_before_flaghas_flaggedis false before any flagtest_flag_counts_are_independent_per_idAll 39 tests pass.
Checklist
npx prisma generateafter schema changesnpx prisma migrate devornpx prisma migrate deployas appropriatePost-Merge Steps for Maintainers
If this PR includes changes to the Prisma schema:
Run the following command to apply the migration to your database:
or, for local development:
Ensure your CI pipeline runs the migration before tests (add this step if missing):
Make sure the database user in CI has permission to run migrations.
If you have any questions, please comment on this PR.
this PR closes #210