Merge pull request #2532 from nextcloud/bugfix/2176
This commit is contained in:
@@ -23,6 +23,8 @@
|
|||||||
|
|
||||||
namespace OCA\Deck\Db;
|
namespace OCA\Deck\Db;
|
||||||
|
|
||||||
|
use OCP\AppFramework\Db\DoesNotExistException;
|
||||||
|
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
|
|
||||||
class AclMapper extends DeckMapper implements IPermissionMapper {
|
class AclMapper extends DeckMapper implements IPermissionMapper {
|
||||||
@@ -43,8 +45,12 @@ class AclMapper extends DeckMapper implements IPermissionMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function findBoardId($aclId): ?int {
|
public function findBoardId($aclId): ?int {
|
||||||
$entity = $this->find($aclId);
|
try {
|
||||||
return $entity->getBoardId();
|
$entity = $this->find($aclId);
|
||||||
|
return $entity->getBoardId();
|
||||||
|
} catch (DoesNotExistException | MultipleObjectsReturnedException $e) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findByParticipant($type, $participant): array {
|
public function findByParticipant($type, $participant): array {
|
||||||
|
|||||||
@@ -322,8 +322,7 @@ class CardMapper extends QBMapper implements IPermissionMapper {
|
|||||||
$stmt = $this->db->prepare($sql);
|
$stmt = $this->db->prepare($sql);
|
||||||
$stmt->bindParam(1, $cardId, \PDO::PARAM_INT);
|
$stmt->bindParam(1, $cardId, \PDO::PARAM_INT);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$row = $stmt->fetch();
|
return $stmt->fetchColumn() ?? null;
|
||||||
return $row['id'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mapOwner(Card &$card) {
|
public function mapOwner(Card &$card) {
|
||||||
|
|||||||
@@ -23,7 +23,9 @@
|
|||||||
|
|
||||||
namespace OCA\Deck\Db;
|
namespace OCA\Deck\Db;
|
||||||
|
|
||||||
|
use OCP\AppFramework\Db\DoesNotExistException;
|
||||||
use OCP\AppFramework\Db\Entity;
|
use OCP\AppFramework\Db\Entity;
|
||||||
|
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
|
|
||||||
class LabelMapper extends DeckMapper implements IPermissionMapper {
|
class LabelMapper extends DeckMapper implements IPermissionMapper {
|
||||||
@@ -100,7 +102,12 @@ class LabelMapper extends DeckMapper implements IPermissionMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function findBoardId($labelId): ?int {
|
public function findBoardId($labelId): ?int {
|
||||||
$entity = $this->find($labelId);
|
try {
|
||||||
return $entity->getBoardId();
|
$entity = $this->find($labelId);
|
||||||
|
return $entity->getBoardId();
|
||||||
|
} catch (DoesNotExistException $e) {
|
||||||
|
} catch (MultipleObjectsReturnedException $e) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,9 @@
|
|||||||
|
|
||||||
namespace OCA\Deck\Db;
|
namespace OCA\Deck\Db;
|
||||||
|
|
||||||
|
use OCP\AppFramework\Db\DoesNotExistException;
|
||||||
use OCP\AppFramework\Db\Entity;
|
use OCP\AppFramework\Db\Entity;
|
||||||
|
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||||
use OCP\IDBConnection;
|
use OCP\IDBConnection;
|
||||||
|
|
||||||
class StackMapper extends DeckMapper implements IPermissionMapper {
|
class StackMapper extends DeckMapper implements IPermissionMapper {
|
||||||
@@ -75,7 +77,12 @@ class StackMapper extends DeckMapper implements IPermissionMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function findBoardId($stackId): ?int {
|
public function findBoardId($stackId): ?int {
|
||||||
$entity = $this->find($stackId);
|
try {
|
||||||
return $entity->getBoardId();
|
$entity = $this->find($stackId);
|
||||||
|
return $entity->getBoardId();
|
||||||
|
} catch (DoesNotExistException $e) {
|
||||||
|
} catch (MultipleObjectsReturnedException $e) {
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ use OCA\Deck\Db\CardMapper;
|
|||||||
use OCP\IURLGenerator;
|
use OCP\IURLGenerator;
|
||||||
use OCP\IUserManager;
|
use OCP\IUserManager;
|
||||||
use OCP\L10N\IFactory;
|
use OCP\L10N\IFactory;
|
||||||
|
use OCP\Notification\AlreadyProcessedException;
|
||||||
use OCP\Notification\INotification;
|
use OCP\Notification\INotification;
|
||||||
use OCP\Notification\INotifier;
|
use OCP\Notification\INotifier;
|
||||||
|
|
||||||
@@ -96,6 +97,9 @@ class Notifier implements INotifier {
|
|||||||
case 'card-assigned':
|
case 'card-assigned':
|
||||||
$cardId = $notification->getObjectId();
|
$cardId = $notification->getObjectId();
|
||||||
$boardId = $this->cardMapper->findBoardId($cardId);
|
$boardId = $this->cardMapper->findBoardId($cardId);
|
||||||
|
if (!$boardId) {
|
||||||
|
throw new AlreadyProcessedException();
|
||||||
|
}
|
||||||
$initiator = $this->userManager->get($params[2]);
|
$initiator = $this->userManager->get($params[2]);
|
||||||
if ($initiator !== null) {
|
if ($initiator !== null) {
|
||||||
$dn = $initiator->getDisplayName();
|
$dn = $initiator->getDisplayName();
|
||||||
@@ -120,6 +124,9 @@ class Notifier implements INotifier {
|
|||||||
case 'card-overdue':
|
case 'card-overdue':
|
||||||
$cardId = $notification->getObjectId();
|
$cardId = $notification->getObjectId();
|
||||||
$boardId = $this->cardMapper->findBoardId($cardId);
|
$boardId = $this->cardMapper->findBoardId($cardId);
|
||||||
|
if (!$boardId) {
|
||||||
|
throw new AlreadyProcessedException();
|
||||||
|
}
|
||||||
$notification->setParsedSubject(
|
$notification->setParsedSubject(
|
||||||
(string) $l->t('The card "%s" on "%s" has reached its due date.', $params)
|
(string) $l->t('The card "%s" on "%s" has reached its due date.', $params)
|
||||||
);
|
);
|
||||||
@@ -128,6 +135,9 @@ class Notifier implements INotifier {
|
|||||||
case 'card-comment-mentioned':
|
case 'card-comment-mentioned':
|
||||||
$cardId = $notification->getObjectId();
|
$cardId = $notification->getObjectId();
|
||||||
$boardId = $this->cardMapper->findBoardId($cardId);
|
$boardId = $this->cardMapper->findBoardId($cardId);
|
||||||
|
if (!$boardId) {
|
||||||
|
throw new AlreadyProcessedException();
|
||||||
|
}
|
||||||
$initiator = $this->userManager->get($params[2]);
|
$initiator = $this->userManager->get($params[2]);
|
||||||
if ($initiator !== null) {
|
if ($initiator !== null) {
|
||||||
$dn = $initiator->getDisplayName();
|
$dn = $initiator->getDisplayName();
|
||||||
@@ -154,6 +164,9 @@ class Notifier implements INotifier {
|
|||||||
break;
|
break;
|
||||||
case 'board-shared':
|
case 'board-shared':
|
||||||
$boardId = $notification->getObjectId();
|
$boardId = $notification->getObjectId();
|
||||||
|
if (!$boardId) {
|
||||||
|
throw new AlreadyProcessedException();
|
||||||
|
}
|
||||||
$initiator = $this->userManager->get($params[1]);
|
$initiator = $this->userManager->get($params[1]);
|
||||||
if ($initiator !== null) {
|
if ($initiator !== null) {
|
||||||
$dn = $initiator->getDisplayName();
|
$dn = $initiator->getDisplayName();
|
||||||
|
|||||||
@@ -177,6 +177,10 @@ class NotifierTest extends \Test\TestCase {
|
|||||||
|
|
||||||
/** @dataProvider dataPrepareCardAssigned */
|
/** @dataProvider dataPrepareCardAssigned */
|
||||||
public function testPrepareCardAssigned($withUserFound = true) {
|
public function testPrepareCardAssigned($withUserFound = true) {
|
||||||
|
$this->cardMapper->expects($this->once())
|
||||||
|
->method('findBoardId')
|
||||||
|
->willReturn(123);
|
||||||
|
|
||||||
/** @var INotification $notification */
|
/** @var INotification $notification */
|
||||||
$notification = $this->createMock(INotification::class);
|
$notification = $this->createMock(INotification::class);
|
||||||
$notification->expects($this->once())
|
$notification->expects($this->once())
|
||||||
|
|||||||
Reference in New Issue
Block a user