Add backend support for comments

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2018-10-04 17:29:28 +02:00
parent 10c09927e2
commit d3027acd37
6 changed files with 68 additions and 1 deletions

View File

@@ -28,6 +28,7 @@ use cogpowered\FineDiff\Diff;
use OCA\Deck\Db\Acl;
use OCP\Activity\IEvent;
use OCP\Activity\IProvider;
use OCP\Comments\IComment;
use OCP\IURLGenerator;
use OCP\IUserManager;
@@ -106,7 +107,7 @@ class DeckProvider implements IProvider {
'type' => 'user',
'id' => $author,
'name' => $user !== null ? $user->getDisplayName() : $author
]
],
];
$params = $this->parseParamForBoard('board', $subjectParams, $params);
@@ -117,6 +118,7 @@ class DeckProvider implements IProvider {
$params = $this->parseParamForAssignedUser($subjectParams, $params);
$params = $this->parseParamForAcl($subjectParams, $params);
$params = $this->parseParamForChanges($subjectParams, $params, $event);
$params = $this->parseParamForComment($subjectParams, $params, $event);
try {
$subject = $this->activityManager->getActivityFormat($subjectIdentifier, $subjectParams, $ownActivity);
@@ -147,6 +149,9 @@ class DeckProvider implements IProvider {
if (strpos($event->getSubject(), 'attachment_') !== false) {
$event->setIcon($this->urlGenerator->imagePath('core', 'places/files.svg'));
}
if (strpos($event->getSubject(), 'comment_') !== false) {
$event->setIcon($this->urlGenerator->imagePath('core', 'actions/comment.svg'));
}
return $event;
}
@@ -227,6 +232,16 @@ class DeckProvider implements IProvider {
return $params;
}
private function parseParamForComment($subjectParams, $params, IEvent $event) {
if (array_key_exists('comment', $subjectParams)) {
/** @var IComment $comment */
$comment = \OC::$server->getCommentsManager()->get((int) $subjectParams['comment']);
$event->setParsedMessage($comment->getMessage());
}
$params['comment'] = $subjectParams['comment'];
return $params;
}
/**
* Add diff to message if the subject parameter 'diff' is set, otherwise
* the changed values are added to before/after