Fixes
This commit is contained in:
parent
d8e21e8b7b
commit
14c05c2900
2 changed files with 20 additions and 11 deletions
13
index.js
13
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,7 +419,8 @@ 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)) {
|
||||||
|
fetch(`${get_img_url(activity)}`)
|
||||||
.then((response) => response.body)
|
.then((response) => response.body)
|
||||||
.then((body) => {
|
.then((body) => {
|
||||||
const stream = new WritableStream({
|
const stream = new WritableStream({
|
||||||
|
@ -426,6 +434,7 @@ lanyard.addEventListener("message", (res) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
app.get('/', async (req, res) => {
|
app.get('/', async (req, res) => {
|
||||||
|
|
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