-
Notifications
You must be signed in to change notification settings - Fork 10
feat(llmo-3354): add PATCH endpoint to clear edge status on 404 pages #2174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1303,6 +1303,32 @@ function SitesController(ctx, log, env) { | |
| } | ||
| }; | ||
|
|
||
| const patchPageCitabilityStatus = async (context) => { | ||
| const { siteId } = context.params; | ||
| const { url, httpStatus } = context.data || {}; | ||
|
|
||
| if (!hasText(url)) { | ||
| return badRequest('url is required'); | ||
| } | ||
|
|
||
| if (httpStatus !== 404) { | ||
| return ok({ url, httpStatus, updated: false }); | ||
| } | ||
|
|
||
| const { PageCitability } = dataAccess; | ||
| const record = await PageCitability.findByUrl(url); | ||
| if (!record) { | ||
| return ok({ url, httpStatus, updated: false }); | ||
| } | ||
|
Comment on lines
+1318
to
+1322
|
||
|
|
||
| record.setIsDeployedAtEdge(false); | ||
| record.setCitabilityScore(0); | ||
| await record.save(); | ||
|
|
||
| log.info(`Cleared edge deployment status for 404 page: ${url} (site: ${siteId})`); | ||
| return ok({ url, httpStatus, updated: true }); | ||
| }; | ||
|
|
||
| return { | ||
| createSite, | ||
| getAll, | ||
|
|
@@ -1317,6 +1343,7 @@ function SitesController(ctx, log, env) { | |
| updateSite, | ||
| updateCdnLogsConfig, | ||
| getPageCitabilityCounts, | ||
| patchPageCitabilityStatus, | ||
| getTopPages, | ||
| resolveSite, | ||
| getBrandProfile, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -340,6 +340,7 @@ export default function getRouteHandlers( | |
| 'GET /sites/:siteId/brand-profile': sitesController.getBrandProfile, | ||
| 'POST /sites/:siteId/brand-profile': sitesController.triggerBrandProfile, | ||
| 'GET /sites/:siteId/page-citability/counts': sitesController.getPageCitabilityCounts, | ||
| 'PATCH /sites/:siteId/page-citability/status': sitesController.patchPageCitabilityStatus, | ||
| 'GET /sites/:siteId/top-pages': sitesController.getTopPages, | ||
|
Comment on lines
340
to
344
|
||
| 'GET /sites/:siteId/top-pages/:source': sitesController.getTopPages, | ||
| 'GET /sites/:siteId/top-pages/:source/:geo': sitesController.getTopPages, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -133,6 +133,7 @@ describe('Sites Controller', () => { | |
| 'updateSite', | ||
| 'updateCdnLogsConfig', | ||
| 'getPageCitabilityCounts', | ||
| 'patchPageCitabilityStatus', | ||
| 'getTopPages', | ||
|
Comment on lines
133
to
137
|
||
| 'getSiteMetricsBySource', | ||
| 'getPageMetricsBySource', | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
patchPageCitabilityStatusupdates site-scoped data but does not validatesiteId, load theSite, or enforceaccessControlUtil.hasAccess(site)(unlike other/sites/:siteId/*handlers in this controller). Without this, callers with the route capability may be able to clear records for sites they don’t belong to. Add the standardsiteIdvalidation +Site.findById+ org access check before any update logic.