Trying some changes to make bot messages and client mmessages have same format

This commit is contained in:
MrMasrozYTLIVE 2024-06-14 17:44:05 +03:00
parent d449249f41
commit 14aa129f6d

18
app.js
View File

@ -290,11 +290,11 @@ function setupTalkButton() {
const audioMessage = { const audioMessage = {
type: 'audio', type: 'audio',
name: config.userName, name: config.userName,
audio: b4a.toString(buffer, 'base64'),
audioType: audioBlob.type,
avatar: updatePortInUrl(config.userAvatar), avatar: updatePortInUrl(config.userAvatar),
topic: topic, topic: topic,
timestamp: Date.now() timestamp: Date.now(),
audio: b4a.toString(buffer, 'base64'),
audioType: audioBlob.type
}; };
console.log('Sending audio message:', audioMessage); // Debugging log console.log('Sending audio message:', audioMessage); // Debugging log
@ -565,10 +565,10 @@ async function sendMessage(e) {
const messageObj = JSON.stringify({ const messageObj = JSON.stringify({
type: 'message', type: 'message',
name: config.userName, name: config.userName,
message,
avatar: config.userAvatar, avatar: config.userAvatar,
topic: topic, topic: topic,
timestamp: timestamp timestamp: timestamp,
message
}); });
const peers = [...activeRooms.find(room => room.topic === topic).swarm.connections]; const peers = [...activeRooms.find(room => room.topic === topic).swarm.connections];
@ -592,12 +592,12 @@ async function handleFileInput(event) {
const fileMessage = { const fileMessage = {
type: 'file', type: 'file',
name: config.userName, name: config.userName,
fileName: file.name,
file: b4a.toString(buffer, 'base64'),
fileType: file.type,
avatar: updatePortInUrl(config.userAvatar), avatar: updatePortInUrl(config.userAvatar),
topic: topic, topic: topic,
timestamp: Date.now() timestamp: Date.now(),
fileName: file.name,
file: b4a.toString(buffer, 'base64'),
fileType: file.type
}; };
console.log('Sending file message:', fileMessage); // Debugging log console.log('Sending file message:', fileMessage); // Debugging log