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.0 KB
Raw Blame
import { MemoriesAccessService } from '../memories/memories-access.service';
import { PhotoResolverService } from '../memories/photo-resolver.service';
import { Injectable } from '@nestjs/common';

import type { Response } from 'express';

/**
 * /api/photos — the trek_photo read surface. Access control comes from the
 * memories domain (a photo is reachable through a trip or a journey), the bytes
 * from the resolver, which asks whichever provider owns the asset.
 */
@Injectable()
export class PhotosService {
  constructor(
    private readonly access: MemoriesAccessService,
    private readonly resolver: PhotoResolverService,
  ) {}

  canAccess(userId: number, photoId: number): Promise<boolean> {
    return this.access.canAccessTrekPhoto(userId, photoId);
  }

  stream(res: Response, userId: number, photoId: number, kind: 'thumbnail' | 'original', range?: string) {
    return this.resolver.streamPhoto(res, userId, photoId, kind, range);
  }

  info(userId: number, photoId: number) {
    return this.resolver.getPhotoInfo(userId, photoId);
  }
}