Skip to content

Commit

Permalink
Fix missing information in activity emails
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Dec 4, 2018
1 parent 8499318 commit e5fe19c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
3 changes: 3 additions & 0 deletions lib/Activity/ActivityManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ private function createEvent($objectType, $entity, $subject, $additionalParams =
$subjectParams['stackBefore'] = $this->stackMapper->find($additionalParams['before']);
}

$subjectParams['author'] = $this->userId;


$event = $this->manager->generateEvent();
$event->setApp('deck')
->setType('deck')
Expand Down
14 changes: 13 additions & 1 deletion lib/Activity/DeckProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ public function parse($language, IEvent $event, IEvent $previousEvent = null) {
*/

$author = $event->getAuthor();
// get author if
if ($author === '' && array_key_exists('author', $subjectParams)) {
$author = $subjectParams['author'];
unset($subjectParams['author']);
}
$user = $this->userManager->get($author);
$params = [
'user' => [
Expand All @@ -90,6 +95,9 @@ public function parse($language, IEvent $event, IEvent $previousEvent = null) {
],
];
if ($event->getObjectType() === ActivityManager::DECK_OBJECT_BOARD) {
if ($event->getObjectName() === '') {
$event->setObject($event->getObjectType(), $event->getObjectId(), $subjectParams['board']['title']);
}
$board = [
'type' => 'highlight',
'id' => $event->getObjectId(),
Expand All @@ -100,6 +108,9 @@ public function parse($language, IEvent $event, IEvent $previousEvent = null) {
}

if ($event->getObjectType() === ActivityManager::DECK_OBJECT_CARD) {
if ($event->getObjectName() === '') {
$event->setObject($event->getObjectType(), $event->getObjectId(), $subjectParams['card']['title']);
}
$card = [
'type' => 'highlight',
'id' => $event->getObjectId(),
Expand Down Expand Up @@ -149,6 +160,7 @@ protected function setSubjects(IEvent $event, $subject, array $parameters) {

$event->setParsedSubject(str_replace($placeholders, $replacements, $subject))
->setRichSubject($subject, $parameters);
$event->setSubject($subject, $parameters);
}

private function getIcon(IEvent $event) {
Expand Down Expand Up @@ -301,6 +313,6 @@ private function parseParamForChanges($subjectParams, $params, $event) {
}

public function deckUrl($endpoint) {
return $this->urlGenerator->linkToRoute('deck.page.index') . '#!' . $endpoint;
return $this->urlGenerator->linkToRouteAbsolute('deck.page.index') . '#!' . $endpoint;
}
}
13 changes: 11 additions & 2 deletions tests/unit/Activity/CommentEventHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,33 @@ class CommentEventHandlerTest extends TestCase {
private $activityManager;
/** @var NotificationHelper */
private $notificationHelper;
/** @var CardMapper */
private $cardMapper;

public function setUp() {
$this->activityManager = $this->createMock(ActivityManager::class);
$this->notificationHelper = $this->createMock(NotificationHelper::class);
$this->cardMapper = $this->createMock(CardMapper::class);
$this->commentEventHandler = new CommentEventHandler(
$this->activityManager,
$this->notificationHelper
$this->notificationHelper,
$this->cardMapper
);
}

public function testHandle() {
$comment = $this->createMock(IComment::class);
$comment->expects($this->any())->method('getId')->willReturn(1);
$comment->expects($this->any())->method('getObjectType')->willReturn('deckCard');
$comment->expects($this->any())->method('getMessage')->willReturn('Hello world');
$card = $this->createMock(Card::class);
$this->cardMapper->expects($this->once())
->method('find')
->willReturn($card);
$commentsEvent = new CommentsEvent(CommentsEvent::EVENT_ADD, $comment);
$this->activityManager->expects($this->once())
->method('triggerEvent')
->with(ActivityManager::DECK_OBJECT_CARD, $comment, ActivityManager::SUBJECT_CARD_COMMENT_CREATE, ['comment' => 1]);
->with(ActivityManager::DECK_OBJECT_CARD, $card, ActivityManager::SUBJECT_CARD_COMMENT_CREATE, ['comment' => $comment]);
$this->notificationHelper->expects($this->once())
->method('sendMention')
->with($comment);
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Activity/DeckProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function testEventIcons($subject, $app, $icon) {

public function testDeckUrl() {
$this->urlGenerator->expects($this->once())
->method('linkToRoute')
->method('linkToRouteAbsolute')
->with('deck.page.index')
->willReturn('http://localhost/index.php/apps/deck/');
$this->assertEquals(
Expand Down

0 comments on commit e5fe19c

Please sign in to comment.