Skip to content

Commit

Permalink
precise attributes and move logic
Browse files Browse the repository at this point in the history
Signed-off-by: dartcafe <[email protected]>
  • Loading branch information
dartcafe committed Aug 12, 2023
1 parent c189300 commit bd51f23
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
10 changes: 5 additions & 5 deletions lib/Event/BaseEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
use OCP\IUserSession;

abstract class BaseEvent extends Event {
protected ?string $activityObject = null;
protected ?string $activityObjectType = null;
protected ?string $eventId = null;
protected array $activitySubjectParams = [];
protected bool $log = true;
Expand Down Expand Up @@ -98,18 +98,18 @@ public function getNotification(): array {
return [];
}

public function getActivityObject(): ?string {
return $this->activityObject;
public function getActivityObjectType(): ?string {
return $this->activityObjectType;
}

public function getActivityObjectId(): int {
if ($this->activityObject === 'poll') {
if ($this->activityObjectType === 'poll') {
return $this->eventObject->getPollId();
}
return $this->eventObject->getId();
}

public function getActivitySubject(): ?string {
public function getActivityType(): ?string {
return $this->eventId;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Listener/BaseListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ protected function addActivity() : void {
if (!($this->event instanceof BaseEvent)) {
return;
}
if ($this->event->getActivitySubject() && $this->event->getActivityObject()) {
if ($this->event->getActivityType() && $this->event->getActivityObjectType()) {
$activityEvent = $this->activityService->createActivityEvent($this->event);
$this->activityService->publishActivityEvent($activityEvent, $this->event->getActor());
if ($this->event->getActor() !== $this->event->getPollOwner()) {
Expand Down
1 change: 0 additions & 1 deletion lib/Provider/ActivityProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
use OCP\L10N\IFactory;

class ActivityProvider implements IProvider {
// protected IL10N $l10n;

public function __construct(
protected ActivityManager $activityManager,
Expand Down
7 changes: 3 additions & 4 deletions lib/Service/ActivityService.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public function __construct(
public function createActivityEvent(BaseEvent $event): ActivityEvent {
$activityEvent = $this->activityManager->generateEvent();
$activityEvent->setApp('polls')
->setType($event->getActivitySubject())
->setType($event->getActivityType())
->setAuthor($event->getActor())
->setObject($event->getActivityObject(), $event->getActivityObjectId())
->setSubject($event->getActivitySubject(), $event->getActivitySubjectParams())
->setObject($event->getActivityObjectType(), $event->getActivityObjectId())
->setSubject($event->getActivityType(), $event->getActivitySubjectParams())
->setTimestamp(time());
return $activityEvent;
}
Expand Down Expand Up @@ -176,7 +176,6 @@ private function getMatchedMessages(): array {
self::FIRST_PERSON_FILTERED => $this->l10n->t('You have reordered the options'),
self::THIRD_PERSON_FILTERED => $this->l10n->t('{actor} has reordered the options'),
],

ShareEvent::CHANGE_EMAIL => [
self::FIRST_PERSON_FULL => $this->l10n->t('You have changed your email address'),
self::THIRD_PERSON_FULL => $this->l10n->t('{sharee} has changed the email address'),
Expand Down

0 comments on commit bd51f23

Please sign in to comment.