Skip to content

Commit

Permalink
Merge pull request #38605 from fsamapoor/replace_strpos_calls_in_comm…
Browse files Browse the repository at this point in the history
…ents_app

Refactors "strpos" calls in /apps/comments
  • Loading branch information
come-nc authored Jun 29, 2023
2 parents f43c24b + 7e33e59 commit fc3ac4d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion apps/comments/lib/Activity/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ protected function parseMessage(IEvent $event): void {
}

$message = str_replace('@"' . $mention['id'] . '"', '{mention' . $mentionCount . '}', $message);
if (strpos($mention['id'], ' ') === false && strpos($mention['id'], 'guest/') !== 0) {
if (!str_contains($mention['id'], ' ') && !str_starts_with($mention['id'], 'guest/')) {
$message = str_replace('@' . $mention['id'], '{mention' . $mentionCount . '}', $message);
}

Expand Down
4 changes: 2 additions & 2 deletions apps/comments/lib/Notification/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function prepare(INotification $notification, string $languageCode): INot
$node = $nodes[0];

$path = rtrim($node->getPath(), '/');
if (strpos($path, '/' . $notification->getUser() . '/files/') === 0) {
if (str_starts_with($path, '/' . $notification->getUser() . '/files/')) {
// Remove /user/files/...
$fullPath = $path;
[,,, $path] = explode('/', $fullPath, 4);
Expand Down Expand Up @@ -182,7 +182,7 @@ public function commentToRichMessage(IComment $comment): array {
// index of the mentions of that type.
$mentionParameterId = 'mention-' . $mention['type'] . $mentionTypeCount[$mention['type']];
$message = str_replace('@"' . $mention['id'] . '"', '{' . $mentionParameterId . '}', $message);
if (strpos($mention['id'], ' ') === false && strpos($mention['id'], 'guest/') !== 0) {
if (!str_contains($mention['id'], ' ') && !str_starts_with($mention['id'], 'guest/')) {
$message = str_replace('@' . $mention['id'], '{' . $mentionParameterId . '}', $message);
}

Expand Down

0 comments on commit fc3ac4d

Please sign in to comment.