Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/Controller/ThreadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ protected function prepareListOfThreads(array $threads, ?array $attendees = null
$firstMessage = $lastMessage = null;
$attendee = $attendees[$thread->getId()] ?? null;
if ($attendee === null) {
// subscribed is set to false here, so clients know that attendee has not subscribed yet
$attendee = ThreadAttendee::createFromParticipant($thread->getId(), $participant);
}

Expand Down
6 changes: 6 additions & 0 deletions lib/Model/ThreadAttendee.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
* @method string getActorId()
* @method void setNotificationLevel(int $notificationLevel)
* @method int getNotificationLevel()
* @method void setSubscribed(bool $subscribed)
* @method int getSubscribed()
*
* @psalm-import-type TalkThreadAttendee from ResponseDefinitions
*/
Expand All @@ -36,6 +38,7 @@ class ThreadAttendee extends Entity implements \JsonSerializable {
protected string $actorType = '';
protected string $actorId = '';
protected int $notificationLevel = 0;
protected bool $subscribed = true;

public function __construct() {
$this->addType('roomId', Types::BIGINT);
Expand All @@ -44,6 +47,7 @@ public function __construct() {
$this->addType('actorType', Types::STRING);
$this->addType('actorId', Types::STRING);
$this->addType('notificationLevel', Types::INTEGER);
$this->addType('subscribed', Types::BOOLEAN);
}

public static function createFromRow(array $row): ThreadAttendee {
Expand All @@ -65,6 +69,7 @@ public static function createFromParticipant(int $threadId, Participant $partici
$attendee->setNotificationLevel(Participant::NOTIFY_DEFAULT);
$attendee->setActorType($participant->getAttendee()->getActorType());
$attendee->setActorId($participant->getAttendee()->getActorId());
$attendee->setSubscribed(false);
return $attendee;
}

Expand All @@ -75,6 +80,7 @@ public static function createFromParticipant(int $threadId, Participant $partici
public function jsonSerialize(): array {
return [
'notificationLevel' => min(3, max(0, $this->getNotificationLevel())),
'subscribed' => $this->getSubscribed() && $this->getNotificationLevel() !== Participant::NOTIFY_NEVER,
];
}
}
1 change: 1 addition & 0 deletions lib/ResponseDefinitions.php
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@
*
* @psalm-type TalkThreadAttendee = array{
* notificationLevel: 0|1|2|3,
* subscribed: bool,
* }
*
* @psalm-type TalkThreadInfo = array{
Expand Down
6 changes: 5 additions & 1 deletion openapi-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -2100,7 +2100,8 @@
"ThreadAttendee": {
"type": "object",
"required": [
"notificationLevel"
"notificationLevel",
"subscribed"
],
"properties": {
"notificationLevel": {
Expand All @@ -2112,6 +2113,9 @@
2,
3
]
},
"subscribed": {
"type": "boolean"
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2005,7 +2005,8 @@
"ThreadAttendee": {
"type": "object",
"required": [
"notificationLevel"
"notificationLevel",
"subscribed"
],
"properties": {
"notificationLevel": {
Expand All @@ -2017,6 +2018,9 @@
2,
3
]
},
"subscribed": {
"type": "boolean"
}
}
},
Expand Down
1 change: 1 addition & 0 deletions src/types/openapi/openapi-full.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2942,6 +2942,7 @@ export type components = {
* @enum {integer}
*/
notificationLevel: 0 | 1 | 2 | 3;
subscribed: boolean;
};
ThreadInfo: {
thread: components["schemas"]["Thread"];
Expand Down
1 change: 1 addition & 0 deletions src/types/openapi/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2404,6 +2404,7 @@ export type components = {
* @enum {integer}
*/
notificationLevel: 0 | 1 | 2 | 3;
subscribed: boolean;
};
ThreadInfo: {
thread: components["schemas"]["Thread"];
Expand Down
Loading