add: upload alt text
This commit is contained in:
parent
3b5b0ce1a1
commit
e0e38b2b32
13 changed files with 224 additions and 59 deletions
|
@ -2,5 +2,6 @@ CREATE TABLE IF NOT EXISTS uploads (
|
|||
id BIGINT NOT NULL PRIMARY KEY,
|
||||
created BIGINT NOT NULL,
|
||||
owner BIGINT NOT NULL,
|
||||
what TEXT NOT NULL
|
||||
what TEXT NOT NULL,
|
||||
alt TEXT NOT NULL
|
||||
)
|
||||
|
|
|
@ -16,10 +16,11 @@ impl DataManager {
|
|||
created: get!(x->1(i64)) as usize,
|
||||
owner: get!(x->2(i64)) as usize,
|
||||
what: serde_json::from_str(&get!(x->3(String))).unwrap(),
|
||||
alt: get!(x->4(String)),
|
||||
}
|
||||
}
|
||||
|
||||
auto_method!(get_upload_by_id(usize as i64)@get_upload_from_row -> "SELECT * FROM uploads WHERE id = $1" --name="upload" --returns=MediaUpload --cache-key-tmpl="atto.uploads:{}");
|
||||
auto_method!(get_upload_by_id(usize as i64)@get_upload_from_row -> "SELECT * FROM uploads WHERE id = $1" --name="upload" --returns=MediaUpload --cache-key-tmpl="atto.upload:{}");
|
||||
|
||||
/// Get all uploads (paginated).
|
||||
///
|
||||
|
@ -113,12 +114,13 @@ impl DataManager {
|
|||
|
||||
let res = execute!(
|
||||
&conn,
|
||||
"INSERT INTO uploads VALUES ($1, $2, $3, $4)",
|
||||
"INSERT INTO uploads VALUES ($1, $2, $3, $4, $5)",
|
||||
params![
|
||||
&(data.id as i64),
|
||||
&(data.created as i64),
|
||||
&(data.owner as i64),
|
||||
&serde_json::to_string(&data.what).unwrap().as_str(),
|
||||
&data.alt,
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -187,4 +189,6 @@ impl DataManager {
|
|||
self.0.1.remove(format!("atto.upload:{}", id)).await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
auto_method!(update_upload_alt(&str)@get_upload_by_id:FinePermission::MANAGE_UPLOADS; -> "UPDATE uploads SET alt = $1 WHERE id = $2" --cache-key-tmpl="atto.upload:{}");
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ pub struct MediaUpload {
|
|||
pub created: usize,
|
||||
pub owner: usize,
|
||||
pub what: MediaType,
|
||||
pub alt: String,
|
||||
}
|
||||
|
||||
impl MediaUpload {
|
||||
|
@ -54,6 +55,7 @@ impl MediaUpload {
|
|||
created: unix_epoch_timestamp(),
|
||||
owner,
|
||||
what,
|
||||
alt: String::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue