Invites and fixed image caching
This commit is contained in:
1 parent
1706a906f0
commit
693a30f437
7 files changed
+193
-5
No files matched your search
+5
-2
@@ -1,3 +1,4 @@
|
||||
import { photoCacheControl } from './storage/photoCache.js';
|
||||
import { canUpdateWorkspaceSettings, subscriptionAllowsWrite } from './workspaceAccess.js';
|
||||
import { buildWorkspaceInviteEmail } from './emails/workspaceInviteEmail.js';
|
||||
import { exportFlock } from './repositories/flockExportRepository.js';
|
||||
@@ -3496,6 +3497,8 @@ app.post(
|
||||
);
|
||||
|
||||
app.get('/api/birds/:birdId/photo', async (req: Request, res: Response, next: NextFunction) => {
|
||||
// Invalid tokens, missing photos and upstream failures must never be cached.
|
||||
res.setHeader('Cache-Control', 'no-store');
|
||||
try {
|
||||
const token = typeof req.query.token === 'string' ? req.query.token : '';
|
||||
const photoAccess = verifyBirdPhotoAccessToken(token);
|
||||
@@ -3525,9 +3528,8 @@ app.get('/api/birds/:birdId/photo', async (req: Request, res: Response, next: Ne
|
||||
expiresInSeconds: 5 * 60,
|
||||
});
|
||||
|
||||
res.setHeader('Cache-Control', 'private, max-age=900');
|
||||
|
||||
if (photoDeliveryMode === 'redirect') {
|
||||
res.setHeader('Cache-Control', photoCacheControl('redirect', photoAccess.expiresAt));
|
||||
res.redirect(302, signedUrl);
|
||||
return;
|
||||
}
|
||||
@@ -3543,6 +3545,7 @@ app.get('/api/birds/:birdId/photo', async (req: Request, res: Response, next: Ne
|
||||
const contentLength = imageResponse.headers.get('content-length');
|
||||
const imageBuffer = Buffer.from(await imageResponse.arrayBuffer());
|
||||
|
||||
res.setHeader('Cache-Control', photoCacheControl('proxy', photoAccess.expiresAt));
|
||||
res.setHeader('Content-Type', contentType);
|
||||
|
||||
if (contentLength) {
|
||||
|
||||
Reference in new issue
Block a user