place-contrib: record origins for collection copies and booking imports

A place copied from a collection and a venue a booking import creates now
record their details as an import, so a later edit compares against what was
really written. Dawarich and the background enrichment write none of the
shareable fields, so they need nothing.

The admin panel asks again for a few seconds while a fresh installation is
still fetching its key, so the prompt appears without a reload.
This commit is contained in:
Maurice
2026-10-30 19:55:55 +01:00
parent 3f2dec6c47
commit 71cd6c2de4
8 changed files with 70 additions and 6 deletions
@@ -12,6 +12,7 @@ import { imageMimeType } from '../llm-parse/image-input';
import { LlmParseService } from '../llm-parse/llm-parse.service';
import { MapsService } from '../maps/maps.service';
import { PermissionsService } from '../permissions/permissions.service';
import { PlaceOriginsService } from '../places/place-origins.service';
import { PlacesService } from '../places/places.service';
import { RealtimeService } from '../realtime/realtime.service';
import { ReservationsService } from '../reservations/reservations.service';
@@ -45,6 +46,7 @@ export class BookingImportService {
private readonly maps: MapsService,
private readonly places: PlacesService,
private readonly uow: UnitOfWork,
private readonly origins: PlaceOriginsService,
) {}
/**
@@ -313,6 +315,7 @@ export class BookingImportService {
const created: Reservation[] = [];
const confirmGeoCache = new Map<string, { lat: number; lng: number } | null>();
const venues: number[] = [];
for (const item of items) {
try {
const { _venue, _accommodation, source: _src, ...reservationData } = item;
@@ -417,6 +420,7 @@ export class BookingImportService {
},
);
if (place) venues.push(place.id);
if (place) this.realtime.broadcast(tripId, 'place:created', { place }, socketId);
this.realtime.broadcast(tripId, 'reservation:created', { reservation }, socketId);
if (accommodationCreated) {
@@ -434,6 +438,8 @@ export class BookingImportService {
}
}
// The venues' websites and phones come from the bookings, not from a person: an import, never shared.
if (venues.length > 0) await this.origins.recordImported(venues);
return { created };
}
}
@@ -7,6 +7,7 @@ import { PermissionsService } from '../permissions/permissions.service';
import { RealtimeService } from '../realtime/realtime.service';
import { isUploadedPlaceImage } from '../places/place-image';
import { PlacesService } from '../places/places.service';
import { PlaceOriginsService } from '../places/place-origins.service';
import { StorageService } from '../storage/storage.service';
import { Collections } from '../../db/entities/Collections.entity';
import { CollectionsRepository, type CollectionPlaceRow } from '../../db/repositories/Collections.repository';
@@ -130,6 +131,7 @@ export class CollectionsService {
@InjectRepository(Users) private readonly users: UsersRepository,
private readonly placeImport: PlaceImportService,
private readonly places: PlacesService, // the journey hook of every place copyToTrip adds
private readonly origins: PlaceOriginsService,
) {}
/**
@@ -1186,6 +1188,8 @@ export class CollectionsService {
created.push({ id: newPlaceId, source_id: s.id });
}
});
// A copied value is the collection's, not typed in this write: recorded as an import, never shared.
if (created.length > 0) await this.origins.recordImported(created.map(({ id }) => id));
const rows = await Promise.all(created.map(({ id }) => this.tripPlaces.findWithTagsAndRatings(id))); // reads only
for (const [i, place] of rows.entries()) {
if (place) events.emit('place:created', { place }); // as the place routes send it
+2 -1
View File
@@ -106,6 +106,7 @@ import { MulterModule } from '@nestjs/platform-express';
],
controllers: [PlacesController],
providers: [PlacesService, PlacesMcp, PlacesRpc, PlaceOriginsService],
exports: [PlacesService],
// The origin bookkeeping too: the copy from a collection and the booking import write places as well.
exports: [PlacesService, PlaceOriginsService],
})
export class PlacesModule {}