Skip to content

Commit b3b9bac

Browse files
committed
feat(federation): delete table on receiving instance if the federated share is deleted
Signed-off-by: Benjamin Frueh <benjamin.frueh@gmail.com>
1 parent d07649e commit b3b9bac

2 files changed

Lines changed: 30 additions & 16 deletions

File tree

lib/Service/FederationService.php

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -109,22 +109,6 @@ public function deleteRow(Table $table, int $rowId): array {
109109
}
110110
}
111111

112-
public function notifyTableDeleted(Table $table): void {
113-
try {
114-
$shares = $this->shareMapper->findRemoteSharesForNode($table->getId(), 'table');
115-
} catch (\Exception $e) {
116-
$this->logger->warning('Could not fetch remote shares for table deletion notification', ['exception' => $e]);
117-
return;
118-
}
119-
foreach ($shares as $share) {
120-
$this->proxy->sendNotification(
121-
FederationProvider::NOTIFICATION_DELETE_TABLE,
122-
(string)$table->getId(),
123-
$share,
124-
);
125-
}
126-
}
127-
128112
public function sendShare(Share $share): void {
129113
$cloudId = $this->cloudIdManager->resolveCloudId($share->getReceiver());
130114
$ownerCloudId = $this->cloudIdManager->getCloudId($share->getSender(), null);
@@ -151,6 +135,22 @@ public function sendShare(Share $share): void {
151135
}
152136
}
153137

138+
public function notifyTableDeleted(Table $table): void {
139+
try {
140+
$shares = $this->shareMapper->findRemoteSharesForNode($table->getId(), 'table');
141+
} catch (\Exception $e) {
142+
$this->logger->warning('Could not fetch remote shares for table deletion notification', ['exception' => $e]);
143+
return;
144+
}
145+
foreach ($shares as $share) {
146+
$this->proxy->sendNotification(
147+
FederationProvider::NOTIFICATION_DELETE_TABLE,
148+
(string)$table->getId(),
149+
$share,
150+
);
151+
}
152+
}
153+
154154
public function notifyPermissionUpdate(Share $share): void {
155155
$this->proxy->sendNotification(
156156
FederationProvider::NOTIFICATION_UPDATE_PERMISSIONS,
@@ -184,4 +184,12 @@ public function notifyTableUpdate(Table $table): void {
184184
);
185185
}
186186
}
187+
188+
public function notifyShareDelete(Share $share): void {
189+
$this->proxy->sendNotification(
190+
FederationProvider::NOTIFICATION_DELETE_TABLE,
191+
(string)$share->getNodeId(),
192+
$share,
193+
);
194+
}
187195
}

lib/Service/ShareService.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,12 @@ public function delete(int $id): Share {
666666

667667
try {
668668
$this->mapper->delete($item);
669+
670+
// notify federated shares about share deletion
671+
if ($item->getReceiverType() === ShareReceiverType::REMOTE) {
672+
$this->federationService->notifyShareDelete($item);
673+
}
674+
669675
if ($item->getNodeType() === 'context') {
670676
$this->contextNavigationMapper->deleteByShareId($item->getId());
671677
}

0 commit comments

Comments
 (0)