mirror of
https://github.com/nextcloud/spreed.git
synced 2025-07-22 06:48:21 +00:00
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:
@ -147,7 +147,7 @@ class ThreadController extends AEnvironmentAwareOCSController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$list[] = [
|
$list[] = [
|
||||||
'thread' => $thread->jsonSerialize(),
|
'thread' => $thread->toArray($this->room),
|
||||||
'attendee' => $attendee->jsonSerialize(),
|
'attendee' => $attendee->jsonSerialize(),
|
||||||
'first' => $firstMessage?->toArray($this->getResponseFormat()),
|
'first' => $firstMessage?->toArray($this->getResponseFormat()),
|
||||||
'last' => $lastMessage?->toArray($this->getResponseFormat()),
|
'last' => $lastMessage?->toArray($this->getResponseFormat()),
|
||||||
|
@ -10,6 +10,7 @@ declare(strict_types=1);
|
|||||||
namespace OCA\Talk\Model;
|
namespace OCA\Talk\Model;
|
||||||
|
|
||||||
use OCA\Talk\ResponseDefinitions;
|
use OCA\Talk\ResponseDefinitions;
|
||||||
|
use OCA\Talk\Room;
|
||||||
use OCP\AppFramework\Db\Entity;
|
use OCP\AppFramework\Db\Entity;
|
||||||
use OCP\DB\Types;
|
use OCP\DB\Types;
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ use OCP\DB\Types;
|
|||||||
*
|
*
|
||||||
* @psalm-import-type TalkThread from ResponseDefinitions
|
* @psalm-import-type TalkThread from ResponseDefinitions
|
||||||
*/
|
*/
|
||||||
class Thread extends Entity implements \JsonSerializable {
|
class Thread extends Entity {
|
||||||
protected int $roomId = 0;
|
protected int $roomId = 0;
|
||||||
protected int $lastMessageId = 0;
|
protected int $lastMessageId = 0;
|
||||||
protected int $numReplies = 0;
|
protected int $numReplies = 0;
|
||||||
@ -45,11 +46,11 @@ class Thread extends Entity implements \JsonSerializable {
|
|||||||
/**
|
/**
|
||||||
* @return TalkThread
|
* @return TalkThread
|
||||||
*/
|
*/
|
||||||
#[\Override]
|
public function toArray(Room $room): array {
|
||||||
public function jsonSerialize(): array {
|
|
||||||
return [
|
return [
|
||||||
'id' => max(1, $this->getId()),
|
'id' => max(1, $this->getId()),
|
||||||
// 'roomId' => max(1, $this->getRoomId()),
|
// 'roomId' => max(1, $this->getRoomId()),
|
||||||
|
'roomToken' => $room->getToken(),
|
||||||
'lastMessageId' => max(0, $this->getLastMessageId()),
|
'lastMessageId' => max(0, $this->getLastMessageId()),
|
||||||
'numReplies' => max(0, $this->getNumReplies()),
|
'numReplies' => max(0, $this->getNumReplies()),
|
||||||
'lastActivity' => max(0, $this->getLastActivity()?->getTimestamp() ?? 0),
|
'lastActivity' => max(0, $this->getLastActivity()?->getTimestamp() ?? 0),
|
||||||
|
@ -449,6 +449,7 @@ namespace OCA\Talk;
|
|||||||
*
|
*
|
||||||
* @psalm-type TalkThread = array{
|
* @psalm-type TalkThread = array{
|
||||||
* id: positive-int,
|
* id: positive-int,
|
||||||
|
* roomToken: string,
|
||||||
* lastMessageId: non-negative-int,
|
* lastMessageId: non-negative-int,
|
||||||
* lastActivity: non-negative-int,
|
* lastActivity: non-negative-int,
|
||||||
* numReplies: non-negative-int,
|
* numReplies: non-negative-int,
|
||||||
|
Reference in New Issue
Block a user