add link to the thread of a message

This commit is contained in:
grimhilt
2023-07-15 00:19:39 +02:00
parent 3bffd88108
commit edddf9afbf
5 changed files with 37 additions and 2 deletions

View File

@@ -38,6 +38,7 @@ export async function getRooms(mailboxId: number) {
room.room_type AS roomType,
mailbox_message.mailbox_id AS mailboxId,
app_thread.parent_id
FROM app_room room
INNER JOIN message ON message.message_id = room.message_id
INNER JOIN mailbox_message ON mailbox_message.message_id = message.message_id
@@ -55,6 +56,7 @@ export async function getRooms(mailboxId: number) {
)
) notSeenRoom ON notSeenRoom.room_id = room.room_id
-- get not seen in thread
LEFT JOIN (
SELECT app_room_message.message_id, app_thread.parent_id
FROM app_room
@@ -89,7 +91,8 @@ export async function getMessages(roomId: number) {
subjectT.value AS subject,
content.text AS content,
message.idate AS date,
GROUP_CONCAT(flagT.flag_name) AS flags
GROUP_CONCAT(flagT.flag_name) AS flags,
thread.room_id AS thread
FROM app_room_message msg
${queryFromId} fromT ON msg.message_id = fromT.message_id
@@ -120,6 +123,13 @@ export async function getMessages(roomId: number) {
LEFT JOIN flag_name flagT ON flagT.flag_id = flag.flag_id
INNER JOIN message ON message.message_id = msg.message_id
-- get room_id of thread room with this message as origin
LEFT JOIN app_room thread ON (
thread.message_id = msg.message_id AND
msg.room_id != thread.room_id AND
thread.room_type = 4
)
WHERE msg.room_id = ?
GROUP BY msg.message_id