Compare commits
2 Commits
f400bbe251
...
a603946868
Author | SHA1 | Date |
---|---|---|
|
a603946868 | |
|
1e5202cd59 |
|
@ -19,6 +19,8 @@ const md = require("markdown-it")()
|
|||
}),
|
||||
});
|
||||
|
||||
/* global Buffer */
|
||||
|
||||
let settings = {
|
||||
SETUP_COMPLETE: false,
|
||||
ACCOUNT_REGISTRATION: false,
|
||||
|
@ -393,10 +395,10 @@ async function updateBiography({ requester_id, author_id, biography_content }) {
|
|||
|
||||
return _r(true);
|
||||
}
|
||||
async function uploadMedia({ parent_id, parent_type, file_buffer, content_type }) {
|
||||
async function uploadMedia({ parent_id, parent_type, file_buffer, content_type }, { resolution_override }) {
|
||||
if (!use_s3_storage) return null;
|
||||
const content_name = crypto.randomUUID();
|
||||
let maximum_image_resolution = { width: 1920, height: 1080 };
|
||||
let maximum_image_resolution = resolution_override || { width: 1920, height: 1080 };
|
||||
|
||||
// Images
|
||||
const compressed_image = await sharp(Buffer.from(file_buffer.split(",")[1], "base64"), { animated: true })
|
||||
|
|
|
@ -47,7 +47,10 @@ async function postImage(request, response) {
|
|||
// TODO: Permissions for uploading images
|
||||
// TODO: Verification for image uploading
|
||||
// FIXME: Naming
|
||||
return response.json(await core.uploadMedia({ parent_id: request.body.post_id || request.body.parent_id, parent_type: request.body.parent_type, file_buffer: request.body.buffer, content_type: request.body.content_type }));
|
||||
let resolution_override;
|
||||
if (request.body.parent_type === "user") resolution_override = { width: 500, height: 500 };
|
||||
|
||||
return response.json(await core.uploadMedia({ parent_id: request.body.post_id || request.body.parent_id, parent_type: request.body.parent_type, file_buffer: request.body.buffer, content_type: request.body.content_type }, { resolution_override: resolution_override }));
|
||||
}
|
||||
async function deleteImage(req, res) {
|
||||
// TODO: Permissions for deleting image
|
||||
|
|
|
@ -82,3 +82,18 @@ function _readFile(file) {
|
|||
reader.readAsDataURL(file);
|
||||
});
|
||||
}
|
||||
|
||||
async function updateBiography() {
|
||||
let form_data = {
|
||||
media: media,
|
||||
content: qs("#post-content").value,
|
||||
id: window.location.href.split("/")[4],
|
||||
};
|
||||
|
||||
const post_response = await request("/api/web/biography", "PATCH", form_data);
|
||||
|
||||
if (post_response.body.success) {
|
||||
window.location.href = `/post/${post_response.body.post_id}`;
|
||||
}
|
||||
}
|
||||
|
|
@ -86,16 +86,3 @@ function _readFile(file) {
|
|||
});
|
||||
}
|
||||
|
||||
async function updateBiography() {
|
||||
let form_data = {
|
||||
media: media,
|
||||
content: qs("#post-content").value,
|
||||
id: window.location.href.split("/")[4],
|
||||
};
|
||||
|
||||
const post_response = await request("/api/web/biography", "PATCH", form_data);
|
||||
|
||||
if (post_response.body.success) {
|
||||
window.location.href = `/post/${post_response.body.post_id}`;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue