Fixed Message attachments!
This commit is contained in:
parent
25e421e982
commit
e1153cb5df
8
app.js
8
app.js
@ -107,7 +107,7 @@ async function initialize() {
|
||||
if (messageObj.type === 'icon') {
|
||||
const username = messageObj.username;
|
||||
if (messageObj.avatar) {
|
||||
const avatarBuffer = Buffer.from(messageObj.avatar, 'base64');
|
||||
const avatarBuffer = b4a.from(messageObj.avatar, 'base64');
|
||||
await drive.put(`/icons/${username}.png`, avatarBuffer);
|
||||
updateIcon(username, avatarBuffer);
|
||||
} else {
|
||||
@ -115,7 +115,7 @@ async function initialize() {
|
||||
}
|
||||
} else if (messageObj.type === 'file') {
|
||||
if (messageObj.file && messageObj.fileName) {
|
||||
const fileBuffer = Buffer.from(messageObj.file, 'base64');
|
||||
const fileBuffer = b4a.from(messageObj.file, 'base64');
|
||||
await drive.put(`/files/${messageObj.fileName}`, fileBuffer);
|
||||
const fileUrl = `http://localhost:${servePort}/files/${messageObj.fileName}`;
|
||||
addFileMessage(messageObj.name, messageObj.fileName, updatePortInUrl(fileUrl), messageObj.fileType, updatePortInUrl(messageObj.avatar));
|
||||
@ -140,7 +140,7 @@ async function initialize() {
|
||||
const iconMessage = JSON.stringify({
|
||||
type: 'icon',
|
||||
username: config.userName,
|
||||
avatar: iconBuffer.toString('base64'),
|
||||
avatar: b4a.toString(iconBuffer, 'base64'),
|
||||
});
|
||||
connection.write(iconMessage);
|
||||
}
|
||||
@ -339,7 +339,7 @@ async function handleFileInput(event) {
|
||||
type: 'file',
|
||||
name: config.userName,
|
||||
fileName: file.name,
|
||||
file: buffer.toString('base64'),
|
||||
file: b4a.toString(buffer, 'base64'),
|
||||
fileType: file.type,
|
||||
avatar: updatePortInUrl(config.userAvatar),
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user