Gate shares behind magic-link sessions, add comments and new-photo email digests
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { AssetType, getConfigOption, getNumericConfigOption, renderPage, SharedLink, title, toString } from '@ipp/core'
|
||||
import { AssetType, getConfigOption, renderPage, SharedLink, title, toString } from '@ipp/core'
|
||||
import {
|
||||
getVideoContentType,
|
||||
photoUrl,
|
||||
@@ -13,6 +13,7 @@ import { downloadFilename, positionInShare } from './filename'
|
||||
import { groupByDateMode } from './order'
|
||||
import { requiresOriginal } from './sizing'
|
||||
import { displayDimensions, metadataGroupActive, pickExif } from './exif'
|
||||
import { getStore } from '../magic/store'
|
||||
|
||||
/**
|
||||
* Render a gallery page for a given SharedLink.
|
||||
@@ -44,7 +45,13 @@ export async function gallery (res: Response, share: SharedLink, openItem?: numb
|
||||
const motionPhotos = !!getConfigOption('ipp.motionPhotos', true)
|
||||
const descriptionInCaption = shareMetadataAllowed && !!getConfigOption('ipp.showMetadata.description.caption', false)
|
||||
const descriptionInSidebar = shareMetadataAllowed && !!getConfigOption('ipp.showMetadata.description.sidebar', false)
|
||||
const sidebarHasContent = shareMetadataAllowed && (descriptionInSidebar || metadataGroupActive('exif') || metadataGroupActive('location'))
|
||||
// A signed-in recipient can comment, which lives in the sidebar too
|
||||
const viewer = res.req.recipient
|
||||
const comments = viewer
|
||||
? { base: '/share/comments/' + share.key, counts: getStore().countComments(share.key) }
|
||||
: undefined
|
||||
const sidebarHasContent = !!comments ||
|
||||
(shareMetadataAllowed && (descriptionInSidebar || metadataGroupActive('exif') || metadataGroupActive('location')))
|
||||
|
||||
const items: GalleryItem[] = await Promise.all(share.assets.map(async (asset, index): Promise<GalleryItem> => {
|
||||
let videoData: string | undefined
|
||||
@@ -152,14 +159,17 @@ export async function gallery (res: Response, share: SharedLink, openItem?: numb
|
||||
groupByDate,
|
||||
metaBase,
|
||||
uploadLink: uploadLink(share),
|
||||
uploadHealthcheck: uploadHealthcheck()
|
||||
uploadHealthcheck: uploadHealthcheck(),
|
||||
comments,
|
||||
accountLink: viewer ? '/me' : undefined
|
||||
}
|
||||
|
||||
// HTML gallery page cache time. A password-protected gallery keeps the
|
||||
// no-store that handleShareRequest set.
|
||||
// The page is per-viewer (comment counts, account link) and behind a
|
||||
// session, so it must never sit in a shared cache, and the browser should
|
||||
// recheck it so new photos and comments show up. A password-protected
|
||||
// gallery keeps the no-store that handleShareRequest set.
|
||||
if (!share.password) {
|
||||
const cacheTime = Math.max(0, getNumericConfigOption('ipp.gallery.cacheTime', 300))
|
||||
res.header('Cache-Control', 'public, max-age=' + cacheTime)
|
||||
res.header('Cache-Control', 'private, no-cache')
|
||||
}
|
||||
res.send(renderPage(h(Gallery, props)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user