ai generated solutions to our ai generated problems
This commit is contained in:
+5
-10
@@ -126,7 +126,7 @@ const CSP_DIRECTIVES = [
|
||||
"style-src 'self'",
|
||||
"style-src-elem 'self'",
|
||||
"style-src-attr 'unsafe-inline'",
|
||||
"img-src 'self' data: blob: https://*.basemaps.cartocdn.com https://basemaps.cartocdn.com https://lastfm.freetls.fastly.net https://*.lastfm.freetls.fastly.net",
|
||||
"img-src 'self' data: blob: https://*.basemaps.cartocdn.com https://basemaps.cartocdn.com",
|
||||
"font-src 'self' data:",
|
||||
"connect-src 'self' https://challenges.cloudflare.com",
|
||||
"frame-src https://challenges.cloudflare.com",
|
||||
@@ -179,7 +179,8 @@ let analyticsDb = null
|
||||
let latestUptimeSnapshot = null
|
||||
|
||||
function songHistoryPath() {
|
||||
return path.join(uptimeStoragePath(), LASTFM_HISTORY_FILE)
|
||||
const fileName = path.basename(LASTFM_HISTORY_FILE || 'lastfm-song-of-day.json')
|
||||
return path.join(uptimeStoragePath(), fileName)
|
||||
}
|
||||
|
||||
function readSongHistory() {
|
||||
@@ -200,12 +201,6 @@ function todayKey() {
|
||||
return new Date().toISOString().slice(0, 10)
|
||||
}
|
||||
|
||||
function lastfmImage(track) {
|
||||
const images = Array.isArray(track.image) ? track.image : []
|
||||
const image = [...images].reverse().find((item) => item?.['#text'])
|
||||
return image?.['#text'] || ''
|
||||
}
|
||||
|
||||
function normalizeLastfmTrack(track) {
|
||||
const artist = track?.artist?.['#text'] || track?.artist?.name || ''
|
||||
const name = track?.name || ''
|
||||
@@ -217,7 +212,7 @@ function normalizeLastfmTrack(track) {
|
||||
name,
|
||||
album: track?.album?.['#text'] || '',
|
||||
url: track?.url || '',
|
||||
image: lastfmImage(track),
|
||||
image: '',
|
||||
played_at: track?.date?.uts ? Number(track.date.uts) : null,
|
||||
}
|
||||
}
|
||||
@@ -1901,7 +1896,7 @@ const server = http.createServer((req, res) => {
|
||||
return
|
||||
}
|
||||
|
||||
if (req.method === 'GET' && req.url === '/api/lastfm/song-of-day') {
|
||||
if (req.method === 'GET' && req.url === '/api/song-of-day') {
|
||||
if (!isSameOriginRequest(req)) {
|
||||
sendJson(res, 403, { error: 'Song of the day is restricted to this site' })
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user