mirror of
https://github.com/cupcakearmy/cryptgeon.git
synced 2024-12-22 08:16:28 +00:00
limit size of note
This commit is contained in:
parent
5c95f0be42
commit
3692d0a2e6
@ -7,7 +7,6 @@
|
|||||||
let html = null
|
let html = null
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
console.log(src)
|
|
||||||
html = await fetch(src).then((res) => res.text())
|
html = await fetch(src).then((res) => res.text())
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -18,8 +18,9 @@
|
|||||||
let result: { password: string; id: string } | null = null
|
let result: { password: string; id: string } | null = null
|
||||||
let advanced = false
|
let advanced = false
|
||||||
let type = false
|
let type = false
|
||||||
let loading = false
|
|
||||||
let message = ''
|
let message = ''
|
||||||
|
let loading = false
|
||||||
|
let error: string | null = null
|
||||||
|
|
||||||
$: if (!advanced) {
|
$: if (!advanced) {
|
||||||
note.views = 1
|
note.views = 1
|
||||||
@ -34,6 +35,7 @@
|
|||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
try {
|
try {
|
||||||
|
error = null
|
||||||
loading = true
|
loading = true
|
||||||
const data: Note = {
|
const data: Note = {
|
||||||
contents: note.contents,
|
contents: note.contents,
|
||||||
@ -53,6 +55,8 @@
|
|||||||
password: password,
|
password: password,
|
||||||
id: response.id,
|
id: response.id,
|
||||||
}
|
}
|
||||||
|
} catch {
|
||||||
|
error = 'could not create note.'
|
||||||
} finally {
|
} finally {
|
||||||
loading = false
|
loading = false
|
||||||
}
|
}
|
||||||
@ -81,6 +85,10 @@
|
|||||||
<Button type="submit">create</Button>
|
<Button type="submit">create</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{#if error}
|
||||||
|
<div class="error-text">{error}</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<p><br />{message}</p>
|
<p><br />{message}</p>
|
||||||
|
|
||||||
<div class="advanced" class:hidden={!advanced}>
|
<div class="advanced" class:hidden={!advanced}>
|
||||||
|
@ -37,7 +37,8 @@
|
|||||||
the backend is written in rust and the frontend is svelte and typescript.
|
the backend is written in rust and the frontend is svelte and typescript.
|
||||||
<br />
|
<br />
|
||||||
you are welcomed to check & audit the
|
you are welcomed to check & audit the
|
||||||
<a href="https://github.com/cupcakearmy/cryptgeon">source code</a>.
|
<a href="https://github.com/cupcakearmy/cryptgeon" target="_blank" rel="noopener">source code</a
|
||||||
|
>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
@ -41,6 +41,9 @@ async fn create(note: web::Json<Note>) -> impl Responder {
|
|||||||
let mut n = note.into_inner();
|
let mut n = note.into_inner();
|
||||||
let id = generate_id();
|
let id = generate_id();
|
||||||
let bad_req = HttpResponse::BadRequest().finish();
|
let bad_req = HttpResponse::BadRequest().finish();
|
||||||
|
if n.contents.chars().count() > 8192 {
|
||||||
|
return bad_req;
|
||||||
|
}
|
||||||
if n.views == None && n.expiration == None {
|
if n.views == None && n.expiration == None {
|
||||||
return bad_req;
|
return bad_req;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user