Skip to content
Merged
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
20 changes: 20 additions & 0 deletions lib/private/Comments/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -523,4 +523,24 @@ protected function fromArray($data): IComment {

return $this;
}

#[\Override]
public function jsonSerialize(): mixed {
return [
'id' => $this->getId(),
'parent_id' => $this->getParentId(),
'top_parent_id' => $this->getTopmostParentId(),
'children_count' => $this->getChildrenCount(),
'message' => $this->getMessage(),
'actor_type' => $this->getActorType(),
'actor_id' => $this->getActorId(),
'object_type' => $this->getObjectType(),
'object_id' => $this->getObjectId(),
'reference_id' => $this->getReferenceId(),
'metadata' => $this->getMetaData(),
'creation_time' => $this->getCreationDateTime()->format(\DateTimeInterface::ATOM),
'reactions' => $this->getReactions(),
'expire_data' => $this->getExpireDate(),
];
}
}
13 changes: 12 additions & 1 deletion lib/public/Comments/CommentsEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use OCP\AppFramework\Attribute\Consumable;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IWebhookCompatibleEvent;

/**
* Class CommentsEvent
Expand All @@ -19,7 +20,7 @@
* In the future, once the deprecated methods are removed, this class will be abstract.
*/
#[Consumable(since: '9.0.0')]
class CommentsEvent extends Event {
class CommentsEvent extends Event implements IWebhookCompatibleEvent {
/**
* @since 11.0.0
* @deprecated 33.0.0 Use \OCP\Comments\Events\CommentAddedEvent instead.
Expand Down Expand Up @@ -70,4 +71,14 @@ public function getEvent(): string {
public function getComment(): IComment {
return $this->comment;
}

/**
* @since 35.0.2
*/
#[\Override]
public function getWebhookSerializable(): array {
return [
'comment' => $this->comment,
];
}
}
4 changes: 3 additions & 1 deletion lib/public/Comments/IComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@

namespace OCP\Comments;

use JsonSerializable;

/**
* Interface IComment
*
* This class represents a comment
*
* @since 9.0.0
*/
interface IComment {
interface IComment extends JsonSerializable {
/**
* @since 9.0.0
*/
Expand Down
Loading