🔒 feat: Add user-configurable IP logging for consume and error logs
- Add IP field to Log model with database index and default empty value - Implement conditional IP recording based on user setting in RecordConsumeLog and RecordErrorLog - Add UserSettingRecordIpLog constant and update user settings API to handle record_ip_log field - Create dedicated "IP记录" tab in personal settings under "其他设置" section - Add IP column to logs table with help tooltip explaining recording conditions - Make IP column visible to all users (not admin-only) with proper filtering for consume/error log types - Restrict display of use_time and retry columns to consume and error log types only - Update personal settings UI structure: rename "通知设置" to "其他设置" to accommodate new functionality - Add proper translation support and maintain consistent styling across components The IP logging feature is disabled by default and only records client IP addresses for consume (type 2) and error (type 5) logs when explicitly enabled by users in their personal settings.
This commit is contained in:
@@ -943,6 +943,7 @@ type UpdateUserSettingRequest struct {
|
||||
WebhookSecret string `json:"webhook_secret,omitempty"`
|
||||
NotificationEmail string `json:"notification_email,omitempty"`
|
||||
AcceptUnsetModelRatioModel bool `json:"accept_unset_model_ratio_model"`
|
||||
RecordIpLog bool `json:"record_ip_log"`
|
||||
}
|
||||
|
||||
func UpdateUserSetting(c *gin.Context) {
|
||||
@@ -1019,6 +1020,7 @@ func UpdateUserSetting(c *gin.Context) {
|
||||
constant.UserSettingNotifyType: req.QuotaWarningType,
|
||||
constant.UserSettingQuotaWarningThreshold: req.QuotaWarningThreshold,
|
||||
"accept_unset_model_ratio_model": req.AcceptUnsetModelRatioModel,
|
||||
constant.UserSettingRecordIpLog: req.RecordIpLog,
|
||||
}
|
||||
|
||||
// 如果是webhook类型,添加webhook相关设置
|
||||
|
||||
Reference in New Issue
Block a user