Skip to content
Open
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: 19 additions & 1 deletion lib/Activity/DeckProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use OCA\Deck\Db\Acl;
use OCA\Deck\Service\CardService;
use OCA\Deck\Service\DiffService;
use OCP\Activity\IEvent;
use OCP\Activity\IProvider;
use OCP\Comments\IComment;
Expand Down Expand Up @@ -37,8 +38,10 @@ class DeckProvider implements IProvider {
private $config;
/** @var CardService */
private $cardService;
/** @var DiffService */
private $diffService;

public function __construct(IURLGenerator $urlGenerator, ActivityManager $activityManager, IUserManager $userManager, ICommentsManager $commentsManager, IFactory $l10n, IConfig $config, $userId, CardService $cardService) {
public function __construct(IURLGenerator $urlGenerator, ActivityManager $activityManager, IUserManager $userManager, ICommentsManager $commentsManager, IFactory $l10n, IConfig $config, $userId, CardService $cardService, DiffService $diffService) {
$this->userId = $userId;
$this->urlGenerator = $urlGenerator;
$this->activityManager = $activityManager;
Expand All @@ -47,6 +50,7 @@ public function __construct(IURLGenerator $urlGenerator, ActivityManager $activi
$this->l10nFactory = $l10n;
$this->config = $config;
$this->cardService = $cardService;
$this->diffService = $diffService;
}

/**
Expand Down Expand Up @@ -335,6 +339,20 @@ private function parseParamForDuedate($subjectParams, $params, IEvent $event) {
* @return mixed
*/
private function parseParamForChanges($subjectParams, $params, $event) {
// Handle card description changes with visual diff
if ($event->getSubject() === ActivityManager::SUBJECT_CARD_UPDATE_DESCRIPTION &&
array_key_exists('before', $subjectParams) && array_key_exists('after', $subjectParams)) {

$before = (string)($subjectParams['before'] ?? '');
$after = (string)($subjectParams['after'] ?? '');

// Generate visual diff and set as parsed message
$diffHtml = $this->diffService->generateDiff($before, $after);
$event->setParsedMessage($diffHtml);

return $params;
}

if (array_key_exists('diff', $subjectParams) && $subjectParams['diff'] && !empty($subjectParams['after'])) {
// Don't add diff as message since we are limited to 255 chars here
$event->setParsedMessage($subjectParams['after']);
Expand Down
6 changes: 6 additions & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
use OCA\Deck\Reference\CreateCardReferenceProvider;
use OCA\Deck\Search\CardCommentProvider;
use OCA\Deck\Search\DeckProvider;
use OCA\Deck\Service\DiffService;
use OCA\Deck\Service\PermissionService;
use OCA\Deck\Sharing\DeckShareProvider;
use OCA\Deck\Sharing\Listener;
Expand Down Expand Up @@ -119,6 +120,11 @@ public function register(IRegistrationContext $context): void {
return $c->get(IDBConnection::class)->supports4ByteText();
});

// Register DiffService for dependency injection
$context->registerService(DiffService::class, static function (ContainerInterface $c) {
return new DiffService();
});

$context->registerSearchProvider(DeckProvider::class);
$context->registerSearchProvider(CardCommentProvider::class);
$context->registerDashboardWidget(DeckWidgetUpcoming::class);
Expand Down
Loading