Skip to main content

Overview

Content moderation is a critical administrative function in Trippins. Administrators have the responsibility to review user-generated content, remove inappropriate reviews, edit misleading information, and ensure all content meets platform quality and safety standards.
Admin privileges are required for all content moderation operations. The ADMIN role grants full access to review management.

Review Entity Structure

Reviews are the primary form of user-generated content on the platform. Understanding the data structure is essential for effective moderation.
@Entity
public class Review {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "reviewId")
    private Integer reviewId;

    @Column(name = "rating", nullable = false)
    private Integer rating;

    @Column(name = "comment", nullable = false)
    private String comment;

    @ManyToOne
    @JoinColumn(name = "Hotel_code", referencedColumnName = "code", nullable = false)
    private Housing hotel;

    @ManyToOne
    @JoinColumn(name = "user_ID", referencedColumnName = "dni", nullable = false)
    private User user;
}

Key Fields

reviewId
Integer
Auto-generated unique identifier for each review
rating
Integer
Numerical rating given by the user (typically 1-5 stars or 0-100 scale)
comment
String
Text content of the review written by the user
hotel
Housing
Many-to-one relationship with the Housing entity being reviewed
user
User
Many-to-one relationship with the User who wrote the review

Admin Workflows

Viewing All Reviews

Administrators can retrieve all reviews across the platform for moderation purposes.
curl -X GET "https://api.trippins.com/v1/api/reviews" \
  -H "Authorization: Bearer ADMIN_JWT_TOKEN"
Response Example:
[
  {
    "reviewId": 1,
    "rating": 100,
    "comment": "Godin el sitio",
    "hotelCode": 1,
    "userName": "Pepe",
    "userDni": "12345678A"
  },
  {
    "reviewId": 2,
    "rating": 50,
    "comment": "Normalito, la verdad que mejorable",
    "hotelCode": 1,
    "userName": "Pepe",
    "userDni": "12345678A"
  },
  {
    "reviewId": 3,
    "rating": 25,
    "comment": "Llego a saber que no tienen baño y no reservo",
    "hotelCode": 1,
    "userName": "Pepe",
    "userDni": "12345678A"
  }
]

Viewing a Specific Review

Retrieve detailed information about a single review for closer inspection.
curl -X GET "https://api.trippins.com/v1/api/reviews/1" \
  -H "Authorization: Bearer ADMIN_JWT_TOKEN"
Returns 200 OK with the review details, or 404 Not Found if the review doesn’t exist

Filtering Reviews by Property

View all reviews for a specific housing to assess property reputation or identify patterns.
public Page<ReviewDTO> findByHotel(int code, Pageable pageable) {
    Housing house = housingRepository.findByCode(code).get();
    Page<Review> paginatedReview = reviewRepository.findByHotel(house, pageable);

    return paginatedReview.map(review -> {
        ReviewDTO dto = new ReviewDTO();
        dto.setReviewId(review.getReviewId());
        dto.setRating(review.getRating());
        dto.setComment(review.getComment());
        dto.setHotelCode(review.getHotel().getCode());
        dto.setUserDni(review.getUser().getDni());
        dto.setUserName(review.getUser().getName());
        return dto;
    });
}
Use pagination for properties with many reviews to optimize performance and user experience

Editing a Review

Administrators can edit review content to remove inappropriate language, correct misinformation, or address policy violations.
1

Identify Problematic Content

Review the comment and rating to identify violations of community guidelines.
2

Make Necessary Edits

curl -X PUT "https://api.trippins.com/v1/api/reviews/3" \
  -H "Authorization: Bearer ADMIN_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "reviewId": 3,
    "rating": 25,
    "comment": "[Content removed by moderator - violated community guidelines]",
    "hotelCode": 1,
    "userDni": "12345678A",
    "userName": "Pepe"
  }'
3

Log the Moderation Action

Document the reason for modification for transparency and audit purposes.
public ReviewDTO updateReview(Integer id, ReviewDTO review) {
    Optional<Review> originalReview = reviewRepository.findById(id);
    Review finalOriginalReview = originalReview.get();

    finalOriginalReview.setReviewId(review.getReviewId());
    finalOriginalReview.setComment(review.getComment());
    finalOriginalReview.setHotel(
        housingRepository.findByCode(review.getHotelCode()).get()
    );
    finalOriginalReview.setRating(review.getRating());
    finalOriginalReview.setUser(
        userRepository.findById(review.getUserDni()).get()
    );

    reviewRepository.save(finalOriginalReview);
    return new ReviewDTO(finalOriginalReview);
}
Always preserve the original review in an audit log before editing. Consider adding a “modified by admin” indicator.

Deleting a Review

Remove reviews that severely violate platform policies, contain illegal content, or are spam.
curl -X DELETE "https://api.trippins.com/v1/api/reviews/3" \
  -H "Authorization: Bearer ADMIN_JWT_TOKEN"
Returns 204 No Content on successful deletion. This operation is permanent and cannot be undone.

Creating Admin Reviews

Administrators can create reviews for testing, demonstrations, or to add official property assessments.
curl -X POST "https://api.trippins.com/v1/api/reviews" \
  -H "Authorization: Bearer ADMIN_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "rating": 95,
    "comment": "Verified by admin - excellent property with outstanding service",
    "hotelCode": 5,
    "userDni": "ADMIN001",
    "userName": "Platform Administrator"
  }'
Admin-created reviews can be marked with a special indicator to distinguish them from user reviews

Content Moderation Strategies

Automated Filtering

Implement automated checks for common policy violations:

Profanity Detection

Flag reviews containing offensive language for manual review

Spam Detection

Identify repetitive or promotional content patterns

Rating Anomalies

Detect suspiciously high or low ratings from new accounts

Length Validation

Flag unusually short or excessively long reviews

Manual Review Workflow

1

Queue Management

Maintain a queue of flagged reviews that require manual inspection.
2

Assessment

Review the content against community guidelines and platform policies.
3

Action Decision

Decide whether to approve, edit, or remove the review.
4

User Communication

Notify the user if their content was modified or removed, explaining the reason.
5

Documentation

Log all moderation actions for accountability and appeals.

Content Policy Guidelines

  • Hate speech, discrimination, or harassment
  • Personal attacks on staff or other guests
  • Illegal activity or content
  • Spam or promotional material
  • False or misleading information
  • Personally identifiable information (PII) of others
  • Minor profanity that can be censored
  • Potentially identifying information that can be redacted
  • Duplicate content that can be consolidated
  • Formatting issues or readability problems
  • Honest opinions about the stay experience
  • Constructive criticism with specific examples
  • Praise for exceptional service
  • Factual descriptions of amenities and location
  • Photos that comply with privacy standards

Data Initialization

The system includes sample reviews for development and testing:
ReviewService.java
public void initializeComments() {
    Optional<User> defUser = userRepository.findByName("Pepe");
    Optional<Housing> defHousing = housingRepository.findById(1);
    
    List<Review> comments = Arrays.asList(
        new Review(1, 100, "Godin el sitio", defHousing.get(), defUser.get()),
        new Review(2, 50, "Normalito, la verdad que mejorable", 
                   defHousing.get(), defUser.get()),
        new Review(3, 25, "Llego a saber que no tienen baño y no reservo", 
                   defHousing.get(), defUser.get())
    );
    
    reviewRepository.saveAll(comments);
}
This initialization runs on application startup to provide test data for development environments

Security and Permissions

Role-Based Access Control

Review management endpoints require the ADMIN role:
SecurityConfiguration.java
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
    http.authorizeHttpRequests(auth -> auth
        .requestMatchers("/v1/api/reviews/**").hasRole("ADMIN")
        .requestMatchers("/v1/api/admin/**").hasRole("ADMIN")
        // ...
    );
    return http.build();
}

JWT Authentication

All moderation operations require a valid JWT token:
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
Non-admin users attempting to access review management endpoints receive 403 Forbidden

API Reference

Review Management Endpoints

GET /v1/api/reviews
GET
Retrieve all reviews in the systemSecurity: Requires ADMIN roleResponse: 200 OK with array of ReviewDTO objects
GET /v1/api/reviews/{id}
GET
Get a specific review by IDSecurity: Requires ADMIN roleParameters:
  • id (path) - Review ID (e.g., 1)
Response: 200 OK with ReviewDTO object
POST /v1/api/reviews
POST
Create a new reviewSecurity: Requires ADMIN roleBody: ReviewDTO object (reviewId is auto-generated)Response: 201 Created with created ReviewDTO
PUT /v1/api/reviews/{id}
PUT
Update an existing reviewSecurity: Requires ADMIN roleParameters:
  • id (path) - Review ID to update
Body: Complete ReviewDTO objectResponse: 200 OK with updated ReviewDTO
DELETE /v1/api/reviews/{id}
DELETE
Delete a reviewSecurity: Requires ADMIN roleParameters:
  • id (path) - Review ID to delete
Response: 204 No Content

Best Practices

Maintain detailed logs of why content was edited or removed. This supports transparency and helps with appeals.
Create and publish comprehensive content policies so users understand what’s acceptable before posting.
Ensure all moderators apply the same criteria when evaluating content to maintain fairness.
Before editing or deleting, archive the original review in a secure moderation log for audit purposes.
When taking action on a review, notify the user with a clear explanation of the policy violation.
Watch for patterns of fake positive/negative reviews that could indicate manipulation attempts.
When users report inappropriate content, review and take action quickly to maintain platform trust.

Moderation Metrics and Reporting

Key Performance Indicators

Total Reviews

Track overall review volume and growth

Moderation Actions

Count of edited or deleted reviews per period

Average Rating

Platform-wide and per-property rating averages

Response Time

Time from flag to resolution for reported content

Sample Analytics Queries

// Calculate average rating across all reviews
double avgRating = reviewRepository.findAll().stream()
    .mapToInt(Review::getRating)
    .average()
    .orElse(0.0);

// Find properties with low ratings (< 50)
List<Review> lowRatedReviews = reviewRepository.findAll().stream()
    .filter(r -> r.getRating() < 50)
    .collect(Collectors.toList());

// Count reviews per property
Map<Integer, Long> reviewsPerHotel = reviewRepository.findAll().stream()
    .collect(Collectors.groupingBy(
        r -> r.getHotel().getCode(), 
        Collectors.counting()
    ));

Handling User Reports

Report Workflow

1

User Submits Report

User flags a review as inappropriate through the platform UI.
2

Review Enters Queue

Reported review is added to the moderation queue for admin review.
3

Admin Assessment

Admin retrieves the review, reads the report reason, and evaluates the content.
4

Take Action

Admin decides to: approve (no violation), edit (minor issues), or delete (serious violation).
5

Notify Stakeholders

Inform both the reporter and the review author of the outcome.

Common Report Categories

Reviews containing profanity, hate speech, or personal attacks require immediate attention and often deletion.

Integration with Reservation System

Reviews are connected to the reservation system through the valorated flag:
// After user submits review
Review newReview = reviewService.createReview(reviewDTO);

// Update corresponding reservation
Reservation reservation = reservationService.getReservationById(reservationId);
reservation.setValorated(true);
reservationService.updateReservation(reservationId, reservation);
This linkage ensures each stay can only be reviewed once and tracks review completion rates

Troubleshooting

Cause: The review ID doesn’t exist in the databaseSolution: Verify the ID is correct using the GET all reviews endpoint
Cause: The hotelCode in the update doesn’t match an existing housingSolution: Ensure the hotelCode corresponds to a valid Housing entity in the database
Cause: The userDni doesn’t match an existing userSolution: Verify the user exists before updating the review
Cause: No constraint preventing multiple reviews from same user for same propertySolution: Implement business logic to check existing reviews before creation
Cause: No validation on rating values (should be 0-100 or 1-5)Solution: Add validation constraints in the DTO and entity layers

Advanced Moderation Features

Sentiment Analysis

Consider implementing automated sentiment analysis to:
  • Flag reviews with extreme negative sentiment for priority review
  • Detect sarcasm or misleading positive reviews
  • Identify genuine constructive criticism vs. malicious content
  • Generate property reputation scores beyond simple ratings

Machine Learning Integration

Train models to automatically categorize reviews by topic (cleanliness, service, location, amenities).

Reviewer Reputation System

Track user review history to establish trust scores:
// Example: Calculate user's review trustworthiness
public double calculateReviewerTrustScore(String userDni) {
    List<Review> userReviews = reviewRepository.findByUserDni(userDni);
    
    // Factors: number of reviews, consistency, verified stays, etc.
    int reviewCount = userReviews.size();
    double consistencyScore = calculateRatingConsistency(userReviews);
    int verifiedStays = getVerifiedReservationCount(userDni);
    
    return (reviewCount * 0.3) + (consistencyScore * 0.4) + (verifiedStays * 0.3);
}
Review moderation must balance platform safety with free speech principles. Consult legal counsel when developing moderation policies.

Data Privacy

  • Store moderation logs securely with access controls
  • Redact personal information before archiving deleted content
  • Comply with GDPR/CCPA right-to-deletion requests
  • Maintain transparency in moderation decision-making

Liability Protection

  • Clearly state in Terms of Service that reviews are user opinions
  • Implement notice-and-takedown procedures for defamatory content
  • Document good-faith moderation efforts
  • Respond promptly to legal requests for content removal

Build docs developers (and LLMs) love