Skip to content

Conversation

@eugbyte
Copy link
Owner

@eugbyte eugbyte commented Oct 4, 2025

No description provided.

@eugbyte eugbyte force-pushed the chore/image-moderation branch from c9d636b to 09ebca5 Compare October 4, 2025 14:25
@eugbyte eugbyte requested a review from Copilot October 4, 2025 14:31
@eugbyte eugbyte marked this pull request as ready for review October 4, 2025 14:31
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds image content moderation functionality using Azure AI Content Safety to validate uploaded images before storing them. It integrates Azure AI Foundry's content safety services to automatically check gathering cover images for inappropriate content.

  • Added Azure AI Content Safety integration with configuration and service client setup
  • Implemented content moderation logic that analyzes images and blocks unsafe content
  • Consolidated configuration files by moving development settings to main appsettings.json

Reviewed Changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/Evently.Server/Features/Files/Services/ObjectStorageService.cs Added content safety client and moderation logic to analyze images
src/Evently.Server/Features/Gatherings/Controllers/GatheringsController.cs Added content moderation check before uploading cover images
src/Evently.Server/Common/Domains/Models/Settings.cs Added AzureAIFoundry configuration model
src/Evently.Server/Common/Domains/Interfaces/IObjectStorageService.cs Added PassesContentModeration method to interface
src/Evently.Server/Evently.Server.csproj Added Azure.AI.ContentSafety package reference
src/Evently.Server/appsettings.json Added configuration sections for Azure AI Foundry and other services
src/Evently.Server/appsettings.Development.json Removed all content (consolidated into main appsettings)
src/evently.client/src/lib/services/gathering-service.ts Fixed handling of empty gathering category details array
src/evently.client/src/lib/components/card.tsx Added null check for image source before using placeholder images

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 85 to 89
int? score = result.CategoriesAnalysis
.Select(v => v.Severity)
.Aggregate((a, b) => a + b)
?? 0;
return result.CategoriesAnalysis.Count != 0 && score == 0;
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

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

The logic for determining content safety is incorrect. When CategoriesAnalysis.Count is 0, the method returns false (content is unsafe), but when there are no categories to analyze, the content should be considered safe. Also, the aggregate will throw an exception if the collection is empty.

Suggested change
int? score = result.CategoriesAnalysis
.Select(v => v.Severity)
.Aggregate((a, b) => a + b)
?? 0;
return result.CategoriesAnalysis.Count != 0 && score == 0;
if (result.CategoriesAnalysis.Count == 0)
{
// No categories to analyze, consider content safe
return true;
}
int score = result.CategoriesAnalysis.Sum(v => v.Severity);
return score == 0;

Copilot uses AI. Check for mistakes.
BinaryData binaryData = await coverImg.ToBinaryData();
bool isContentSafe = await objectStorageService.PassesContentModeration(binaryData);
if (!isContentSafe) {
return new Uri(string.Empty, UriKind.RelativeOrAbsolute);
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

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

Returning an empty URI when content moderation fails is misleading. Consider throwing an exception or returning a specific error response to clearly indicate the image was rejected due to content policy violations.

Copilot uses AI. Check for mistakes.
Comment on lines 17 to 18
"ContentSafetyKey": "<ai-foundary-content-safety-key>",
"ContentSafetyEndpoint": "<ai-foundary-content-safety-api>"
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

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

Corrected spelling of 'foundary' to 'foundry'.

Suggested change
"ContentSafetyKey": "<ai-foundary-content-safety-key>",
"ContentSafetyEndpoint": "<ai-foundary-content-safety-api>"
"ContentSafetyKey": "<ai-foundry-content-safety-key>",
"ContentSafetyEndpoint": "<ai-foundry-content-safety-api>"

Copilot uses AI. Check for mistakes.
@eugbyte eugbyte force-pushed the chore/image-moderation branch from b8b8cd3 to df69999 Compare October 4, 2025 14:51
@eugbyte eugbyte requested a review from Copilot October 4, 2025 15:03
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +88 to +89
.Aggregate((a, b) => a + b)
?? 0;
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

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

The null-conditional operator ?? is applied to the wrong expression. If result.CategoriesAnalysis is empty, Aggregate will throw an exception before the null check. Consider using DefaultIfEmpty() or checking if the collection is empty first.

Suggested change
.Aggregate((a, b) => a + b)
?? 0;
.DefaultIfEmpty(0)
.Aggregate((a, b) => a + b);

Copilot uses AI. Check for mistakes.
AnalyzeImageResult result = response.Value;
int? score = result.CategoriesAnalysis
.Select(v => v.Severity)
.Aggregate((a, b) => a + b)
Copy link

Copilot AI Oct 4, 2025

Choose a reason for hiding this comment

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

The aggregation logic assumes all severity values are integers that can be summed. Consider using Sum() instead of Aggregate((a, b) => a + b) for clarity and better null handling.

Suggested change
.Aggregate((a, b) => a + b)
.Sum()

Copilot uses AI. Check for mistakes.
@eugbyte eugbyte merged commit 37f3351 into main Oct 4, 2025
3 checks passed
@eugbyte eugbyte deleted the chore/image-moderation branch October 4, 2025 15:06
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.

2 participants