fix(wiki): clear stale citation chunks on deletion
This commit is contained in:
@@ -3,6 +3,7 @@ package middleware
|
||||
import (
|
||||
"context"
|
||||
stderrors "errors"
|
||||
"strings"
|
||||
|
||||
apprepo "github.com/Tencent/WeKnora/internal/application/repository"
|
||||
"github.com/Tencent/WeKnora/internal/config"
|
||||
@@ -190,7 +191,8 @@ func KBIDFromChunkIDParam(param string, chunkService ChunkLookup) KBIDResolver {
|
||||
// before this refactor is useful.
|
||||
func isResourceNotFound(err error) bool {
|
||||
return stderrors.Is(err, apprepo.ErrKnowledgeBaseNotFound) ||
|
||||
stderrors.Is(err, ErrResourceNotFound)
|
||||
stderrors.Is(err, ErrResourceNotFound) ||
|
||||
strings.TrimSpace(err.Error()) == "chunk not found"
|
||||
}
|
||||
|
||||
// RequireKBAccess returns a gin.HandlerFunc that resolves KB access
|
||||
|
||||
@@ -245,6 +245,10 @@ func TestRequireKBAccess_NotFound_Aborts(t *testing.T) {
|
||||
require.False(t, ok, "no access should be stashed on failure")
|
||||
}
|
||||
|
||||
func TestIsResourceNotFound_ChunkNotFound(t *testing.T) {
|
||||
require.True(t, isResourceNotFound(errors.New("chunk not found")))
|
||||
}
|
||||
|
||||
func TestRequireKBAccess_SharedKB_RewritesTenantContext(t *testing.T) {
|
||||
share := &stubKBShareForGuard{
|
||||
permission: map[string]types.OrgMemberRole{"kb-shared": types.OrgRoleEditor},
|
||||
|
||||
Reference in New Issue
Block a user