From abf8e39b064edd7be63c3cfd88026fe09c3377d2 Mon Sep 17 00:00:00 2001 From: Gian <47775302+gpunto@users.noreply.github.com> Date: Thu, 6 Aug 2026 14:31:31 +0200 Subject: [PATCH] Add the thread participant fields sent by the real backend --- src/helpers/threads.rb | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/helpers/threads.rb b/src/helpers/threads.rb index c61d1cc..e7589e9 100644 --- a/src/helpers/threads.rb +++ b/src/helpers/threads.rb @@ -1,6 +1,8 @@ # Builds the thread objects served by the threads query from the tracked messages: # every channel message with replies is a thread. +THREAD_PARTICIPANT_APP_PK = 102_398 + def query_threads(reply_limit:) parents = $message_list.select do |msg| msg['parent_id'].nil? && $message_list.any? { |reply| reply['parent_id'] == msg['id'] } @@ -29,6 +31,23 @@ def build_thread(parent:, reply_limit:) 'participant_count' => participants.count, 'reply_count' => replies.count, 'latest_replies' => replies.last(reply_limit), - 'thread_participants' => participants.map { |user| { 'user_id' => user['id'], 'user' => user } } + 'thread_participants' => participants.map { |user| build_thread_participant(parent: parent, user: user, replies: replies) } + } +end + +# Mirrors the fields the real backend sends for a thread participant. Clients generated from the +# OpenAPI spec require app_pk, channel_cid, created_at, last_read_at and custom. +def build_thread_participant(parent:, user:, replies:) + user_replies = replies.select { |reply| reply['user']['id'] == user['id'] } + { + 'app_pk' => THREAD_PARTICIPANT_APP_PK, + 'channel_cid' => parent['cid'], + 'thread_id' => parent['id'], + 'user_id' => user['id'], + 'user' => user, + 'created_at' => user_replies.first['created_at'], + 'last_read_at' => user_replies.last['created_at'], + 'last_thread_message_at' => user_replies.last['created_at'], + 'custom' => {} } end