Fix being able to edit/delete messages only on the websocket end, doesn't affect db

This commit is contained in:
2026-02-01 21:33:51 -07:00
parent 64a15390e7
commit a73834a849
2 changed files with 97 additions and 94 deletions

View File

@@ -129,7 +129,7 @@ app.ws('/ws', {
if (!authResult.valid) return
const userId = authResult.id
await db1
const result = await db1
.update(berryDashChats)
.set({
content: btoa(message.data.newContent)
@@ -142,6 +142,7 @@ app.ws('/ws', {
)
.execute()
if (result[0].affectedRows == 1) {
for (const client of clients) {
client.send(
JSON.stringify({
@@ -153,6 +154,7 @@ app.ws('/ws', {
})
)
}
}
connection0.end()
connection1.end()
@@ -182,7 +184,7 @@ app.ws('/ws', {
const userId = authResult.id
const time = Math.floor(Date.now() / 1000)
await db1
const result = await db1
.update(berryDashChats)
.set({
deletedAt: time
@@ -195,6 +197,7 @@ app.ws('/ws', {
)
.execute()
if (result[0].affectedRows == 1) {
const chatRows = await db1
.select({
id: berryDashChats.id,
@@ -220,7 +223,6 @@ app.ws('/ws', {
)
}
const chat = chatRows[0]
console.log(chat)
const userData = await db1
.select({
@@ -278,6 +280,7 @@ app.ws('/ws', {
})
)
}
}
connection0.end()
connection1.end()

View File

@@ -17,7 +17,7 @@ export async function checkAuthorization (
if (!userData[0]) return { valid: false, id: 0 }
else {
if (updateIp != undefined && updateIp != null && db0 != undefined)
if (updateIp != null)
db0
.update(users)
.set({ latestIp: updateIp })