Spoiler Fix #90
1 changed files with 31 additions and 2 deletions
stronger tests
commit
11acba45e6
|
|
@ -46,9 +46,9 @@ test("web download discord: works if a known attachment", async t => {
|
|||
t.match(event.node.res.getHeader("location"), /https:\/\/cdn.discordapp.com\/attachments\/655216173696286746\/1314358913482621010\/image\.png\?ex=/)
|
||||
})
|
||||
|
||||
test("web download discord: works with spoilers", async t => {
|
||||
test("web download discord: works with spoilers for humans", async t => {
|
||||
const event = {}
|
||||
await router.test("get", "/download/discordcdn/:channel_id/:attachment_id/:file_name?spoiler", {
|
||||
await router.test("get", "/download/discordcdn/:channel_id/:attachment_id/:file_name?spoiler=yes", {
|
||||
params: {
|
||||
channel_id: "655216173696286746",
|
||||
attachment_id: "1314358913482621010",
|
||||
|
|
@ -73,6 +73,35 @@ test("web download discord: works with spoilers", async t => {
|
|||
t.match(event.node.res.getHeader("location"), /https:\/\/cdn.discordapp.com\/attachments\/655216173696286746\/1314358913482621010\/image\.png\?ex=/)
|
||||
})
|
||||
|
||||
test("web download discord: rejects with spoilers for bots", async t => {
|
||||
const event = {}
|
||||
const [error] = await tryToCatch(() => router.test("get", "/download/discordcdn/:channel_id/:attachment_id/:file_name?spoiler=yes", {
|
||||
params: {
|
||||
channel_id: "655216173696286746",
|
||||
attachment_id: "1314358913482621010",
|
||||
file_name: "image.png"
|
||||
},
|
||||
headers: {
|
||||
"user-agent": "Synapse (bot; +https://github.com/matrix-org/synapse)"
|
||||
},
|
||||
event,
|
||||
snow: {
|
||||
channel: {
|
||||
async refreshAttachmentURLs(attachments) {
|
||||
assert(Array.isArray(attachments))
|
||||
return {
|
||||
refreshed_urls: attachments.map(a => ({
|
||||
original: a,
|
||||
refreshed: a + `?ex=${Math.floor(Date.now() / 1000 + 3600).toString(16)}`
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}))
|
||||
t.equal(error.data, "Sorry URL previewer, you can't have this URL.")
|
||||
})
|
||||
|
||||
test("web download discord: uses cache", async t => {
|
||||
let notCalled = true
|
||||
const event = {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue