Skip to content

Commit 4c4e6b4

Browse files
provokateurinbackportbot[bot]
authored andcommitted
fix(files_sharing): Use UnknownActivityException
Signed-off-by: provokateurin <kate@provokateurin.de>
1 parent 5b445c5 commit 4c4e6b4

6 files changed

Lines changed: 41 additions & 34 deletions

File tree

apps/files_sharing/lib/Activity/Providers/Base.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
5555
if ($this->activityManager->isFormattingFilteredObject()) {
5656
try {
5757
return $this->parseShortVersion($event);
58-
} catch (\InvalidArgumentException $e) {
58+
} catch (UnknownActivityException $e) {
5959
// Ignore and simply use the long version...
6060
}
6161
}
@@ -66,7 +66,7 @@ public function parse($language, IEvent $event, ?IEvent $previousEvent = null) {
6666
/**
6767
* @param IEvent $event
6868
* @return IEvent
69-
* @throws \InvalidArgumentException
69+
* @throws UnknownActivityException
7070
* @since 11.0.0
7171
*/
7272
abstract protected function parseShortVersion(IEvent $event);
@@ -75,14 +75,11 @@ abstract protected function parseShortVersion(IEvent $event);
7575
* @param IEvent $event
7676
* @param IEvent|null $previousEvent
7777
* @return IEvent
78-
* @throws \InvalidArgumentException
78+
* @throws UnknownActivityException
7979
* @since 11.0.0
8080
*/
8181
abstract protected function parseLongVersion(IEvent $event, ?IEvent $previousEvent = null);
8282

83-
/**
84-
* @throws \InvalidArgumentException
85-
*/
8683
protected function setSubjects(IEvent $event, string $subject, array $parameters): void {
8784
$event->setRichSubject($subject, $parameters);
8885
}
@@ -91,7 +88,7 @@ protected function setSubjects(IEvent $event, string $subject, array $parameters
9188
* @param array|string $parameter
9289
* @param IEvent|null $event
9390
* @return array
94-
* @throws \InvalidArgumentException
91+
* @throws UnknownActivityException
9592
*/
9693
protected function getFile($parameter, ?IEvent $event = null) {
9794
if (is_array($parameter)) {
@@ -101,7 +98,7 @@ protected function getFile($parameter, ?IEvent $event = null) {
10198
$path = $parameter;
10299
$id = (string)$event->getObjectId();
103100
} else {
104-
throw new \InvalidArgumentException('Could not generate file parameter');
101+
throw new UnknownActivityException('Could not generate file parameter');
105102
}
106103

107104
return [

apps/files_sharing/lib/Activity/Providers/Downloads.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
namespace OCA\Files_Sharing\Activity\Providers;
88

9+
use OCP\Activity\Exceptions\UnknownActivityException;
910
use OCP\Activity\IEvent;
1011

1112
class Downloads extends Base {
@@ -18,7 +19,7 @@ class Downloads extends Base {
1819
/**
1920
* @param IEvent $event
2021
* @return IEvent
21-
* @throws \InvalidArgumentException
22+
* @throws UnknownActivityException
2223
* @since 11.0.0
2324
*/
2425
#[\Override]
@@ -32,7 +33,7 @@ public function parseShortVersion(IEvent $event) {
3233
|| $event->getSubject() === self::SUBJECT_SHARED_FOLDER_BY_EMAIL_DOWNLOADED) {
3334
$subject = $this->l->t('Downloaded by {email}');
3435
} else {
35-
throw new \InvalidArgumentException();
36+
throw new UnknownActivityException();
3637
}
3738

3839
if ($this->activityManager->getRequirePNG()) {
@@ -49,7 +50,7 @@ public function parseShortVersion(IEvent $event) {
4950
* @param IEvent $event
5051
* @param IEvent|null $previousEvent
5152
* @return IEvent
52-
* @throws \InvalidArgumentException
53+
* @throws UnknownActivityException
5354
* @since 11.0.0
5455
*/
5556
#[\Override]
@@ -71,7 +72,7 @@ public function parseLongVersion(IEvent $event, ?IEvent $previousEvent = null) {
7172
$subject = $this->l->t('{email} downloaded {file}');
7273
$this->setSubjects($event, $subject, $parsedParameters);
7374
} else {
74-
throw new \InvalidArgumentException();
75+
throw new UnknownActivityException();
7576
}
7677

7778
if ($this->activityManager->getRequirePNG()) {
@@ -86,7 +87,7 @@ public function parseLongVersion(IEvent $event, ?IEvent $previousEvent = null) {
8687
/**
8788
* @param IEvent $event
8889
* @return array
89-
* @throws \InvalidArgumentException
90+
* @throws UnknownActivityException
9091
*/
9192
protected function getParsedParameters(IEvent $event) {
9293
$subject = $event->getSubject();
@@ -121,6 +122,6 @@ protected function getParsedParameters(IEvent $event) {
121122
];
122123
}
123124

124-
throw new \InvalidArgumentException();
125+
throw new UnknownActivityException();
125126
}
126127
}

apps/files_sharing/lib/Activity/Providers/Groups.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
namespace OCA\Files_Sharing\Activity\Providers;
88

9+
use OCP\Activity\Exceptions\UnknownActivityException;
910
use OCP\Activity\IEvent;
1011
use OCP\Activity\IEventMerger;
1112
use OCP\Activity\IManager;
@@ -45,7 +46,7 @@ public function __construct(
4546
/**
4647
* @param IEvent $event
4748
* @return IEvent
48-
* @throws \InvalidArgumentException
49+
* @throws UnknownActivityException
4950
* @since 11.0.0
5051
*/
5152
#[\Override]
@@ -63,7 +64,7 @@ public function parseShortVersion(IEvent $event) {
6364
} elseif ($event->getSubject() === self::SUBJECT_EXPIRED_GROUP) {
6465
$subject = $this->l->t('Share for group {group} expired');
6566
} else {
66-
throw new \InvalidArgumentException();
67+
throw new UnknownActivityException();
6768
}
6869

6970
if ($this->activityManager->getRequirePNG()) {
@@ -80,7 +81,7 @@ public function parseShortVersion(IEvent $event) {
8081
* @param IEvent $event
8182
* @param IEvent|null $previousEvent
8283
* @return IEvent
83-
* @throws \InvalidArgumentException
84+
* @throws UnknownActivityException
8485
* @since 11.0.0
8586
*/
8687
#[\Override]
@@ -98,7 +99,7 @@ public function parseLongVersion(IEvent $event, ?IEvent $previousEvent = null) {
9899
} elseif ($event->getSubject() === self::SUBJECT_EXPIRED_GROUP) {
99100
$subject = $this->l->t('Share for file {file} with group {group} expired');
100101
} else {
101-
throw new \InvalidArgumentException();
102+
throw new UnknownActivityException();
102103
}
103104

104105
if ($this->activityManager->getRequirePNG()) {
@@ -131,7 +132,8 @@ protected function getParsedParameters(IEvent $event) {
131132
'group' => $this->generateGroupParameter($parameters[1]),
132133
];
133134
}
134-
return [];
135+
136+
throw new UnknownActivityException();
135137
}
136138

137139
/**

apps/files_sharing/lib/Activity/Providers/PublicLinks.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
55
* SPDX-License-Identifier: AGPL-3.0-or-later
66
*/
7+
78
namespace OCA\Files_Sharing\Activity\Providers;
89

10+
use OCP\Activity\Exceptions\UnknownActivityException;
911
use OCP\Activity\IEvent;
1012

1113
class PublicLinks extends Base {
@@ -19,7 +21,7 @@ class PublicLinks extends Base {
1921
/**
2022
* @param IEvent $event
2123
* @return IEvent
22-
* @throws \InvalidArgumentException
24+
* @throws UnknownActivityException
2325
* @since 11.0.0
2426
*/
2527
#[\Override]
@@ -39,7 +41,7 @@ public function parseShortVersion(IEvent $event) {
3941
} elseif ($event->getSubject() === self::SUBJECT_LINK_BY_EXPIRED) {
4042
$subject = $this->l->t('Public link of {actor} expired');
4143
} else {
42-
throw new \InvalidArgumentException();
44+
throw new UnknownActivityException();
4345
}
4446

4547
if ($this->activityManager->getRequirePNG()) {
@@ -56,7 +58,7 @@ public function parseShortVersion(IEvent $event) {
5658
* @param IEvent $event
5759
* @param IEvent|null $previousEvent
5860
* @return IEvent
59-
* @throws \InvalidArgumentException
61+
* @throws UnknownActivityException
6062
* @since 11.0.0
6163
*/
6264
#[\Override]
@@ -76,7 +78,7 @@ public function parseLongVersion(IEvent $event, ?IEvent $previousEvent = null) {
7678
} elseif ($event->getSubject() === self::SUBJECT_LINK_BY_EXPIRED) {
7779
$subject = $this->l->t('Public link of {actor} for {file} expired');
7880
} else {
79-
throw new \InvalidArgumentException();
81+
throw new UnknownActivityException();
8082
}
8183

8284
if ($this->activityManager->getRequirePNG()) {
@@ -108,6 +110,7 @@ protected function getParsedParameters(IEvent $event) {
108110
'actor' => $this->getUser($parameters[1]),
109111
];
110112
}
111-
return [];
113+
114+
throw new UnknownActivityException();
112115
}
113116
}

apps/files_sharing/lib/Activity/Providers/RemoteShares.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
namespace OCA\Files_Sharing\Activity\Providers;
88

9+
use OCP\Activity\Exceptions\UnknownActivityException;
910
use OCP\Activity\IEvent;
1011
use OCP\Activity\IEventMerger;
1112
use OCP\Activity\IManager;
@@ -34,7 +35,7 @@ public function __construct(IFactory $languageFactory,
3435
/**
3536
* @param IEvent $event
3637
* @return IEvent
37-
* @throws \InvalidArgumentException
38+
* @throws UnknownActivityException
3839
* @since 11.0.0
3940
*/
4041
#[\Override]
@@ -46,7 +47,7 @@ public function parseShortVersion(IEvent $event) {
4647
} elseif ($event->getSubject() === self::SUBJECT_REMOTE_SHARE_DECLINED) {
4748
$subject = $this->l->t('{user} declined the remote share');
4849
} else {
49-
throw new \InvalidArgumentException();
50+
throw new UnknownActivityException();
5051
}
5152

5253
if ($this->activityManager->getRequirePNG()) {
@@ -63,7 +64,7 @@ public function parseShortVersion(IEvent $event) {
6364
* @param IEvent $event
6465
* @param IEvent|null $previousEvent
6566
* @return IEvent
66-
* @throws \InvalidArgumentException
67+
* @throws UnknownActivityException
6768
* @since 11.0.0
6869
*/
6970
#[\Override]
@@ -79,7 +80,7 @@ public function parseLongVersion(IEvent $event, ?IEvent $previousEvent = null) {
7980
} elseif ($event->getSubject() === self::SUBJECT_REMOTE_SHARE_UNSHARED) {
8081
$subject = $this->l->t('{user} unshared {file} from you');
8182
} else {
82-
throw new \InvalidArgumentException();
83+
throw new UnknownActivityException();
8384
}
8485

8586
if ($this->activityManager->getRequirePNG()) {
@@ -119,6 +120,6 @@ protected function getParsedParameters(IEvent $event) {
119120
'user' => $this->getUser($parameters[0]),
120121
];
121122
}
122-
throw new \InvalidArgumentException();
123+
throw new UnknownActivityException();
123124
}
124125
}

apps/files_sharing/lib/Activity/Providers/Users.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
55
* SPDX-License-Identifier: AGPL-3.0-or-later
66
*/
7+
78
namespace OCA\Files_Sharing\Activity\Providers;
89

10+
use OCP\Activity\Exceptions\UnknownActivityException;
911
use OCP\Activity\IEvent;
1012

1113
class Users extends Base {
@@ -25,7 +27,7 @@ class Users extends Base {
2527
/**
2628
* @param IEvent $event
2729
* @return IEvent
28-
* @throws \InvalidArgumentException
30+
* @throws UnknownActivityException
2931
* @since 11.0.0
3032
*/
3133
#[\Override]
@@ -53,7 +55,7 @@ public function parseShortVersion(IEvent $event) {
5355
} elseif ($event->getSubject() === self::SUBJECT_EXPIRED) {
5456
$subject = $this->l->t('Share expired');
5557
} else {
56-
throw new \InvalidArgumentException();
58+
throw new UnknownActivityException();
5759
}
5860

5961
if ($this->activityManager->getRequirePNG()) {
@@ -70,7 +72,7 @@ public function parseShortVersion(IEvent $event) {
7072
* @param IEvent $event
7173
* @param IEvent|null $previousEvent
7274
* @return IEvent
73-
* @throws \InvalidArgumentException
75+
* @throws UnknownActivityException
7476
* @since 11.0.0
7577
*/
7678
#[\Override]
@@ -98,7 +100,7 @@ public function parseLongVersion(IEvent $event, ?IEvent $previousEvent = null) {
98100
} elseif ($event->getSubject() === self::SUBJECT_EXPIRED) {
99101
$subject = $this->l->t('Share for file {file} expired');
100102
} else {
101-
throw new \InvalidArgumentException();
103+
throw new UnknownActivityException();
102104
}
103105

104106
if ($this->activityManager->getRequirePNG()) {
@@ -140,6 +142,7 @@ protected function getParsedParameters(IEvent $event) {
140142
'actor' => $this->getUser($parameters[1]),
141143
];
142144
}
143-
return [];
145+
146+
throw new UnknownActivityException();
144147
}
145148
}

0 commit comments

Comments
 (0)