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.4 KB
Raw Blame
import type { AssetInfo, ServiceResult } from '../memories.helpers';
import type { PhotoAssetKind, PhotoAssetRef, PhotoBytes, PhotoFetchError, PhotoProvider } from '../photo-provider';
import { SynologyService } from '../synology.service';
import { Injectable } from '@nestjs/common';

import type { Response } from 'express';

/**
 * Synology Photos behind the PhotoProvider interface.
 *
 * The `size` parameter stays unset, as every caller left it. The passphrase is
 * the one thing this provider needs that Immich does not: a shared album link
 * carries its own, and the caller decrypts it before handing it over.
 */
@Injectable()
export class SynologyPhotoProvider implements PhotoProvider {
  readonly id = 'synologyphotos';

  constructor(private readonly synology: SynologyService) {}

  streamAsset(res: Response, ref: PhotoAssetRef, kind: PhotoAssetKind): Promise<void> {
    return this.synology.streamSynologyAsset(
      res,
      ref.userId,
      ref.ownerId,
      ref.assetId,
      kind,
      undefined,
      ref.passphrase,
    );
  }

  fetchThumbnailBytes(ref: PhotoAssetRef): Promise<PhotoBytes | PhotoFetchError> {
    return this.synology.fetchSynologyThumbnailBytes(ref.userId, ref.ownerId, ref.assetId, ref.passphrase);
  }

  getAssetInfo(ref: PhotoAssetRef): Promise<ServiceResult<AssetInfo>> {
    return this.synology.getSynologyAssetInfo(ref.userId, ref.assetId, ref.ownerId, ref.passphrase);
  }
}