Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor contactsinteraction app #39243

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
21 changes: 9 additions & 12 deletions apps/contactsinteraction/lib/AddressBook.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,25 @@ class AddressBook extends ExternalAddressBook implements IACL {

public const URI = 'recent';

private RecentContactMapper $mapper;
private IL10N $l10n;
private string $principalUri;

public function __construct(RecentContactMapper $mapper,
IL10N $l10n,
string $principalUri) {
public function __construct(
private RecentContactMapper $mapper,
private IL10N $l10n,
private string $principalUri,
) {
parent::__construct(Application::APP_ID, self::URI);

$this->mapper = $mapper;
$this->l10n = $l10n;
$this->principalUri = $principalUri;
}

/**
* @inheritDoc
* @throws Exception
*/
public function delete(): void {
throw new Exception("This addressbook is immutable");
}

/**
* @inheritDoc
* @throws Exception
*/
public function createFile($name, $data = null) {
throw new Exception("This addressbook is immutable");
Expand Down Expand Up @@ -131,6 +127,7 @@ public function getLastModified(): ?int {

/**
* @inheritDoc
* @throws Exception
*/
public function propPatch(PropPatch $propPatch) {
throw new Exception("This addressbook is immutable");
Expand All @@ -139,7 +136,7 @@ public function propPatch(PropPatch $propPatch) {
/**
* @inheritDoc
*/
public function getProperties($properties) {
public function getProperties($properties): array {
return [
'principaluri' => $this->principalUri,
'{DAV:}displayname' => $this->l10n->t('Recently contacted'),
Expand Down
13 changes: 4 additions & 9 deletions apps/contactsinteraction/lib/AddressBookProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,10 @@

class AddressBookProvider implements IAddressBookProvider {

/** @var RecentContactMapper */
private $mapper;

/** @var IL10N */
private $l10n;

public function __construct(RecentContactMapper $mapper, IL10N $l10n) {
$this->mapper = $mapper;
$this->l10n = $l10n;
public function __construct(
private RecentContactMapper $mapper,
private IL10N $l10n,
) {
}

/**
Expand Down
10 changes: 5 additions & 5 deletions apps/contactsinteraction/lib/BackgroundJob/CleanupJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@
use OCP\BackgroundJob\TimedJob;

class CleanupJob extends TimedJob {
private RecentContactMapper $mapper;

public function __construct(ITimeFactory $time,
RecentContactMapper $mapper) {
public function __construct(
ITimeFactory $time,
private RecentContactMapper $mapper,
) {
parent::__construct($time);

$this->setInterval(24 * 60 * 60);
$this->setTimeSensitivity(IJob::TIME_INSENSITIVE);

$this->mapper = $mapper;
}

protected function run($argument) {
protected function run(mixed $argument): void {
$time = $this->time->getDateTime();
$time->modify('-7days');
$this->mapper->cleanUp($time->getTimestamp());
Expand Down
15 changes: 6 additions & 9 deletions apps/contactsinteraction/lib/Card.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,11 @@
class Card implements ICard, IACL {
use ACLTrait;

private RecentContact $contact;
private string $principal;
private array $acls;

public function __construct(RecentContact $contact, string $principal, array $acls) {
$this->contact = $contact;
$this->principal = $principal;
$this->acls = $acls;
public function __construct(
private RecentContact $contact,
private string $principal,
private array $acls,
) {
}

/**
Expand Down Expand Up @@ -77,7 +74,7 @@ public function put($data): ?string {
/**
* @inheritDoc
*/
public function get() {
public function get(): string {
return $this->contact->getCard();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,15 @@ class ContactInteractionListener implements IEventListener {

use TTransactional;

private RecentContactMapper $mapper;
private CardSearchDao $cardSearchDao;
private IUserManager $userManager;
private IDBConnection $dbConnection;
private ITimeFactory $timeFactory;
private IL10N $l10n;
private LoggerInterface $logger;

public function __construct(RecentContactMapper $mapper,
CardSearchDao $cardSearchDao,
IUserManager $userManager,
IDBConnection $connection,
ITimeFactory $timeFactory,
IL10N $l10nFactory,
LoggerInterface $logger) {
$this->mapper = $mapper;
$this->cardSearchDao = $cardSearchDao;
$this->userManager = $userManager;
$this->dbConnection = $connection;
$this->timeFactory = $timeFactory;
$this->l10n = $l10nFactory;
$this->logger = $logger;
public function __construct(
private RecentContactMapper $mapper,
private CardSearchDao $cardSearchDao,
private IUserManager $userManager,
private IDBConnection $dbConnection,
private ITimeFactory $timeFactory,
private IL10N $l10n,
private LoggerInterface $logger,
) {
}

public function handle(Event $event): void {
Expand Down
Loading