fix: render public folder links
This commit is contained in:
@@ -525,6 +525,39 @@ func (r *NodeRepository) GetByPublicToken(ctx context.Context, token string) (*m
|
||||
`, TokenHash(token)).Scan)
|
||||
}
|
||||
|
||||
func (r *NodeRepository) GetPublicDescendant(ctx context.Context, token, nodeID string) (*model.Node, error) {
|
||||
return scanNode(r.pool.QueryRow(ctx, `
|
||||
WITH RECURSIVE root AS (
|
||||
SELECT n.id, n.parent_id, n.node_type, n.title, n.owner_user_id, n.owner_department_id,
|
||||
n.created_by, n.updated_by, n.storage_key, n.original_filename, n.mime_type,
|
||||
n.extension, n.size_bytes, n.office_format, n.external_url, n.version,
|
||||
n.created_at, n.updated_at, n.trashed_at, n.purge_after, n.deleted_at
|
||||
FROM files_public_links l
|
||||
JOIN files_nodes n ON n.id = l.node_id
|
||||
WHERE l.token_hash = $1
|
||||
AND l.revoked_at IS NULL
|
||||
AND l.expires_at > now()
|
||||
AND n.deleted_at IS NULL
|
||||
), descendants AS (
|
||||
SELECT * FROM root
|
||||
UNION ALL
|
||||
SELECT c.id, c.parent_id, c.node_type, c.title, c.owner_user_id, c.owner_department_id,
|
||||
c.created_by, c.updated_by, c.storage_key, c.original_filename, c.mime_type,
|
||||
c.extension, c.size_bytes, c.office_format, c.external_url, c.version,
|
||||
c.created_at, c.updated_at, c.trashed_at, c.purge_after, c.deleted_at
|
||||
FROM files_nodes c
|
||||
JOIN descendants d ON c.parent_id = d.id
|
||||
WHERE c.deleted_at IS NULL
|
||||
)
|
||||
SELECT id, parent_id, node_type, title, owner_user_id, owner_department_id,
|
||||
created_by, updated_by, storage_key, original_filename, mime_type,
|
||||
extension, size_bytes, office_format, external_url, version,
|
||||
'view' AS effective_access, created_at, updated_at, trashed_at, purge_after, deleted_at
|
||||
FROM descendants
|
||||
WHERE id = $2
|
||||
`, TokenHash(token), nodeID).Scan)
|
||||
}
|
||||
|
||||
func (r *NodeRepository) Audit(ctx context.Context, actorID, action, entityType, entityID string, meta string) {
|
||||
if meta == "" {
|
||||
meta = "{}"
|
||||
|
||||
Reference in New Issue
Block a user