feat(threads): Add room token to thread info for future search and widgets

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling
2025-07-10 16:31:54 +02:00
parent 78573cc91c
commit e6d2969c3c
3 changed files with 6 additions and 4 deletions

View File

@ -147,7 +147,7 @@ class ThreadController extends AEnvironmentAwareOCSController {
}
$list[] = [
'thread' => $thread->jsonSerialize(),
'thread' => $thread->toArray($this->room),
'attendee' => $attendee->jsonSerialize(),
'first' => $firstMessage?->toArray($this->getResponseFormat()),
'last' => $lastMessage?->toArray($this->getResponseFormat()),

View File

@ -10,6 +10,7 @@ declare(strict_types=1);
namespace OCA\Talk\Model;
use OCA\Talk\ResponseDefinitions;
use OCA\Talk\Room;
use OCP\AppFramework\Db\Entity;
use OCP\DB\Types;
@ -27,7 +28,7 @@ use OCP\DB\Types;
*
* @psalm-import-type TalkThread from ResponseDefinitions
*/
class Thread extends Entity implements \JsonSerializable {
class Thread extends Entity {
protected int $roomId = 0;
protected int $lastMessageId = 0;
protected int $numReplies = 0;
@ -45,11 +46,11 @@ class Thread extends Entity implements \JsonSerializable {
/**
* @return TalkThread
*/
#[\Override]
public function jsonSerialize(): array {
public function toArray(Room $room): array {
return [
'id' => max(1, $this->getId()),
// 'roomId' => max(1, $this->getRoomId()),
'roomToken' => $room->getToken(),
'lastMessageId' => max(0, $this->getLastMessageId()),
'numReplies' => max(0, $this->getNumReplies()),
'lastActivity' => max(0, $this->getLastActivity()?->getTimestamp() ?? 0),

View File

@ -449,6 +449,7 @@ namespace OCA\Talk;
*
* @psalm-type TalkThread = array{
* id: positive-int,
* roomToken: string,
* lastMessageId: non-negative-int,
* lastActivity: non-negative-int,
* numReplies: non-negative-int,