Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

1.1 KB
Raw Blame
import { Journeys } from '../../db/entities/Journeys.entity';
import { likeAny, StorageReclaimSource } from '../storage/storage-reclaim-source.service';
import { EVERY_RECLAIMABLE_CATEGORY } from '../storage/storage-reclaim.types';
import { Injectable } from '@nestjs/common';

/**
 * Tells the storage reclaim pass which stored objects a journey still names
 * (#2924). `journeys.cover_image` is inherited from the first linked trip as
 * `covers/<name>` (the trip and the journey share the object), set to a
 * gallery photo's `journey/<name>`, or whatever a PATCH sent. Every category
 * is claimed; the photos themselves are the photos domain's rows.
 */
@Injectable()
export class JourneyStorageRefsService extends StorageReclaimSource {
  readonly id = 'journey';
  readonly claims = EVERY_RECLAIMABLE_CATEGORY;

  protected async storedValues(containing: readonly string[] | null): Promise<Array<string | null | undefined>> {
    const rows = await this.em
      .getRepository(Journeys)
      .find(likeAny<Journeys>(this.em.getPlatform(), ['cover_image'], containing), { fields: ['cover_image'] });
    return rows.map((row) => row.cover_image);
  }
}