Skip to content

Commit

Permalink
messages in folder should include sent threads
Browse files Browse the repository at this point in the history
  • Loading branch information
Joosakur committed Feb 13, 2025
1 parent c481d8f commit e5aeea2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -247,16 +247,13 @@ class MessageController(
return db.connect { dbc ->
requireMessageAccountAccess(dbc, user, clock, accountId)
dbc.read {
val accountAccessLimit = it.getAccountAccessLimit(accountId, user.id)

it.getReceivedThreads(
it.getThreads(
accountId,
pageSize = 20,
page,
featureConfig.municipalMessageAccountName,
featureConfig.serviceWorkerMessageAccountName,
folderId,
accountAccessLimit,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ fun Database.Read.getThreads(
page: Int,
municipalAccountName: String,
serviceWorkerAccountName: String,
folderId: MessageThreadFolderId? = null,
): PagedMessageThreads {
val threads =
createQuery {
Expand Down Expand Up @@ -487,7 +488,7 @@ SELECT
FROM message_thread_participant tp
JOIN message_thread t on t.id = tp.thread_id
LEFT JOIN application a ON t.application_id = a.id
WHERE tp.participant_id = ${bind(accountId)} AND tp.folder_id IS NULL
WHERE tp.participant_id = ${bind(accountId)} AND tp.folder_id IS NOT DISTINCT FROM ${bind(folderId)}
AND EXISTS (SELECT 1 FROM message m WHERE m.thread_id = t.id AND (m.sender_id = ${bind(accountId)} OR m.sent_at IS NOT NULL))
ORDER BY tp.last_message_timestamp DESC
LIMIT ${bind(pageSize)} OFFSET ${bind((page - 1) * pageSize)}
Expand Down

0 comments on commit e5aeea2

Please sign in to comment.