Skip to content

Commit 7ea99d5

Browse files
Debug log what happens during reminders processing
Signed-off-by: Christoph Wurst <[email protected]>
1 parent 74d8165 commit 7ea99d5

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

apps/dav/lib/CalDAV/Reminder/ReminderService.php

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
use OCP\IGroupManager;
3939
use OCP\IUser;
4040
use OCP\IUserManager;
41+
use Psr\Log\LoggerInterface;
4142
use Sabre\VObject;
4243
use Sabre\VObject\Component\VAlarm;
4344
use Sabre\VObject\Component\VEvent;
@@ -46,6 +47,7 @@
4647
use Sabre\VObject\Recur\EventIterator;
4748
use Sabre\VObject\Recur\MaxInstancesExceededException;
4849
use Sabre\VObject\Recur\NoInstancesException;
50+
use function count;
4951
use function strcasecmp;
5052

5153
class ReminderService {
@@ -71,6 +73,9 @@ class ReminderService {
7173
/** @var IConfig */
7274
private $config;
7375

76+
/** @var LoggerInterface */
77+
private $logger;
78+
7479
public const REMINDER_TYPE_EMAIL = 'EMAIL';
7580
public const REMINDER_TYPE_DISPLAY = 'DISPLAY';
7681
public const REMINDER_TYPE_AUDIO = 'AUDIO';
@@ -86,31 +91,22 @@ class ReminderService {
8691
self::REMINDER_TYPE_AUDIO
8792
];
8893

89-
/**
90-
* ReminderService constructor.
91-
*
92-
* @param Backend $backend
93-
* @param NotificationProviderManager $notificationProviderManager
94-
* @param IUserManager $userManager
95-
* @param IGroupManager $groupManager
96-
* @param CalDavBackend $caldavBackend
97-
* @param ITimeFactory $timeFactory
98-
* @param IConfig $config
99-
*/
10094
public function __construct(Backend $backend,
10195
NotificationProviderManager $notificationProviderManager,
10296
IUserManager $userManager,
10397
IGroupManager $groupManager,
10498
CalDavBackend $caldavBackend,
10599
ITimeFactory $timeFactory,
106-
IConfig $config) {
100+
IConfig $config,
101+
LoggerInterface $logger) {
107102
$this->backend = $backend;
108103
$this->notificationProviderManager = $notificationProviderManager;
109104
$this->userManager = $userManager;
110105
$this->groupManager = $groupManager;
111106
$this->caldavBackend = $caldavBackend;
112107
$this->timeFactory = $timeFactory;
113108
$this->config = $config;
109+
$this->logger = $logger;
114110
}
115111

116112
/**
@@ -119,8 +115,11 @@ public function __construct(Backend $backend,
119115
* @throws NotificationProvider\ProviderNotAvailableException
120116
* @throws NotificationTypeDoesNotExistException
121117
*/
122-
public function processReminders():void {
118+
public function processReminders() :void {
123119
$reminders = $this->backend->getRemindersToProcess();
120+
$this->logger->debug('{numReminders} reminders to process', [
121+
'numReminders' => count($reminders),
122+
]);
124123

125124
foreach ($reminders as $reminder) {
126125
$calendarData = is_resource($reminder['calendardata'])
@@ -133,22 +132,34 @@ public function processReminders():void {
133132

134133
$vcalendar = $this->parseCalendarData($calendarData);
135134
if (!$vcalendar) {
135+
$this->logger->debug('Reminder {id} does not belong to a valid calendar', [
136+
'id' => $reminder['id'],
137+
]);
136138
$this->backend->removeReminder($reminder['id']);
137139
continue;
138140
}
139141

140142
$vevent = $this->getVEventByRecurrenceId($vcalendar, $reminder['recurrence_id'], $reminder['is_recurrence_exception']);
141143
if (!$vevent) {
144+
$this->logger->debug('Reminder {id} does not belong to a valid event', [
145+
'id' => $reminder['id'],
146+
]);
142147
$this->backend->removeReminder($reminder['id']);
143148
continue;
144149
}
145150

146151
if ($this->wasEventCancelled($vevent)) {
152+
$this->logger->debug('Reminder {id} belongs to a cancelled event', [
153+
'id' => $reminder['id'],
154+
]);
147155
$this->deleteOrProcessNext($reminder, $vevent);
148156
continue;
149157
}
150158

151159
if (!$this->notificationProviderManager->hasProvider($reminder['type'])) {
160+
$this->logger->debug('Reminder {id} does not belong to a valid notification provider', [
161+
'id' => $reminder['id'],
162+
]);
152163
$this->deleteOrProcessNext($reminder, $vevent);
153164
continue;
154165
}
@@ -164,6 +175,10 @@ public function processReminders():void {
164175
$users[] = $user;
165176
}
166177

178+
$this->logger->debug('Reminder {id} will be sent to {numUsers} users', [
179+
'id' => $reminder['id'],
180+
'numUsers' => count($users),
181+
]);
167182
$notificationProvider = $this->notificationProviderManager->getProvider($reminder['type']);
168183
$notificationProvider->send($vevent, $reminder['displayname'], $users);
169184

0 commit comments

Comments
 (0)