Skip to content

Commit

Permalink
Merge pull request #13117 from nextcloud/bugfix/noid/update-code-style
Browse files Browse the repository at this point in the history
chore: Update coding-standard
  • Loading branch information
nickvergessen authored Aug 23, 2024
2 parents 498b56f + 10dc3c7 commit 4f2319e
Show file tree
Hide file tree
Showing 106 changed files with 508 additions and 498 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# .git-blame-ignore-revs
# Update to nextcloud/coding-standard 1.2.3
956a1ab00ffb25d87c0f5192333c9b66e56a63fe
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ You can enable HMR (Hot module replacement) to avoid page reloads when working o

We are also available on [our public Talk team conversation](https://cloud.nextcloud.com/call/c7fz9qpr), if you want to join the discussion.

### 🙈 Ignore code style updates in git blame

```sh
git config blame.ignoreRevsFile .git-blame-ignore-revs
```

### 🌏 Testing federation locally

When testing federated conversations locally, some additional steps might be needed,
Expand Down
4 changes: 2 additions & 2 deletions lib/Activity/Provider/Call.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public function parse($language, IEvent $event, ?IEvent $previousEvent = null):
$parameters = $event->getSubjectParameters();

try {
$room = $this->manager->getRoomForUser((int) $parameters['room'], $this->activityManager->getCurrentUserId());
$room = $this->manager->getRoomForUser((int)$parameters['room'], $this->activityManager->getCurrentUserId());
} catch (RoomNotFoundException) {
$room = null;
}

$result = $this->parseCall($room, $event, $l);
$result['subject'] .= ' ' . $this->getDuration($l, (int) $parameters['duration']);
$result['subject'] .= ' ' . $this->getDuration($l, (int)$parameters['duration']);
// $result['params']['call'] = $roomParameter;
$this->setSubjects($event, $result['subject'], $result['params']);
} else {
Expand Down
4 changes: 2 additions & 2 deletions lib/Activity/Provider/Invitation.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public function parse($language, IEvent $event, ?IEvent $previousEvent = null):
$l = $this->languageFactory->get('spreed', $language);
$parameters = $event->getSubjectParameters();

$roomParameter = $this->getFormerRoom($l, (int) $parameters['room']);
$roomParameter = $this->getFormerRoom($l, (int)$parameters['room']);
try {
$room = $this->manager->getRoomById((int) $parameters['room']);
$room = $this->manager->getRoomById((int)$parameters['room']);
$roomParameter = $this->getRoom($room, $event->getAffectedUser());
} catch (RoomNotFoundException $e) {
}
Expand Down
4 changes: 2 additions & 2 deletions lib/BackgroundJob/CheckCertificates.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@ protected function run($argument): void {
$signalingServers = $this->talkConfig->getSignalingServers();

foreach ($signalingServers as $signalingServer) {
if ((bool) $signalingServer['verify']) {
if ((bool)$signalingServer['verify']) {
$this->checkServerCertificate($signalingServer['server']);
}
}

$recordingServers = $this->talkConfig->getRecordingServers();

foreach ($recordingServers as $recordingServer) {
if ((bool) $recordingServer['verify']) {
if ((bool)$recordingServer['verify']) {
$this->checkServerCertificate($recordingServer['server']);
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/BackgroundJob/RemoveEmptyRooms.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private function deleteIfFileIsRemoved(Room $room): bool {
return false;
}

$mountsForFile = $this->userMountCache->getMountsForFileId((int) $room->getObjectId());
$mountsForFile = $this->userMountCache->getMountsForFileId((int)$room->getObjectId());
if (!empty($mountsForFile)) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/Capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ public function getCapabilities(): array {
// 'folder' => string,
],
'call' => [
'enabled' => ((int) $this->serverConfig->getAppValue('spreed', 'start_calls', (string) Room::START_CALL_EVERYONE)) !== Room::START_CALL_NOONE,
'enabled' => ((int)$this->serverConfig->getAppValue('spreed', 'start_calls', (string)Room::START_CALL_EVERYONE)) !== Room::START_CALL_NOONE,
'breakout-rooms' => $this->talkConfig->isBreakoutRoomsEnabled(),
'recording' => $this->talkConfig->isRecordingEnabled(),
'recording-consent' => $this->talkConfig->recordingConsentRequired(),
Expand Down
4 changes: 2 additions & 2 deletions lib/Chat/AutoComplete/SearchPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ protected function searchUsers(string $search, array $users, ISearchResult $sear

$matches = $exactMatches = [];
foreach ($users as $userId => $displayName) {
$userId = (string) $userId;
$userId = (string)$userId;
if ($this->userId !== '' && $this->userId === $userId) {
// Do not suggest the current user
continue;
Expand Down Expand Up @@ -219,7 +219,7 @@ protected function searchGroups(string $search, array $groups, ISearchResult $se
continue;
}

$groupId = (string) $groupId;
$groupId = (string)$groupId;
if ($searchResult->hasResult($type, $groupId)) {
continue;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Chat/Changelog/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(
}

public function getChangelogForUser(string $userId): int {
return (int) $this->config->getUserValue($userId, 'spreed', 'changelog', '0');
return (int)$this->config->getUserValue($userId, 'spreed', 'changelog', '0');
}

public function userHasNewChangelog(string $userId): bool {
Expand All @@ -43,7 +43,7 @@ public function updateChangelog(string $userId): void {
$hasReceivedLog = $this->getChangelogForUser($userId);

try {
$this->config->setUserValue($userId, 'spreed', 'changelog', (string) count($logs), (string) $hasReceivedLog);
$this->config->setUserValue($userId, 'spreed', 'changelog', (string)count($logs), (string)$hasReceivedLog);
} catch (PreConditionNotMetException $e) {
// Parallel request won the race
return;
Expand Down
66 changes: 33 additions & 33 deletions lib/Chat/ChatManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ public function __construct(
* Sends a new message to the given chat.
*
* @param bool $shouldSkipLastMessageUpdate If multiple messages will be posted
* (e.g. when adding multiple users to a room) we can skip the last
* message and last activity update until the last entry was created
* and then update with those values.
* This will replace O(n) with 1 database update.
* (e.g. when adding multiple users to a room) we can skip the last
* message and last activity update until the last entry was created
* and then update with those values.
* This will replace O(n) with 1 database update.
* @throws MessagingNotAllowedException
*/
public function addSystemMessage(
Expand All @@ -133,7 +133,7 @@ public function addSystemMessage(
throw $e;
}

$comment = $this->commentsManager->create($actorType, $actorId, 'chat', (string) $chat->getId());
$comment = $this->commentsManager->create($actorType, $actorId, 'chat', (string)$chat->getId());
$comment->setMessage($message, self::MAX_CHAT_LENGTH);
$comment->setCreationDateTime($creationDateTime);
if ($referenceId !== null) {
Expand Down Expand Up @@ -200,10 +200,10 @@ public function addSystemMessage(
$alreadyNotifiedUsers = $this->notifier->notifyMentionedUsers($chat, $captionComment ?? $comment, $alreadyNotifiedUsers, $silent);
if (!empty($alreadyNotifiedUsers)) {
$userIds = array_column($alreadyNotifiedUsers, 'id');
$this->participantService->markUsersAsMentioned($chat, Attendee::ACTOR_USERS, $userIds, (int) $comment->getId(), $usersDirectlyMentioned);
$this->participantService->markUsersAsMentioned($chat, Attendee::ACTOR_USERS, $userIds, (int)$comment->getId(), $usersDirectlyMentioned);
}
if (!empty($federatedUsersDirectlyMentioned)) {
$this->participantService->markUsersAsMentioned($chat, Attendee::ACTOR_FEDERATED_USERS, $federatedUsersDirectlyMentioned, (int) $comment->getId(), $federatedUsersDirectlyMentioned);
$this->participantService->markUsersAsMentioned($chat, Attendee::ACTOR_FEDERATED_USERS, $federatedUsersDirectlyMentioned, (int)$comment->getId(), $federatedUsersDirectlyMentioned);
}

$this->notifier->notifyOtherParticipant($chat, $comment, [], $silent);
Expand All @@ -214,7 +214,7 @@ public function addSystemMessage(
// e.g. sharing an item to the chat
try {
$participant = $this->participantService->getParticipantByActor($chat, $actorType, $actorId);
$this->participantService->updateLastReadMessage($participant, (int) $comment->getId());
$this->participantService->updateLastReadMessage($participant, (int)$comment->getId());
} catch (ParticipantNotFoundException) {
// Participant not found => No read-marker update needed
}
Expand Down Expand Up @@ -245,7 +245,7 @@ public function addSystemMessage(
* @return IComment
*/
public function addChangelogMessage(Room $chat, string $message): IComment {
$comment = $this->commentsManager->create(Attendee::ACTOR_GUESTS, Attendee::ACTOR_ID_CHANGELOG, 'chat', (string) $chat->getId());
$comment = $this->commentsManager->create(Attendee::ACTOR_GUESTS, Attendee::ACTOR_ID_CHANGELOG, 'chat', (string)$chat->getId());

$comment->setMessage($message, self::MAX_CHAT_LENGTH);
$comment->setCreationDateTime($this->timeFactory->getDateTime());
Expand Down Expand Up @@ -294,7 +294,7 @@ public function sendMessage(
throw $e;
}

$comment = $this->commentsManager->create($actorType, $actorId, 'chat', (string) $chat->getId());
$comment = $this->commentsManager->create($actorType, $actorId, 'chat', (string)$chat->getId());
$comment->setMessage($message, self::MAX_CHAT_LENGTH);
$comment->setCreationDateTime($creationDateTime);
// A verb ('comment', 'like'...) must be provided to be able to save a
Expand Down Expand Up @@ -340,7 +340,7 @@ public function sendMessage(
$this->commentsManager->save($comment);

if ($participant instanceof Participant) {
$this->participantService->updateLastReadMessage($participant, (int) $comment->getId());
$this->participantService->updateLastReadMessage($participant, (int)$comment->getId());
}

// Update last_message
Expand Down Expand Up @@ -368,10 +368,10 @@ public function sendMessage(
$alreadyNotifiedUsers = $this->notifier->notifyMentionedUsers($chat, $comment, $alreadyNotifiedUsers, $silent, $participant);
if (!empty($alreadyNotifiedUsers)) {
$userIds = array_column($alreadyNotifiedUsers, 'id');
$this->participantService->markUsersAsMentioned($chat, Attendee::ACTOR_USERS, $userIds, (int) $comment->getId(), $usersDirectlyMentioned);
$this->participantService->markUsersAsMentioned($chat, Attendee::ACTOR_USERS, $userIds, (int)$comment->getId(), $usersDirectlyMentioned);
}
if (!empty($federatedUsersDirectlyMentioned)) {
$this->participantService->markUsersAsMentioned($chat, Attendee::ACTOR_FEDERATED_USERS, $federatedUsersDirectlyMentioned, (int) $comment->getId(), $federatedUsersDirectlyMentioned);
$this->participantService->markUsersAsMentioned($chat, Attendee::ACTOR_FEDERATED_USERS, $federatedUsersDirectlyMentioned, (int)$comment->getId(), $federatedUsersDirectlyMentioned);
}

// User was not mentioned, send a normal notification
Expand Down Expand Up @@ -460,7 +460,7 @@ public function removePollOnMessageDelete(Room $room, Participant $participant,
],
], JSON_THROW_ON_ERROR),
'chat',
[(string) $room->getId()],
[(string)$room->getId()],
'system',
0
);
Expand Down Expand Up @@ -517,7 +517,7 @@ public function deleteMessage(Room $chat, IComment $comment, Participant $partic

$this->commentsManager->save($comment);

$this->attachmentService->deleteAttachmentByMessageId((int) $comment->getId());
$this->attachmentService->deleteAttachmentByMessageId((int)$comment->getId());

$this->referenceManager->invalidateCache($chat->getToken());

Expand Down Expand Up @@ -602,10 +602,10 @@ public function editMessage(Room $chat, IComment $comment, Participant $particip
$alreadyNotifiedUsers = $this->notifier->notifyMentionedUsers($chat, $comment, $usersToNotifyBefore, silent: false);
if (!empty($alreadyNotifiedUsers)) {
$userIds = array_column($alreadyNotifiedUsers, 'id');
$this->participantService->markUsersAsMentioned($chat, Attendee::ACTOR_USERS, $userIds, (int) $comment->getId(), $addedUsersDirectMentioned);
$this->participantService->markUsersAsMentioned($chat, Attendee::ACTOR_USERS, $userIds, (int)$comment->getId(), $addedUsersDirectMentioned);
}
if (!empty($federatedUsersDirectlyMentionedAfter)) {
$this->participantService->markUsersAsMentioned($chat, Attendee::ACTOR_FEDERATED_USERS, $federatedUsersDirectlyMentionedAfter, (int) $comment->getId(), $federatedUsersDirectlyMentionedAfter);
$this->participantService->markUsersAsMentioned($chat, Attendee::ACTOR_FEDERATED_USERS, $federatedUsersDirectlyMentionedAfter, (int)$comment->getId(), $federatedUsersDirectlyMentionedAfter);
}
}
}
Expand All @@ -631,7 +631,7 @@ protected static function compareMention(array $mention1, array $mention2): int
}

public function clearHistory(Room $chat, string $actorType, string $actorId): IComment {
$this->commentsManager->deleteCommentsAtObject('chat', (string) $chat->getId());
$this->commentsManager->deleteCommentsAtObject('chat', (string)$chat->getId());

$this->shareProvider->deleteInRoom($chat->getToken());

Expand Down Expand Up @@ -660,7 +660,7 @@ public function clearHistory(Room $chat, string $actorType, string $actorId): IC
public function getParentComment(Room $chat, string $parentId): IComment {
$comment = $this->commentsManager->get($parentId);

if ($comment->getObjectType() !== 'chat' || $comment->getObjectId() !== (string) $chat->getId()) {
if ($comment->getObjectType() !== 'chat' || $comment->getObjectId() !== (string)$chat->getId()) {
throw new NotFoundException('Parent not found in the right context');
}

Expand All @@ -680,20 +680,20 @@ public function getComment(Room $chat, string $messageId): IComment {

$comment = $this->commentsManager->get($messageId);

if ($comment->getObjectType() !== 'chat' || $comment->getObjectId() !== (string) $chat->getId()) {
if ($comment->getObjectType() !== 'chat' || $comment->getObjectId() !== (string)$chat->getId()) {
throw new NotFoundException('Message not found in the right context');
}

return $comment;
}

public function getLastReadMessageFromLegacy(Room $chat, IUser $user): int {
$marker = $this->commentsManager->getReadMark('chat', (string) $chat->getId(), $user);
$marker = $this->commentsManager->getReadMark('chat', (string)$chat->getId(), $user);
if ($marker === null) {
return 0;
}

return $this->commentsManager->getLastCommentBeforeDate('chat', (string) $chat->getId(), $marker, self::VERB_MESSAGE);
return $this->commentsManager->getLastCommentBeforeDate('chat', (string)$chat->getId(), $marker, self::VERB_MESSAGE);
}

public function getUnreadCount(Room $chat, int $lastReadMessage): int {
Expand All @@ -705,7 +705,7 @@ public function getUnreadCount(Room $chat, int $lastReadMessage): int {
$key = $chat->getId() . '-' . $lastReadMessage;
$unreadCount = $this->unreadCountCache->get($key);
if ($unreadCount === null) {
$unreadCount = $this->commentsManager->getNumberOfCommentsWithVerbsForObjectSinceComment('chat', (string) $chat->getId(), $lastReadMessage, [self::VERB_MESSAGE, 'object_shared']);
$unreadCount = $this->commentsManager->getNumberOfCommentsWithVerbsForObjectSinceComment('chat', (string)$chat->getId(), $lastReadMessage, [self::VERB_MESSAGE, 'object_shared']);
$this->unreadCountCache->set($key, $unreadCount, 1800);
}
return $unreadCount;
Expand All @@ -730,11 +730,11 @@ public function getLastCommonReadMessage(Room $chat): int {
* @param int $limit
* @param bool $includeLastKnown
* @return IComment[] the messages found (only the id, actor type and id,
* creation date and message are relevant), or an empty array if the
* timeout expired.
* creation date and message are relevant), or an empty array if the
* timeout expired.
*/
public function getHistory(Room $chat, int $offset, int $limit, bool $includeLastKnown): array {
return $this->commentsManager->getForObjectSince('chat', (string) $chat->getId(), $offset, 'desc', $limit, $includeLastKnown);
return $this->commentsManager->getForObjectSince('chat', (string)$chat->getId(), $offset, 'desc', $limit, $includeLastKnown);
}

/**
Expand All @@ -748,7 +748,7 @@ public function getHistory(Room $chat, int $offset, int $limit, bool $includeLas
public function getPreviousMessageWithVerb(Room $chat, int $offset, array $verbs, bool $offsetIsVerbMatch): IComment {
$messages = $this->commentsManager->getCommentsWithVerbForObjectSinceComment(
'chat',
(string) $chat->getId(),
(string)$chat->getId(),
$verbs,
$offset,
'desc',
Expand Down Expand Up @@ -780,8 +780,8 @@ public function getPreviousMessageWithVerb(Room $chat, int $offset, array $verbs
* @param bool $includeLastKnown
* @param bool $markNotificationsAsRead (defaults to true)
* @return IComment[] the messages found (only the id, actor type and id,
* creation date and message are relevant), or an empty array if the
* timeout expired.
* creation date and message are relevant), or an empty array if the
* timeout expired.
*/
public function waitForNewMessages(Room $chat, int $offset, int $limit, int $timeout, ?IUser $user, bool $includeLastKnown, bool $markNotificationsAsRead = true): array {
if ($markNotificationsAsRead && $user instanceof IUser) {
Expand Down Expand Up @@ -839,7 +839,7 @@ protected function checkCacheOrDatabase(Room $chat, int $offset, int $limit, boo
}

// Load data from the database
$comments = $this->commentsManager->getForObjectSince('chat', (string) $chat->getId(), $offset, 'asc', $limit, $includeLastKnown);
$comments = $this->commentsManager->getForObjectSince('chat', (string)$chat->getId(), $offset, 'asc', $limit, $includeLastKnown);

if (empty($comments)) {
// We only write the cache when there were no new comments,
Expand All @@ -865,13 +865,13 @@ protected function checkCacheOrDatabase(Room $chat, int $offset, int $limit, boo
protected function waitForNewMessagesWithDatabase(Room $chat, int $offset, int $limit, int $timeout, bool $includeLastKnown): array {
$elapsedTime = 0;

$comments = $this->commentsManager->getForObjectSince('chat', (string) $chat->getId(), $offset, 'asc', $limit, $includeLastKnown);
$comments = $this->commentsManager->getForObjectSince('chat', (string)$chat->getId(), $offset, 'asc', $limit, $includeLastKnown);

while (empty($comments) && $elapsedTime < $timeout) {
sleep(1);
$elapsedTime++;

$comments = $this->commentsManager->getForObjectSince('chat', (string) $chat->getId(), $offset, 'asc', $limit, $includeLastKnown);
$comments = $this->commentsManager->getForObjectSince('chat', (string)$chat->getId(), $offset, 'asc', $limit, $includeLastKnown);
}

return $comments;
Expand All @@ -883,7 +883,7 @@ protected function waitForNewMessagesWithDatabase(Room $chat, int $offset, int $
* @param Room $chat
*/
public function deleteMessages(Room $chat): void {
$this->commentsManager->deleteCommentsAtObject('chat', (string) $chat->getId());
$this->commentsManager->deleteCommentsAtObject('chat', (string)$chat->getId());

$this->shareProvider->deleteInRoom($chat->getToken());

Expand Down
6 changes: 3 additions & 3 deletions lib/Chat/CommentsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function getCommentsById(array $ids): array {
$comments = [];
$result = $query->execute();
while ($row = $result->fetch()) {
$comments[(int) $row['id']] = $this->getCommentFromData($row);
$comments[(int)$row['id']] = $this->getCommentFromData($row);
}
$result->closeCursor();

Expand All @@ -70,8 +70,8 @@ public function retrieveReactionsByActor(string $actorType, string $actorId, arr
$reactions = [];
$result = $query->executeQuery();
while ($row = $result->fetch()) {
$reactions[(int) $row['parent_id']] ??= [];
$reactions[(int) $row['parent_id']][] = $row['reaction'];
$reactions[(int)$row['parent_id']] ??= [];
$reactions[(int)$row['parent_id']][] = $row['reaction'];
}
$result->closeCursor();

Expand Down
2 changes: 1 addition & 1 deletion lib/Chat/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ private function createNotification(Room $chat, IComment $comment, string $subje
}

protected function getDefaultGroupNotification(): int {
return (int) $this->config->getAppValue('spreed', 'default_group_notification', (string) Participant::NOTIFY_MENTION);
return (int)$this->config->getAppValue('spreed', 'default_group_notification', (string)Participant::NOTIFY_MENTION);
}

/**
Expand Down
Loading

0 comments on commit 4f2319e

Please sign in to comment.