Skip to content

Conversation

@fulleni
Copy link
Member

@fulleni fulleni commented Nov 30, 2025

Status

READY

Description

This pull request significantly enhances the application's backend capabilities by introducing robust support for user-generated content. It establishes new data models for engagements and reports, along with a comprehensive system for managing user action limits and permissions. The changes streamline how data models are configured and accessed through generic API endpoints, laying the groundwork for interactive user features while maintaining security and control.

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

- Update core package reference from 3779a8b1dbd8450d524574cf5376b7cc2ed514e7 to 4ffe8833b8a042b2b3b68550f682c5aa902a5ccc
- Update both pubspec.lock and pubspec.yaml files
    Introduces new permission constants for managing user-generated content. This includes permissions for creating, reading, updating, and deleting engagements and reports, scoped to the owner.

    These permissions are essential for securing the new UGC endpoints and ensuring users can only manage their own content.
    Assigns the new engagement and report permissions to the `_appGuestUserPermissions` set. Since guest, standard, and premium users all inherit from this base set, this change grants all application users the ability to create and manage their own engagements and reports.

    This is a necessary step to allow users to interact with the new community features.
    Instantiates `DataMongodb` clients and `DataRepository` instances for the `Engagement` and `Report` models. These new repositories are then provided to the application's dependency injection container.

    This makes the services for managing engagements and reports available throughout the application, particularly for the generic data API routes.
    Adds `ModelConfig` entries for 'engagement' and 'report' to the `modelRegistry`. This configuration defines the authorization rules for each model, such as requiring ownership for all operations and using specific `_owned` permissions.

    Registering these models makes them available through the generic `/api/v1/data` endpoint, enabling clients to perform CRUD operations on them.
    Updates the `_ensureIndexes` method in the `DatabaseSeedingService` to create indexes on the `engagements` and `reports` collections.

    Indexes are added for `userId` to optimize fetching user-specific content, and for `entityId` and `entityType` to efficiently query for content related to a specific item (e.g., all engagements for a headline).
…mit service for ugc

Expands the `UserActionLimitService` interface with new, correctly named methods: `checkEngagementCreationLimit` and `checkReportCreationLimit`.

This change correctly frames the limit checks around the primary entities (`Engagement`, `Report`) being created, rather than their sub-components. The `checkEngagementCreationLimit` method now accepts the `Engagement` object to allow for conditional logic based on its content (e.g., presence of a comment).
    Overhauls the `DefaultUserActionLimitService` to correctly enforce daily limits for engagements and reports. The service now injects the `Engagement` and `Report` repositories to perform database counts.

    - `checkEngagementCreationLimit`: Checks the `reactionsPerDay` limit on every call. If the engagement contains a comment, it also checks the `commentsPerDay` limit.
    - `checkReportCreationLimit`: Checks the `reportsPerDay` limit.

    This centralizes all UGC limit logic within the service layer, adhering to the established architectural pattern.
- Register read, readAll, create, update, and delete operations for Engagement and Report entities
- Implement custom creators for engagement and report with security and limit checks
- Update existing updaters and deleters for other entities
- Rename UserPreferenceLimitService to UserActionLimitService for better naming consistency
…ervice

- Update import statement for UserActionLimitService
- Replace UserPreferenceLimitService with UserActionLimitService in middleware
- Update _getLimitsForRole to _getPreferenceLimitsForRole
- Add const keyword to ForbiddenException instances
@fulleni fulleni added this to the Market Contender Edition milestone Nov 30, 2025
@fulleni fulleni self-assigned this Nov 30, 2025
@fulleni fulleni linked an issue Nov 30, 2025 that may be closed by this pull request
@gemini-code-assist
Copy link

gemini-code-assist bot commented Nov 30, 2025

Summary of Changes

Hello @fulleni, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the application's backend capabilities by introducing robust support for user-generated content. It establishes new data models for engagements and reports, along with a comprehensive system for managing user action limits and permissions. The changes streamline how data models are configured and accessed through generic API endpoints, laying the groundwork for interactive user features while maintaining security and control.

Highlights

  • User Generated Content (UGC) Handling: Introduced new Engagement and Report models to support user-generated content like reactions, comments, and reporting mechanisms.
  • User Action Limit Service Refactoring: The UserPreferenceLimitService has been refactored and renamed to UserActionLimitService. This service now centralizes the enforcement of various user-related limits, including those for new engagements and reports, based on user roles and remote configuration.
  • Permissions and Role Management: New permissions for creating, reading, updating, and deleting engagements and reports have been defined and integrated into the existing role-based access control system, ensuring proper authorization for UGC.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces functionality for user-generated content, specifically engagements (reactions/comments) and reports. The changes include adding new data models, database collections and permissions which is a solid architectural improvement. The UserPreferenceLimitService has been refactored into a more general UserActionLimitService to handle new action-based limits. My review includes suggestions to improve testability by abstracting DateTime.now() and to enhance code clarity by removing redundant type casts in the new model registry.

@fulleni fulleni merged commit ef5a90a into main Nov 30, 2025
1 check failed
@fulleni fulleni deleted the feat/handle-user-generated-content branch November 30, 2025 07:41
@github-project-automation github-project-automation bot moved this from Backlog to Done in Flutter News App Project Nov 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

feat: Expose Comment Endpoints

2 participants