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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"bamarni/composer-bin-plugin": true
},
"platform": {
"php": "8.1"
"php": "8.2"
}
},
"scripts": {
Expand Down
5 changes: 2 additions & 3 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

namespace OCA\Deck\AppInfo;

use Closure;
use Exception;
use OCA\Circles\Events\CircleDestroyedEvent;
use OCA\Deck\Capabilities;
Expand Down Expand Up @@ -99,8 +98,8 @@ public function __construct(array $urlParams = []) {
}

public function boot(IBootContext $context): void {
$context->injectFn(Closure::fromCallable([$this, 'registerCommentsEntity']));
$context->injectFn(Closure::fromCallable([$this, 'registerCollaborationResources']));
$context->injectFn($this->registerCommentsEntity(...));
$context->injectFn($this->registerCollaborationResources(...));

$context->injectFn(function (IManager $shareManager) {
$shareManager->registerShareProvider(DeckShareProvider::class);
Expand Down
16 changes: 6 additions & 10 deletions lib/Db/Assignment.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@ public function __construct() {
}

public function getTypeString(): string {
switch ($this->getType()) {
case self::TYPE_USER:
return 'user';
case self::TYPE_GROUP:
return 'group';
case self::TYPE_CIRCLE:
return 'circle';
}

return 'unknown';
return match ($this->getType()) {
self::TYPE_USER => 'user',
self::TYPE_GROUP => 'group',
self::TYPE_CIRCLE => 'circle',
default => 'unknown',
};
}
}
54 changes: 15 additions & 39 deletions lib/Notification/NotificationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,43 +31,19 @@

class NotificationHelper {

/** @var CardMapper */
protected $cardMapper;
/** @var BoardMapper */
protected $boardMapper;
/** @var AssignmentMapper */
protected $assignmentMapper;
/** @var PermissionService */
protected $permissionService;
/** @var IConfig */
protected $config;
/** @var IManager */
protected $notificationManager;
/** @var IGroupManager */
protected $groupManager;
/** @var string */
protected $currentUser;
/** @var array */
private $boards = [];
private array $boards = [];

public function __construct(
CardMapper $cardMapper,
BoardMapper $boardMapper,
AssignmentMapper $assignmentMapper,
PermissionService $permissionService,
IConfig $config,
IManager $notificationManager,
IGroupManager $groupManager,
$userId,
protected readonly CardMapper $cardMapper,
protected readonly BoardMapper $boardMapper,
protected readonly AssignmentMapper $assignmentMapper,
protected readonly PermissionService $permissionService,
protected readonly IConfig $config,
protected readonly IManager $notificationManager,
protected readonly IGroupManager $groupManager,
protected readonly ?string $userId,
) {
$this->cardMapper = $cardMapper;
$this->boardMapper = $boardMapper;
$this->assignmentMapper = $assignmentMapper;
$this->permissionService = $permissionService;
$this->config = $config;
$this->notificationManager = $notificationManager;
$this->groupManager = $groupManager;
$this->currentUser = $userId;
}

/**
Expand Down Expand Up @@ -145,7 +121,7 @@ public function sendCardAssigned(Card $card, string $userId): void {
->setSubject('card-assigned', [
$card->getTitle(),
$board->getTitle(),
$this->currentUser
$this->userId
]);
$this->notificationManager->notify($notification);
}
Expand Down Expand Up @@ -174,7 +150,7 @@ public function sendBoardShared(int $boardId, Acl $acl, bool $markAsRead = false
$notification = $this->generateBoardShared($board, $acl->getParticipant());
if ($markAsRead) {
$this->notificationManager->markProcessed($notification);
} elseif ($acl->getParticipant() !== $this->currentUser) {
} elseif ($acl->getParticipant() !== $this->userId) {
$notification->setDateTime(new DateTime());
$this->notificationManager->notify($notification);
}
Expand All @@ -185,7 +161,7 @@ public function sendBoardShared(int $boardId, Acl $acl, bool $markAsRead = false
return;
}
foreach ($group->getUsers() as $user) {
if ($user->getUID() === $this->currentUser) {
if ($user->getUID() === $this->userId) {
continue;
}
$notification = $this->generateBoardShared($board, $user->getUID());
Expand All @@ -201,7 +177,7 @@ public function sendBoardShared(int $boardId, Acl $acl, bool $markAsRead = false

public function sendMention(IComment $comment): void {
foreach ($comment->getMentions() as $mention) {
if ((string)$mention['id'] === $this->currentUser) {
if ((string)$mention['id'] === $this->userId) {
continue;
}
$card = $this->cardMapper->find($comment->getObjectId());
Expand All @@ -212,7 +188,7 @@ public function sendMention(IComment $comment): void {
->setUser((string)$mention['id'])
->setDateTime(new DateTime())
->setObject('card', (string)$card->getId())
->setSubject('card-comment-mentioned', [$card->getTitle(), $boardId, $this->currentUser])
->setSubject('card-comment-mentioned', [$card->getTitle(), $boardId, $this->userId])
->setMessage('{message}', ['message' => $comment->getMessage()]);
$this->notificationManager->notify($notification);
}
Expand All @@ -235,7 +211,7 @@ private function generateBoardShared(Board $board, string $userId): INotificatio
->setApp('deck')
->setUser($userId)
->setObject('board', (string)$board->getId())
->setSubject('board-shared', [$board->getTitle(), $this->currentUser]);
->setSubject('board-shared', [$board->getTitle(), $this->userId]);
return $notification;
}
}
31 changes: 6 additions & 25 deletions lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,14 @@
use OCP\Notification\UnknownNotificationException;

class Notifier implements INotifier {
/** @var IFactory */
protected $l10nFactory;
/** @var IURLGenerator */
protected $url;
/** @var IUserManager */
protected $userManager;
/** @var CardMapper */
protected $cardMapper;
/** @var StackMapper */
protected $stackMapper;
/** @var BoardMapper */
protected $boardMapper;

public function __construct(
IFactory $l10nFactory,
IURLGenerator $url,
IUserManager $userManager,
CardMapper $cardMapper,
StackMapper $stackMapper,
BoardMapper $boardMapper,
protected readonly IFactory $l10nFactory,
protected readonly IURLGenerator $url,
protected readonly IUserManager $userManager,
protected readonly CardMapper $cardMapper,
protected readonly StackMapper $stackMapper,
protected readonly BoardMapper $boardMapper,
) {
$this->l10nFactory = $l10nFactory;
$this->url = $url;
$this->userManager = $userManager;
$this->cardMapper = $cardMapper;
$this->stackMapper = $stackMapper;
$this->boardMapper = $boardMapper;
}

/**
Expand Down
13 changes: 3 additions & 10 deletions lib/Search/DeckProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,11 @@
use OCP\Search\SearchResult;

class DeckProvider implements IProvider {
private IL10N $l10n;
private SearchService $searchService;
private IURLGenerator $urlGenerator;

public function __construct(
SearchService $searchService,
IURLGenerator $urlGenerator,
IL10N $l10n,
private readonly SearchService $searchService,
private readonly IURLGenerator $urlGenerator,
private readonly IL10N $l10n,
) {
$this->l10n = $l10n;
$this->searchService = $searchService;
$this->urlGenerator = $urlGenerator;
}

public function getId(): string {
Expand Down
11 changes: 3 additions & 8 deletions lib/Search/FilterStringParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@
use OCP\IL10N;

class FilterStringParser {

/**
* @var IL10N
*/
private $l10n;

public function __construct(IL10N $l10n) {
$this->l10n = $l10n;
public function __construct(
private readonly IL10N $l10n,
) {
}

public function parse(?string $filter): SearchQuery {
Expand Down
75 changes: 12 additions & 63 deletions lib/Service/AssignmentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,69 +25,18 @@
use OCP\EventDispatcher\IEventDispatcher;

class AssignmentService {

/**
* @var PermissionService
*/
private $permissionService;
/**
* @var CardMapper
*/
private $cardMapper;
/**
* @var AssignmentMapper
*/
private $assignedUsersMapper;
/**
* @var AclMapper
*/
private $aclMapper;
/**
* @var NotificationHelper
*/
private $notificationHelper;
/**
* @var ChangeHelper
*/
private $changeHelper;
/**
* @var ActivityManager
*/
private $activityManager;
/**
* @var IEventDispatcher
*/
private $eventDispatcher;
/** @var string|null */
private $currentUser;
/**
* @var AssignmentServiceValidator
*/
private $assignmentServiceValidator;


public function __construct(
PermissionService $permissionService,
CardMapper $cardMapper,
AssignmentMapper $assignedUsersMapper,
AclMapper $aclMapper,
NotificationHelper $notificationHelper,
ActivityManager $activityManager,
ChangeHelper $changeHelper,
IEventDispatcher $eventDispatcher,
AssignmentServiceValidator $assignmentServiceValidator,
$userId,
private readonly PermissionService $permissionService,
private readonly CardMapper $cardMapper,
private readonly AssignmentMapper $assignedUsersMapper,
private readonly AclMapper $aclMapper,
private readonly NotificationHelper $notificationHelper,
private readonly ActivityManager $activityManager,
private readonly ChangeHelper $changeHelper,
private readonly IEventDispatcher $eventDispatcher,
private readonly AssignmentServiceValidator $assignmentServiceValidator,
private readonly ?string $userId,
) {
$this->assignmentServiceValidator = $assignmentServiceValidator;
$this->permissionService = $permissionService;
$this->cardMapper = $cardMapper;
$this->assignedUsersMapper = $assignedUsersMapper;
$this->aclMapper = $aclMapper;
$this->notificationHelper = $notificationHelper;
$this->changeHelper = $changeHelper;
$this->activityManager = $activityManager;
$this->eventDispatcher = $eventDispatcher;
$this->currentUser = $userId;
}

/**
Expand Down Expand Up @@ -122,7 +71,7 @@ public function assignUser(int $cardId, string $userId, int $type = Assignment::
}


if ($type === Assignment::TYPE_USER && $userId !== $this->currentUser) {
if ($type === Assignment::TYPE_USER && $userId !== $this->userId) {
$this->notificationHelper->sendCardAssigned($card, $userId);
}

Expand Down Expand Up @@ -156,7 +105,7 @@ public function unassignUser(int $cardId, string $userId, int $type = 0): Assign
$assignment = $this->assignedUsersMapper->delete($assignment);
$card = $this->cardMapper->find($cardId);
$this->activityManager->triggerEvent(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_USER_UNASSIGN, ['assigneduser' => $userId]);
if ($type === Assignment::TYPE_USER && $userId !== $this->currentUser) {
if ($type === Assignment::TYPE_USER && $userId !== $this->userId) {
$this->notificationHelper->markCardAssignedAsRead($card, $userId);
}
$this->changeHelper->cardChanged($cardId);
Expand Down
54 changes: 12 additions & 42 deletions lib/Service/AttachmentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,52 +28,22 @@
use Psr\Container\ContainerExceptionInterface;

class AttachmentService {
private $attachmentMapper;
private $cardMapper;
private $permissionService;
private $userId;

/** @var IAttachmentService[] */
private $services = [];
/** @var Application */
private $application;
/** @var AttachmentCacheHelper */
private $attachmentCacheHelper;
/** @var IL10N */
private $l10n;
/** @var ActivityManager */
private $activityManager;
/** @var ChangeHelper */
private $changeHelper;
private IUserManager $userManager;
/** @var AttachmentServiceValidator */
private AttachmentServiceValidator $attachmentServiceValidator;
private array $services = [];

public function __construct(
AttachmentMapper $attachmentMapper,
CardMapper $cardMapper,
IUserManager $userManager,
ChangeHelper $changeHelper,
PermissionService $permissionService,
Application $application,
AttachmentCacheHelper $attachmentCacheHelper,
$userId,
IL10N $l10n,
ActivityManager $activityManager,
AttachmentServiceValidator $attachmentServiceValidator,
private readonly AttachmentMapper $attachmentMapper,
private readonly CardMapper $cardMapper,
private readonly IUserManager $userManager,
private readonly ChangeHelper $changeHelper,
private readonly PermissionService $permissionService,
private readonly Application $application,
private readonly AttachmentCacheHelper $attachmentCacheHelper,
private readonly ?string $userId,
private readonly IL10N $l10n,
private readonly ActivityManager $activityManager,
private readonly AttachmentServiceValidator $attachmentServiceValidator,
) {
$this->attachmentMapper = $attachmentMapper;
$this->cardMapper = $cardMapper;
$this->permissionService = $permissionService;
$this->userId = $userId;
$this->application = $application;
$this->attachmentCacheHelper = $attachmentCacheHelper;
$this->l10n = $l10n;
$this->activityManager = $activityManager;
$this->changeHelper = $changeHelper;
$this->userManager = $userManager;
$this->attachmentServiceValidator = $attachmentServiceValidator;

// Register shipped attachment services
// TODO: move this to a plugin based approach once we have different types of attachments
$this->registerAttachmentService('deck_file', FileService::class);
Expand Down
Loading
Loading