Skip to content

Commit

Permalink
Fix Comments
Browse files Browse the repository at this point in the history
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
  • Loading branch information
rullzer committed Aug 1, 2017
1 parent 19b039e commit 201bbb9
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
11 changes: 5 additions & 6 deletions apps/comments/appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@
*
*/

use \OCA\Comments\AppInfo\Application;

$application = new Application();
$application->registerRoutes($this, ['routes' => [
['name' => 'Notifications#view', 'url' => '/notifications/view/{id}', 'verb' => 'GET'],
]]);
return [
'routes' => [
['name' => 'Notifications#view', 'url' => '/notifications/view/{id}', 'verb' => 'GET'],
]
];
4 changes: 2 additions & 2 deletions apps/comments/lib/Activity/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function commentEvent(CommentsEvent $event) {

// Get all mount point owners
$cache = $this->mountCollection->getMountCache();
$mounts = $cache->getMountsForFileId($event->getComment()->getObjectId());
$mounts = $cache->getMountsForFileId((int)$event->getComment()->getObjectId());
if (empty($mounts)) {
return;
}
Expand All @@ -93,7 +93,7 @@ public function commentEvent(CommentsEvent $event) {
foreach ($mounts as $mount) {
$owner = $mount->getUser()->getUID();
$ownerFolder = $this->rootFolder->getUserFolder($owner);
$nodes = $ownerFolder->getById($event->getComment()->getObjectId());
$nodes = $ownerFolder->getById((int)$event->getComment()->getObjectId());
if (!empty($nodes)) {
/** @var Node $node */
$node = array_shift($nodes);
Expand Down
6 changes: 3 additions & 3 deletions apps/comments/lib/Activity/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected function parseLongVersion(IEvent $event) {
trim($subjectParameters[1], '/'),
]))
->setRichSubject($this->l->t('You commented on {file}'), [
'file' => $this->generateFileParameter($event->getObjectId(), $subjectParameters[1]),
'file' => $this->generateFileParameter((int)$event->getObjectId(), $subjectParameters[1]),
]);
} else {
$author = $this->generateUserParameter($subjectParameters[0]);
Expand All @@ -157,7 +157,7 @@ protected function parseLongVersion(IEvent $event) {
]))
->setRichSubject($this->l->t('{author} commented on {file}'), [
'author' => $author,
'file' => $this->generateFileParameter($event->getObjectId(), $subjectParameters[1]),
'file' => $this->generateFileParameter((int)$event->getObjectId(), $subjectParameters[1]),
]);
}
} else {
Expand All @@ -173,7 +173,7 @@ protected function parseLongVersion(IEvent $event) {
protected function parseMessage(IEvent $event) {
$messageParameters = $event->getMessageParameters();
try {
$comment = $this->commentsManager->get((int) $messageParameters[0]);
$comment = $this->commentsManager->get((string) $messageParameters[0]);
$message = $comment->getMessage();
$message = str_replace("\n", '<br />', str_replace(['<', '>'], ['&lt;', '&gt;'], $message));

Expand Down
2 changes: 1 addition & 1 deletion apps/comments/lib/Controller/Notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function view($id) {
if($comment->getObjectType() !== 'files') {
return new NotFoundResponse();
}
$files = $this->folder->getById($comment->getObjectId());
$files = $this->folder->getById((int)$comment->getObjectId());
if(count($files) === 0) {
$this->markProcessed($comment);
return new NotFoundResponse();
Expand Down
2 changes: 1 addition & 1 deletion apps/comments/lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function prepare(INotification $notification, $languageCode) {
throw new \InvalidArgumentException('Unsupported comment object');
}
$userFolder = $this->rootFolder->getUserFolder($notification->getUser());
$nodes = $userFolder->getById($parameters[1]);
$nodes = $userFolder->getById((int)$parameters[1]);
if(empty($nodes)) {
throw new \InvalidArgumentException('Cannot resolve file id to Node instance');
}
Expand Down

0 comments on commit 201bbb9

Please sign in to comment.