Fixes
This commit is contained in:
parent
d8e21e8b7b
commit
14c05c2900
2 changed files with 20 additions and 11 deletions
31
index.js
31
index.js
|
@ -68,7 +68,7 @@ function get_img_url(activity) {
|
||||||
if (activity.name in activityImages) {
|
if (activity.name in activityImages) {
|
||||||
return decodeURIComponent(activityImages[activity.name])
|
return decodeURIComponent(activityImages[activity.name])
|
||||||
} else {
|
} else {
|
||||||
return decodeURIComponent(`https://cdn.discordapp.com/app-assets/680748054038577165/680775885317472448.png`)
|
return ''
|
||||||
// This was supposed to be temporary but it kinda stuck honestly lol (It's an ultrakill icon)
|
// This was supposed to be temporary but it kinda stuck honestly lol (It's an ultrakill icon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,6 +201,13 @@ async function pageUpdate() {
|
||||||
|
|
||||||
function get_img() {
|
function get_img() {
|
||||||
var fn = sha256(get_img_url(activity))
|
var fn = sha256(get_img_url(activity))
|
||||||
|
var fp = path.join(staticpath, 'cached', fn)
|
||||||
|
|
||||||
|
if (!fs.existsSync(fp)) {
|
||||||
|
return 'imgs/notFound.png'
|
||||||
|
} else if (fs.readFileSync(fp).length < 1) {
|
||||||
|
fs.rmSync(fp)
|
||||||
|
}
|
||||||
|
|
||||||
return '/cached/' + fn
|
return '/cached/' + fn
|
||||||
}
|
}
|
||||||
|
@ -412,17 +419,19 @@ lanyard.addEventListener("message", (res) => {
|
||||||
if (!fs.existsSync(fp)) {
|
if (!fs.existsSync(fp)) {
|
||||||
var wrst = fs.createWriteStream(fp)
|
var wrst = fs.createWriteStream(fp)
|
||||||
|
|
||||||
fetch(`${getThumbor()}/256x256/${get_img_url(activity)}`)
|
if (get_img_url(activity)) {
|
||||||
.then((response) => response.body)
|
fetch(`${get_img_url(activity)}`)
|
||||||
.then((body) => {
|
.then((response) => response.body)
|
||||||
const stream = new WritableStream({
|
.then((body) => {
|
||||||
write(chunk) {
|
const stream = new WritableStream({
|
||||||
wrst.write(chunk)
|
write(chunk) {
|
||||||
}
|
wrst.write(chunk)
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
|
||||||
body.pipeTo(stream)
|
body.pipeTo(stream)
|
||||||
})
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
BIN
static/imgs/notFound.png
Normal file
BIN
static/imgs/notFound.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
Loading…
Reference in a new issue