mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-08-08 00:18:12 +08:00
Go: add soft fingerprint framework (#17837)
Signed-off-by: Jin Hai <haijin.chn@gmail.com>
This commit is contained in:
@@ -823,6 +823,47 @@ func (h *Handler) UpdateSystemLicenseConfig(c *gin.Context) {
|
||||
common.SuccessWithData(c, result, "System license config updated successfully")
|
||||
}
|
||||
|
||||
type SetSoftFingerprintRequest struct {
|
||||
SoftFingerprint string `json:"fingerprint" binding:"required"`
|
||||
}
|
||||
|
||||
func (h *Handler) SetSoftFingerprint(c *gin.Context) {
|
||||
var req SetSoftFingerprintRequest
|
||||
if err := c.ShouldBindJSON(&req); err != nil {
|
||||
println("JSON bind error: %v (type: %T)", err, err)
|
||||
common.ErrorWithCode(c, common.CodeBadRequest, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
err := h.service.SetSoftFingerprint(req.SoftFingerprint)
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
common.SuccessNoData(c, "SUCCESS")
|
||||
}
|
||||
|
||||
func (h *Handler) ShowSoftFingerprint(c *gin.Context) {
|
||||
softFingerprint, err := h.service.GetSoftFingerprint()
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
common.SuccessWithData(c, softFingerprint, "")
|
||||
}
|
||||
|
||||
func (h *Handler) DeleteSoftFingerprint(c *gin.Context) {
|
||||
err := h.service.DeleteSoftFingerprint()
|
||||
if err != nil {
|
||||
common.ErrorWithCode(c, common.CodeServerError, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
common.SuccessNoData(c, "SUCCESS")
|
||||
}
|
||||
|
||||
type ShowUserActivityRequest struct {
|
||||
Days int `json:"days"`
|
||||
Email string `json:"email"`
|
||||
|
||||
@@ -70,6 +70,10 @@ func RegisterEERouter(protected *gin.RouterGroup, r *Router) {
|
||||
protected.GET("/system/license", r.handler.ShowSystemLicense)
|
||||
protected.PUT("/system/license/config", r.handler.UpdateSystemLicenseConfig)
|
||||
|
||||
protected.POST("/system/soft-fingerprint", r.handler.SetSoftFingerprint)
|
||||
protected.GET("/system/soft-fingerprint", r.handler.ShowSoftFingerprint)
|
||||
protected.DELETE("/system/soft-fingerprint", r.handler.DeleteSoftFingerprint)
|
||||
|
||||
protected.GET("/fingerprint", r.handler.GetFingerprint)
|
||||
protected.POST("/license", r.handler.SetLicense)
|
||||
protected.POST("/license/config", r.handler.UpdateLicenseConfig)
|
||||
|
||||
@@ -402,6 +402,23 @@ func (s *Service) UpdateSystemLicenseConfig(timeRecordSaveInterval, timeRecordTa
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *Service) SetSoftFingerprint(softFingerprint string) error {
|
||||
return errors.New("set soft fingerprint is not supported")
|
||||
}
|
||||
|
||||
func (s *Service) GetSoftFingerprint() (map[string]interface{}, error) {
|
||||
result := map[string]interface{}{
|
||||
"command": "show_soft_fingerprint",
|
||||
"error": "'show soft fingerprint' is not supported",
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (s *Service) DeleteSoftFingerprint() error {
|
||||
return errors.New("delete soft fingerprint is not supported")
|
||||
}
|
||||
|
||||
// ShowUserActivity show user activity for enterprise edition
|
||||
func (s *Service) ShowUserActivity(email string, days int) (map[string]interface{}, error) {
|
||||
// Query user by email
|
||||
|
||||
Reference in New Issue
Block a user