export json data of commments

Signed-off-by: grnd-alt <salimbelakkaf@outlook.de>
This commit is contained in:
grnd-alt
2024-07-19 12:16:09 +02:00
committed by Julius Härtl
parent db00879b6a
commit 09748aebb9
5 changed files with 50 additions and 5 deletions

View File

@@ -12,6 +12,7 @@ use OCA\Deck\Db\CardMapper;
use OCA\Deck\Db\StackMapper;
use OCA\Deck\Model\CardDetails;
use OCA\Deck\Service\BoardService;
use OCA\Deck\Service\CommentService;
use OCP\App\IAppManager;
use OCP\DB\Exception;
use Symfony\Component\Console\Command\Command;
@@ -27,6 +28,7 @@ class UserExport extends Command {
private StackMapper $stackMapper,
private CardMapper $cardMapper,
private AssignmentMapper $assignedUsersMapper,
private CommentService $commentService,
) {
parent::__construct();
}
@@ -56,6 +58,9 @@ class UserExport extends Command {
$data = [];
foreach ($boards as $board) {
if ($board->getDeletedAt() > 0) {
continue;
}
$fullBoard = $this->boardMapper->find($board->getId(), true, true);
$data[$board->getId()] = $fullBoard->jsonSerialize();
$stacks = $this->stackMapper->findAll($board->getId());
@@ -68,7 +73,13 @@ class UserExport extends Command {
$fullCard->setAssignedUsers($assignedUsers);
$cardDetails = new CardDetails($fullCard, $fullBoard);
$data[$board->getId()]['stacks'][$stack->getId()]['cards'][] = $cardDetails->jsonSerialize();
$comments = $this->commentService->list($card->getId());
$cardDetails->setCommentsCount(count($comments->getData()));
$cardJson = $cardDetails->jsonSerialize();
$cardJson['comments'] = $comments->getData();
$data[$board->getId()]['stacks'][$stack->getId()]['cards'][] = $cardJson;
}
}
}

View File

@@ -58,7 +58,7 @@ class CommentEventListener implements IEventListener {
private function activityHandler(CommentsEvent $event): void {
$comment = $event->getComment();
$card = $this->cardMapper->find($comment->getObjectId());
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_COMMENT_CREATE, ['comment' => $comment]);
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_COMMENT_CREATE, ['comment' => $comment], $comment->getActorId());
}
private function notificationHandler(CommentsEvent $event): void {

View File

@@ -6,6 +6,7 @@
namespace OCA\Deck\Service\Importer\Systems;
use OC\Comments\Comment;
use OCA\Deck\BadRequestException;
use OCA\Deck\Db\Acl;
use OCA\Deck\Db\Assignment;
@@ -103,8 +104,20 @@ class DeckJsonService extends ABoardImportService {
}
public function getComments(): array {
// Comments are not implemented in export
return [];
$comments = [];
foreach ($this->tmpCards as $sourceCard) {
if (!property_exists($sourceCard, "comments")) {
continue;
}
$commentsOriginal = $sourceCard->comments;
foreach ($commentsOriginal as $commentOriginal) {
$comment = new Comment();
$comment->setActor($commentOriginal->actorType, $commentOriginal->actorId)
->setMessage($commentOriginal->message)->setCreationDateTime(\DateTime::createFromFormat('Y-m-d\TH:i:sP', $commentOriginal->creationDateTime));
$comments[$this->cards[$sourceCard->id]->getId()][$commentOriginal->id] = $comment;
}
}
return $comments;
}
public function getCardLabelAssignment(): array {