Repository navigation
feat(remote-activities): less request, longer TTL - #3033
ArtificialOwl wants to merge 1 commit into
Conversation
575ef87 to
444e861
Compare
35c7189 to
d94a11c
Compare
72fe9db to
8cfd17a
Compare
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
8cfd17a to
2cc5767
Compare
| if (is_array($argument) && array_key_exists('instances', $argument)) { | ||
| foreach ($argument['instances'] as $instance => $entries) { | ||
| $this->sendActivities($instance, $entries); | ||
| } | ||
| } else { | ||
| call_user_func_array($this->sendActivity(...), $argument); | ||
| } |
There was a problem hiding this comment.
Instead of using a fragile check on is_array here could you please introduce a second, per remote instance BG job that runs bulk activities? Could use array{instance: string, entries: list<...>} as param so type checking is possible too.
Also means one slow instance doesn't hold up the rest.
|
|
||
| $items = []; | ||
| foreach ($entries as $entry) { | ||
| [$target, $token, $path, $internalType, $time, $actor, $secondPath] = array_merge(array_fill(0, 6, ''), $entry); |
There was a problem hiding this comment.
| [$target, $token, $path, $internalType, $time, $actor, $secondPath] = array_merge(array_fill(0, 6, ''), $entry); | |
| [$target, $token, $path, $internalType, $time, $actor, $secondPath] = $entry + array_fill(0, 7, ''); |
Please also add tests for this
| } catch (ClientException $e) { | ||
| $this->logger->warning('Failed to send remote activity', ['exception' => $e]); |
There was a problem hiding this comment.
these activities are lost when the remote doesn't have the new endpoint. Either introduce a capability to check before trying a bulk send, or resend them as single items when the remote doesn't have the bulk endpoint.
| $type = $this->translateType($internalType, $secondPath); | ||
|
|
||
| $item = [ | ||
| 'to' => [ | ||
| 'type' => 'Person', | ||
| 'name' => $cloudId->getUser(), | ||
| ], | ||
| 'actor' => [ | ||
| 'type' => 'Person', | ||
| 'name' => $actor, | ||
| ], | ||
| 'type' => $type, | ||
| 'share' => [ | ||
| 'type' => 'Document', | ||
| 'token' => $token, | ||
| ], | ||
| 'updated' => date(\DateTime::W3C, (int)$time), | ||
| ]; | ||
|
|
||
| if ($type === 'Move') { | ||
| $item['target'] = [ | ||
| 'type' => 'Document', | ||
| 'name' => $path, | ||
| ]; | ||
| $item['origin'] = [ | ||
| 'type' => 'Document', | ||
| 'name' => $secondPath, | ||
| ]; | ||
| } else { | ||
| $item['object'] = [ | ||
| 'type' => 'Document', | ||
| 'name' => $path, | ||
| ]; | ||
| } | ||
|
|
||
| $items[] = $item; | ||
| } |
There was a problem hiding this comment.
seems like this is duplicating what the singular method is already doing. extract and create a separate function that handles both.
Collectionso that only one request need to be sent to the remote instance.How to set a 30 minutes TTL: