mirror of
https://github.com/liamcottle/reticulum-meshchat.git
synced 2026-04-28 00:20:48 +00:00
increase file upload size limit
This commit is contained in:
parent
307cd05fe2
commit
4abca80ed0
1 changed files with 16 additions and 1 deletions
|
|
@ -1806,9 +1806,9 @@
|
|||
const fields = {};
|
||||
|
||||
// add file attachments
|
||||
var fileAttachmentsTotalSize = 0;
|
||||
if(this.newMessageFiles.length > 0){
|
||||
const fileAttachments = [];
|
||||
var fileAttachmentsTotalSize = 0;
|
||||
for(const file of this.newMessageFiles){
|
||||
fileAttachmentsTotalSize += file.size;
|
||||
fileAttachments.push({
|
||||
|
|
@ -1820,7 +1820,9 @@
|
|||
}
|
||||
|
||||
// add image attachment
|
||||
var imageTotalSize = 0;
|
||||
if(this.newMessageImage){
|
||||
imageTotalSize = this.newMessageImage.size;
|
||||
fields["image"] = {
|
||||
// Reticulum sends image type as "jpg" or "png" and not "image/jpg" or "image/png"
|
||||
"image_type": this.newMessageImage.type.replace("image/", ""),
|
||||
|
|
@ -1829,13 +1831,26 @@
|
|||
}
|
||||
|
||||
// add audio attachment
|
||||
var audioTotalSize = 0;
|
||||
if(this.newMessageAudio){
|
||||
audioTotalSize = this.newMessageImage.size;
|
||||
fields["audio"] = {
|
||||
"audio_mode": this.newMessageAudio.audio_mode,
|
||||
"audio_bytes": this.arrayBufferToBase64(await this.newMessageAudio.audio_blob.arrayBuffer()),
|
||||
};
|
||||
}
|
||||
|
||||
// calculate estimated message size in bytes
|
||||
const contentSize = this.newMessageText.length;
|
||||
const totalMessageSize = contentSize + fileAttachmentsTotalSize + imageTotalSize + audioTotalSize;
|
||||
|
||||
// ask user if they still want to send message if it may be rejected by sender
|
||||
if(totalMessageSize > 1000 * 900){ // actual limit in LXMF Router is 1mb
|
||||
if(!confirm(`Your message exceeds 900KB (It's ${this.formatBytes(totalMessageSize)}). It may be rejected by the recipient unless they have increased their delivery limit. Do you want to try sending anyway?`)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// send message to reticulum
|
||||
const response = await window.axios.post(`/api/v1/lxmf-messages/send`, {
|
||||
"lxmf_message": {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue