fix(page-data): isolate owner API from public pages
This commit is contained in:
@@ -501,18 +501,21 @@ export function createPageDataPublicService(deps = {}) {
|
||||
});
|
||||
}
|
||||
|
||||
async function softDeleteRow(pageId, datasetName, rowId, req) {
|
||||
async function deleteRow(pageId, datasetName, rowId, req) {
|
||||
return runPublicAction(async () => {
|
||||
const publication = await queryPublication(pageId);
|
||||
const policy = await loadPolicy(publication);
|
||||
const deleteAction = policyAllowsAction(policy, datasetName, 'hard_delete')
|
||||
? 'hard_delete'
|
||||
: 'soft_delete';
|
||||
const access = resolveAccessContext({
|
||||
publication,
|
||||
policy,
|
||||
req,
|
||||
action: 'soft_delete',
|
||||
action: deleteAction,
|
||||
datasetName,
|
||||
});
|
||||
enforceRateLimit(req, publication, 'soft_delete');
|
||||
enforceRateLimit(req, publication, deleteAction);
|
||||
const { ownerService, effective, policyDataset } = await resolveEffectiveDataset(
|
||||
publication.user_id,
|
||||
policy,
|
||||
@@ -531,13 +534,15 @@ export function createPageDataPublicService(deps = {}) {
|
||||
}
|
||||
: null,
|
||||
);
|
||||
const result = await ownerService.softDeleteRowForDataset(effective, rowId, {
|
||||
const result = deleteAction === 'hard_delete'
|
||||
? await ownerService.hardDeleteRowForDataset(effective, rowId, { rowScope })
|
||||
: await ownerService.softDeleteRowForDataset(effective, rowId, {
|
||||
deletedBy: access.session?.sessionId ?? 'public',
|
||||
rowScope,
|
||||
});
|
||||
recordPublicLog(resolveWorkspaceRoot(publication.user_id), publication, {
|
||||
datasetName,
|
||||
action: 'soft_delete',
|
||||
action: deleteAction,
|
||||
rowId,
|
||||
req,
|
||||
session: access.session,
|
||||
@@ -781,7 +786,8 @@ export function createPageDataPublicService(deps = {}) {
|
||||
getStats,
|
||||
insertRow,
|
||||
updateRow,
|
||||
softDeleteRow,
|
||||
deleteRow,
|
||||
softDeleteRow: deleteRow,
|
||||
getOwnerPolicy,
|
||||
saveOwnerPolicy,
|
||||
saveOwnerPolicyFromPublish,
|
||||
|
||||
Reference in New Issue
Block a user