fix 'currently listening' bug

This commit is contained in:
pschneid 2025-10-17 09:09:04 +02:00
parent af5b20d3e6
commit 7ed44ac60e
9 changed files with 7 additions and 7 deletions

BIN
prod.out

Binary file not shown.

View File

@ -15,7 +15,7 @@ import { syncUserData, captureNowPlaying } from './lib/sync.js';
const app = express(); const app = express();
app.use(helmet()); app.use(helmet());
app.use(cors({ origin: [ app.use(cors({ origin: [
'http://localhost:3000', 'http://localhost:4000',
'https://159.195.9.107:3443', 'https://159.195.9.107:3443',
'http://159.195.9.107:3443' 'http://159.195.9.107:3443'
], credentials: true })); ], credentials: true }));

View File

@ -70,7 +70,7 @@ usersRouter.get('/:uid/now-playing', requireAuth, async (req, res) => {
return res.status(403).json({ error: 'Forbidden' }); return res.status(403).json({ error: 'Forbidden' });
if (req.user.uid !== uid) { if (req.user.uid !== uid) {
// allow if users are partnered // allow if users are partnered
const paired = db.db.prepare('SELECT 1 FROM friendships WHERE (user1_id=? AND user2_id=?) OR (user1_id=? AND user2_id=?)').get(req.user.uid, uid, uid, req.user.uid); const paired = db.db.prepare('SELECT 1 FROM friendships WHERE (user_a_id=? AND user_b_id=?) OR (user_a_id=? AND user_b_id=?)').get(req.user.uid, uid, uid, req.user.uid);
if (!paired) if (!paired)
return res.status(403).json({ error: 'Forbidden' }); return res.status(403).json({ error: 'Forbidden' });
} }
@ -108,7 +108,7 @@ usersRouter.get('/:uid/audio-features', requireAuth, async (req, res) => {
if (!req.user) if (!req.user)
return res.status(403).json({ error: 'Forbidden' }); return res.status(403).json({ error: 'Forbidden' });
if (req.user.uid !== uid) { if (req.user.uid !== uid) {
const paired = db.db.prepare('SELECT 1 FROM friendships WHERE (user1_id=? AND user2_id=?) OR (user1_id=? AND user2_id=?)').get(req.user.uid, uid, uid, req.user.uid); const paired = db.db.prepare('SELECT 1 FROM friendships WHERE (user_a_id=? AND user_b_id=?) OR (user_a_id=? AND user_b_id=?)').get(req.user.uid, uid, uid, req.user.uid);
if (!paired) if (!paired)
return res.status(403).json({ error: 'Forbidden' }); return res.status(403).json({ error: 'Forbidden' });
} }

View File

@ -17,7 +17,7 @@ const app = express();
app.use(helmet()); app.use(helmet());
app.use(cors({ origin: [ app.use(cors({ origin: [
'http://localhost:3000', 'http://localhost:4000',
'https://159.195.9.107:3443', 'https://159.195.9.107:3443',
'http://159.195.9.107:3443' 'http://159.195.9.107:3443'
], credentials: true })); ], credentials: true }));

View File

@ -74,7 +74,7 @@ usersRouter.get('/:uid/now-playing', requireAuth, async (req: AuthedRequest, res
if (!req.user) return res.status(403).json({ error: 'Forbidden' }); if (!req.user) return res.status(403).json({ error: 'Forbidden' });
if (req.user.uid !== uid) { if (req.user.uid !== uid) {
// allow if users are partnered // allow if users are partnered
const paired = db.db.prepare('SELECT 1 FROM friendships WHERE (user1_id=? AND user2_id=?) OR (user1_id=? AND user2_id=?)').get(req.user.uid, uid, uid, req.user.uid); const paired = db.db.prepare('SELECT 1 FROM friendships WHERE (user_a_id=? AND user_b_id=?) OR (user_a_id=? AND user_b_id=?)').get(req.user.uid, uid, uid, req.user.uid);
if (!paired) return res.status(403).json({ error: 'Forbidden' }); if (!paired) return res.status(403).json({ error: 'Forbidden' });
} }
// Try DB-captured snapshot first (last 60s) // Try DB-captured snapshot first (last 60s)
@ -108,7 +108,7 @@ usersRouter.get('/:uid/audio-features', requireAuth, async (req: AuthedRequest,
const ids = String(req.query.ids || '').split(',').map(s => s.trim()).filter(Boolean); const ids = String(req.query.ids || '').split(',').map(s => s.trim()).filter(Boolean);
if (!req.user) return res.status(403).json({ error: 'Forbidden' }); if (!req.user) return res.status(403).json({ error: 'Forbidden' });
if (req.user.uid !== uid) { if (req.user.uid !== uid) {
const paired = db.db.prepare('SELECT 1 FROM friendships WHERE (user1_id=? AND user2_id=?) OR (user1_id=? AND user2_id=?)').get(req.user.uid, uid, uid, req.user.uid); const paired = db.db.prepare('SELECT 1 FROM friendships WHERE (user_a_id=? AND user_b_id=?) OR (user_a_id=? AND user_b_id=?)').get(req.user.uid, uid, uid, req.user.uid);
if (!paired) return res.status(403).json({ error: 'Forbidden' }); if (!paired) return res.status(403).json({ error: 'Forbidden' });
} }
if (!ids.length) return res.json({ audio_features: [] }); if (!ids.length) return res.json({ audio_features: [] });

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -5,7 +5,7 @@ import react from '@vitejs/plugin-react'
export default defineConfig({ export default defineConfig({
plugins: [react()], plugins: [react()],
server: { server: {
port: 3000, port: 4000,
host: true host: true
} }
}) })