Skip to content

Conversation

@zy84338719
Copy link
Owner

No description provided.

Copilot AI review requested due to automatic review settings September 22, 2025 09:55
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 a comprehensive transfer log feature with auditing capabilities for upload and download activities, along with polished storage UI improvements. The changes include both frontend components for managing transfer logs and backend services for tracking and retrieving audit data.

  • Adds a new transfer logs tab with filtering, search, and pagination functionality
  • Implements backend services for recording and retrieving upload/download audit logs
  • Enhances storage management UI with improved visual design and better status indicators
  • Adds configuration options for requiring login for uploads and downloads

Reviewed Changes

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

Show a summary per file
File Description
themes/2025/admin/js/transfer-logs.js New JavaScript module for transfer logs management with API integration and pagination
themes/2025/admin/js/storage-simple.js Enhanced storage UI with improved visual design and status indicators
themes/2025/admin/js/main.js Added transfer logs tab initialization and improved JSON response handling
themes/2025/admin/js/config-simple.js Added login requirement configuration options for uploads and downloads
themes/2025/admin/index.html Added transfer logs tab and login requirement checkboxes in configuration
themes/2025/admin/css/storage.css Complete visual refresh of storage management interface
themes/2025/admin/css/admin-modern.css Added styling for transfer logs table and controls
internal/services/share/logging.go New service for tracking upload/download operations with audit logging
internal/services/share/file.go Integrated upload logging into file sharing workflow
internal/services/admin/config.go Added support for login requirement configuration
internal/services/admin/audit.go New service for retrieving transfer logs with filtering
internal/routes/admin.go Added transfer logs API endpoint
internal/repository/transfer_log.go New repository for transfer log data access and querying
internal/repository/manager.go Added transfer log repository to manager
internal/models/web/admin.go Added transfer log response models
internal/models/models.go Added transfer log model aliases
internal/models/db/transfer_log.go New database model for transfer logs
internal/handlers/storage.go Improved storage path handling for local storage
internal/handlers/share.go Added login requirements and download logging
internal/handlers/admin.go Added transfer logs API handler
internal/database/database.go Added transfer log table migration
internal/config/transfer_config.go Added login requirement configuration fields
docs/config.new.yaml Updated configuration template with login requirements
config.yaml Updated default configuration with login requirements

}
} catch (error) {
console.error('加载传输日志失败:', error);
const message = (error && error.message) ? error.message.substring(0, 200) : '未知错误';
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

The error message truncation logic is inconsistent with the pattern used in main.js for error handling. Consider extracting this into a shared utility function for consistent error message formatting across the application.

Copilot uses AI. Check for mistakes.
Comment on lines +182 to +189
window.initTransferLogsTab = function () {
ensureBindings();
load(1);
};

window.applyTransferLogFilters = applyFilters;
window.refreshTransferLogs = refresh;
window.changeTransferLogPage = changePage;
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

Multiple global function assignments should be grouped into a single namespace object to avoid polluting the global scope. Consider using a pattern like window.TransferLogs = { init: ..., applyFilters: ..., refresh: ..., changePage: ... }.

Suggested change
window.initTransferLogsTab = function () {
ensureBindings();
load(1);
};
window.applyTransferLogFilters = applyFilters;
window.refreshTransferLogs = refresh;
window.changeTransferLogPage = changePage;
window.TransferLogs = {
init: function () {
ensureBindings();
load(1);
},
applyFilters: applyFilters,
refresh: refresh,
changePage: changePage
};

Copilot uses AI. Check for mistakes.
Comment on lines +725 to +726
if (typeof initTransferLogsTab === 'function') {
initTransferLogsTab();
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

The function name 'initTransferLogsTab' doesn't follow the established naming convention. Other cases use function names like 'loadMCPConfig' that start with action verbs. Consider renaming to 'loadTransferLogsTab' for consistency.

Suggested change
if (typeof initTransferLogsTab === 'function') {
initTransferLogsTab();
if (typeof loadTransferLogsTab === 'function') {
loadTransferLogsTab();

Copilot uses AI. Check for mistakes.
if s.repositoryManager.User != nil {
if user, err := s.repositoryManager.User.GetByID(*userID); err == nil {
logEntry.Username = user.Username
} else if err != nil {
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

The condition else if err != nil is redundant since the if condition already checks err == nil. The else clause will only execute when err != nil. Simplify to just else.

Suggested change
} else if err != nil {
} else {

Copilot uses AI. Check for mistakes.
Comment on lines 1181 to 1182
operation := strings.TrimSpace(c.DefaultQuery("operation", ""))
search := strings.TrimSpace(c.DefaultQuery("search", ""))
Copy link

Copilot AI Sep 22, 2025

Choose a reason for hiding this comment

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

Calling strings.TrimSpace on empty default values is unnecessary since empty strings don't have leading/trailing whitespace. Consider checking for non-empty values before trimming or moving the trimming logic into the service layer.

Suggested change
operation := strings.TrimSpace(c.DefaultQuery("operation", ""))
search := strings.TrimSpace(c.DefaultQuery("search", ""))
operation := c.DefaultQuery("operation", "")
if operation != "" {
operation = strings.TrimSpace(operation)
}
search := c.DefaultQuery("search", "")
if search != "" {
search = strings.TrimSpace(search)
}

Copilot uses AI. Check for mistakes.
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

Codex Review: Here are some suggestions.

func (h *ShareHandler) DownloadFile(c *gin.Context) {
code := c.Query("code")
if code == "" {
common.BadRequestResponse(c, "文件代码不能为空")
return
}
// 获取用户ID(如果已登录)
var userID *uint
if uid, exists := c.Get("user_id"); exists {
id := uid.(uint)
userID = &id
}
fileCode, err := h.service.GetFileByCodeWithAuth(code, userID)

[P1] Enforce download login requirement

The new transfer.download.require_login config is validated and exposed, but DownloadFile never checks it before streaming the file. Even with the flag set to 1, anonymous users can download any share because the handler only records logs after download and does not gate access. Administrators who turn on the new option will believe downloads require authentication but the endpoint remains public, so the feature does not provide the intended protection.


Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

@zy84338719 zy84338719 merged commit 08b16c8 into main Sep 24, 2025
4 checks passed
@zy84338719 zy84338719 deleted the feature/login-gates branch September 24, 2025 14:33
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