Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix(activity): regroup into sharing activity
Signed-off-by: skjnldsv <[email protected]>
  • Loading branch information
skjnldsv committed Aug 1, 2024
commit 7a8ff5ec35a67c95cc87fa0efe46322267206eab
46 changes: 11 additions & 35 deletions lib/Activity/Listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,19 @@
use OCP\Files\InvalidPathException;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCP\ILogger;
use OCP\IRequest;
use OCP\IURLGenerator;
use Psr\Log\LoggerInterface;

class Listener {
/** @var IRequest */
protected $request;
/** @var IManager */
protected $activityManager;
/** @var IURLGenerator */
protected $urlGenerator;
/** @var IRootFolder */
protected $rootFolder;
/** @var CurrentUser */
protected $currentUser;
/** @var ILogger */
protected $logger;

/**
* @param IRequest $request
* @param IManager $activityManager
* @param IURLGenerator $urlGenerator
* @param IRootFolder $rootFolder
* @param CurrentUser $currentUser
* @param ILogger $logger
*/
public function __construct(IRequest $request, IManager $activityManager, IURLGenerator $urlGenerator, IRootFolder $rootFolder, CurrentUser $currentUser, ILogger $logger) {
$this->request = $request;
$this->activityManager = $activityManager;
$this->urlGenerator = $urlGenerator;
$this->rootFolder = $rootFolder;
$this->currentUser = $currentUser;
$this->logger = $logger;
public function __construct(
protected IRequest $request,
protected IManager $activityManager,
protected IURLGenerator $urlGenerator,
protected IRootFolder $rootFolder,
protected CurrentUser $currentUser,
protected LoggerInterface $logger
) {
}

/**
Expand Down Expand Up @@ -128,13 +108,9 @@ public function readFile(string $path): void {
->setLink($this->urlGenerator->linkToRouteAbsolute('files.view.index', $linkData));
$this->activityManager->publish($event);
} catch (\InvalidArgumentException $e) {
$this->logger->logException($e, [
'app' => 'files_downloadactivity',
]);
$this->logger->error($e->getMessage(), $e->getTrace());
} catch (\BadMethodCallException $e) {
$this->logger->logException($e, [
'app' => 'files_downloadactivity',
]);
$this->logger->error($e->getMessage(), $e->getTrace());
}
}

Expand Down
30 changes: 19 additions & 11 deletions lib/Activity/Setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,11 @@

namespace OCA\FilesDownloadActivity\Activity;

use OCP\Activity\ISetting;
use OCP\Activity\ActivitySettings;
use OCP\IL10N;

class Setting implements ISetting {

/** @var IL10N */
protected $l;

/**
* @param IL10N $l
*/
public function __construct(IL10N $l) {
$this->l = $l;
class Setting extends ActivitySettings {
public function __construct(protected IL10N $l) {
}

/**
Expand All @@ -54,6 +46,22 @@ public function getName(): string {
return $this->l->t('A local shared file or folder was <strong>downloaded</strong>');
}

/**
* @return string Lowercase a-z and underscore only group identifier
* @since 20.0.0
*/
public function getGroupIdentifier() {
return 'sharing';
}

/**
* @return string A translated string for the settings group
* @since 20.0.0
*/
public function getGroupName() {
return $this->l->t('Sharing');
}

/**
* @return int whether the filter should be rather on the top or bottom of
* the admin section. The filters are arranged in ascending order of the
Expand Down
17 changes: 8 additions & 9 deletions tests/psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.30.0@d0bc6e25d89f649e4f36a534f330f8bb4643dd69">
<files psalm-version="5.25.0@01a8eb06b9e9cc6cfb6a320bf9fb14331919d505">
<file src="lib/Activity/Listener.php">
<MissingDependency occurrences="3">
<code>$this-&gt;rootFolder</code>
<code>IRootFolder</code>
<code>IRootFolder</code>
<MissingDependency>
<code><![CDATA[$this->rootFolder]]></code>
<code><![CDATA[protected]]></code>
</MissingDependency>
<UndefinedClass occurrences="1">
<code>Filesystem</code>
<UndefinedClass>
<code><![CDATA[Filesystem]]></code>
</UndefinedClass>
</file>
<file src="lib/CurrentUser.php">
<NoInterfaceProperties occurrences="1">
<code>$this-&gt;request-&gt;server</code>
<NoInterfaceProperties>
<code><![CDATA[$this->request->server]]></code>
</NoInterfaceProperties>
</file>
</files>