Skip to content

Image upload - #25

Merged
prakashm88 merged 5 commits into
mainfrom
image-upload
Sep 14, 2025
Merged

Image upload#25
prakashm88 merged 5 commits into
mainfrom
image-upload

Conversation

@prakashm88

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings September 2, 2025 18:31

Copilot AI left a comment

Copy link
Copy Markdown

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 implements a comprehensive image upload feature for the DocVerse platform. The changes enable users to upload images directly within the markdown editor and manage them through a gallery interface.

  • Image upload functionality with database storage and tagging
  • Enhanced markdown editor with custom image upload command
  • Database migration system and new tables for file storage
  • Tag restrictions for admin-only tags like "challenges"

Reviewed Changes

Copilot reviewed 25 out of 30 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
app/src/types/index.ts Added Challenge interface and new post status types
app/src/services/api-client.ts Added file upload endpoints and challenge management
app/src/pages/create-post.tsx Integrated image upload component with markdown editor
app/src/components/ui/* New UI components for image upload, gallery, and tagging
apis/src/routers/files.py New file upload router with authentication and tagging
apis/src/services/database/* Database migration system and file storage operations
apis/bootstrap.sql Added content_uploads and site_settings tables
Files not reviewed (1)
  • app/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)

app/src/hooks/use-challenges.ts:1

  • Use strict equality (===) instead of loose equality (==) for comparison to avoid type coercion issues.
import { useState, useMemo, useCallback, useEffect } from 'react';

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

Comment on lines +60 to +76
// Set up global callback for MDEditor image insertion
useEffect(() => {
console.log('Setting up global callbacks...');
window.insertMarkdownCallback = handleImageInsert;
window.showImageUploadDialog = () => {
console.log('showImageUploadDialog called!');
setShowImageDialog(true);
};

return () => {
delete window.insertMarkdownCallback;
delete window.showImageUploadDialog;
};
}, []);

// Create custom commands for MDEditor
const imageUploadCommand = createImageUploadCommand();

Copilot AI Sep 2, 2025

Copy link

Choose a reason for hiding this comment

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

Adding functions to the global window object is an anti-pattern that can lead to memory leaks and naming conflicts. Consider using React refs or a more React-friendly communication pattern between the markdown editor and the upload component.

Suggested change
// Set up global callback for MDEditor image insertion
useEffect(() => {
console.log('Setting up global callbacks...');
window.insertMarkdownCallback = handleImageInsert;
window.showImageUploadDialog = () => {
console.log('showImageUploadDialog called!');
setShowImageDialog(true);
};
return () => {
delete window.insertMarkdownCallback;
delete window.showImageUploadDialog;
};
}, []);
// Create custom commands for MDEditor
const imageUploadCommand = createImageUploadCommand();
// Use React state and props for dialog and markdown insertion
// Remove global window callback setup/cleanup.
// Create custom commands for MDEditor
const imageUploadCommand = createImageUploadCommand({
onShowDialog: () => setShowImageDialog(true),
onInsertMarkdown: handleImageInsert,
});

Copilot uses AI. Check for mistakes.
Comment thread apis/src/routers/files.py
Comment on lines +92 to +96
logger.info(f"👤 Current user: {current_user}")

# Check if current_user has required fields
if 'user_id' not in current_user:
logger.error(f"❌ Current user missing 'user_id' field: {current_user}")

Copilot AI Sep 2, 2025

Copy link

Choose a reason for hiding this comment

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

Logging the entire current_user object may expose sensitive user information in logs. Consider logging only the user ID or a sanitized version of the user data.

Suggested change
logger.info(f"👤 Current user: {current_user}")
# Check if current_user has required fields
if 'user_id' not in current_user:
logger.error(f"❌ Current user missing 'user_id' field: {current_user}")
logger.info(f"👤 Current user ID: {current_user.get('user_id', 'unknown')}")
# Check if current_user has required fields
if 'user_id' not in current_user:
logger.error(f"❌ Current user missing 'user_id' field. User ID: {current_user.get('user_id', 'unknown')}")

Copilot uses AI. Check for mistakes.
logger = logging.getLogger(__name__)

# Cache configuration
CACHE_DIR = Path("/tmp/docverse_files")

Copilot AI Sep 2, 2025

Copy link

Choose a reason for hiding this comment

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

Hard-coded cache directory path should be configurable through environment variables or settings to support different deployment environments and avoid potential permission issues.

Copilot uses AI. Check for mistakes.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@prakashm88
prakashm88 merged commit 8d425f9 into main Sep 14, 2025
1 check passed
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