feat: gate full notes behind auth on single session endpoint
Made-with: Cursor
This commit is contained in:
@@ -6,6 +6,7 @@ const { triggerWebhook } = require('../utils/webhooks');
|
||||
const { getWebSocketManager } = require('../utils/websocket-manager');
|
||||
const { startMonitor, stopMonitor, getMonitorSnapshot } = require('../utils/ecast-shard-client');
|
||||
const { computeNotesPreview } = require('../utils/notes-preview');
|
||||
const { optionalAuthenticateToken } = require('../middleware/optional-auth');
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@@ -71,7 +72,7 @@ router.get('/active', (req, res) => {
|
||||
});
|
||||
|
||||
// Get single session by ID
|
||||
router.get('/:id', (req, res) => {
|
||||
router.get('/:id', optionalAuthenticateToken, (req, res) => {
|
||||
try {
|
||||
const session = db.prepare(`
|
||||
SELECT
|
||||
@@ -87,7 +88,14 @@ router.get('/:id', (req, res) => {
|
||||
return res.status(404).json({ error: 'Session not found' });
|
||||
}
|
||||
|
||||
res.json(session);
|
||||
const { has_notes, notes_preview } = computeNotesPreview(session.notes);
|
||||
|
||||
if (req.user) {
|
||||
res.json({ ...session, has_notes, notes_preview });
|
||||
} else {
|
||||
const { notes, ...publicSession } = session;
|
||||
res.json({ ...publicSession, has_notes, notes_preview });
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({ error: error.message });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user