mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-29 08:00:06 +00:00
place-enrichment: a community summary the request carried stays out of the shared cache
Like an OpenStreetMap summary, a summary credited to the community is read straight off the request's details, so any caller could have it served to every user of the instance for a week under the community's name.
This commit is contained in:
@@ -454,15 +454,18 @@ export class PlaceEnrichmentService {
|
||||
rating: collectRating(details) ?? collectRating(osmDetails),
|
||||
};
|
||||
// The cache is keyed by place and language, so a row written here is what
|
||||
// every user of the instance sees for a week. An OpenStreetMap summary and
|
||||
// a menu link are the two things read straight off the request's own
|
||||
// `details` that become a link on every screen, and when the request
|
||||
// carried those, the text and the link are the caller's word rather than
|
||||
// the map's: fine to answer them with, not to serve to everyone else. The
|
||||
// row simply is not written, and the next request computes its own answer.
|
||||
// A summary or a link the lookup here fetched itself is the map's and keeps.
|
||||
// every user of the instance sees for a week. An OpenStreetMap or community
|
||||
// summary and a menu link are the things read straight off the request's
|
||||
// own `details` that end up on every screen, and when the request carried
|
||||
// those, the text and the link are the caller's word rather than the
|
||||
// map's: fine to answer them with, not to serve to everyone else. The row
|
||||
// simply is not written, and the next request computes its own answer. A
|
||||
// summary or a link the lookup here fetched itself is the map's and keeps.
|
||||
const fromCaller =
|
||||
req.details != null && (description?.source === 'osm' || ownFacts.some((fact) => fact.url != null));
|
||||
req.details != null &&
|
||||
(description?.source === 'osm' ||
|
||||
description?.source === 'community' ||
|
||||
ownFacts.some((fact) => fact.url != null));
|
||||
if (!fromCaller) await this.writeCache(placeId, lang, { ...result, cv: communityVersion(placeId, details) });
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -632,6 +632,18 @@ describe("the description on the place's own website", () => {
|
||||
expect(mockUpsertEntry).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('ENRICH-122: a community summary the request carried is answered, but not cached for everyone', async () => {
|
||||
// The community credit is read off the details as well, so a request can
|
||||
// claim it for any text; the sender sees it, the row is not written.
|
||||
const out = await make(mapsStub()).enrich(1, {
|
||||
...OSM_REQ,
|
||||
details: { source: 'openstreetmap', summary: 'Buchung nur über phish.example', summary_source: 'community' },
|
||||
});
|
||||
|
||||
expect(out.description).toMatchObject({ source: 'community', text: 'Buchung nur über phish.example' });
|
||||
expect(mockUpsertEntry).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('ENRICH-119: with the index switched off, no lookup leaves for the description', async () => {
|
||||
// TREK_PLACES_ENABLED=false is a promise about egress, and a saved index
|
||||
// place opened later is still an index place.
|
||||
|
||||
Reference in New Issue
Block a user