Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: Fix code quality based on review
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed Aug 7, 2023
commit dd2b3ac4c09d314f66072cae2753a7ea9819d829
2 changes: 1 addition & 1 deletion lib/Chat/ChatManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public function sendMessage(Room $chat, ?Participant $participant, string $actor
try {
$this->commentsManager->save($comment);

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

Expand Down
5 changes: 2 additions & 3 deletions lib/Chat/Parser/SystemMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,6 @@ public function parseDeletedMessage(Message $chatMessage): void {
$parsedParameters = ['actor' => $this->getActor($room, $data['deleted_by_type'], $data['deleted_by_id'])];

$participant = $chatMessage->getParticipant();
$currentActorId = $participant?->getAttendee()->getActorId();

$authorIsActor = $data['deleted_by_type'] === $chatMessage->getComment()->getActorType()
&& $data['deleted_by_id'] === $chatMessage->getComment()->getActorId();
Expand All @@ -576,11 +575,11 @@ public function parseDeletedMessage(Message $chatMessage): void {
} elseif (!$participant->isGuest()) {
$currentUserIsActor = $parsedParameters['actor']['type'] === 'user' &&
$participant->getAttendee()->getActorType() === Attendee::ACTOR_USERS &&
$currentActorId === $parsedParameters['actor']['id'];
$participant->getAttendee()->getActorId() === $parsedParameters['actor']['id'];
} else {
$currentUserIsActor = $parsedParameters['actor']['type'] === 'guest' &&
$participant->getAttendee()->getActorType() === 'guest' &&
$currentActorId === $parsedParameters['actor']['id'];
$participant->getAttendee()->getActorId() === $parsedParameters['actor']['id'];
}

if ($chatMessage->getMessageType() === ChatManager::VERB_MESSAGE_DELETED) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Chat/Parser/UserMention.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function parseMessage(Message $chatMessage): void {
if ($mention['type'] === 'call') {
$userId = '';
if ($chatMessage->getParticipant()?->getAttendee()->getActorType() === Attendee::ACTOR_USERS) {
$userId = $chatMessage->getParticipant()?->getAttendee()->getActorId();
$userId = $chatMessage->getParticipant()->getAttendee()->getActorId();
}

$messageParameters[$mentionParameterId] = [
Expand Down
4 changes: 4 additions & 0 deletions lib/Migration/Version18000Date20230504205823.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
]);
$table->addColumn('error_count', Types::BIGINT, [
'default' => 0,
'unsigned' => true,
]);
$table->addColumn('last_error_date', Types::DATETIME, [
'notnull' => false,
Expand All @@ -77,6 +78,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
$table->addColumn('state', Types::SMALLINT, [
'default' => 0,
'notnull' => false,
'unsigned' => true,
]);

$table->setPrimaryKey(['id']);
Expand All @@ -90,6 +92,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
]);
$table->addColumn('bot_id', Types::BIGINT, [
'default' => 0,
'unsigned' => true,
]);
$table->addColumn('token', Types::STRING, [
'length' => 64,
Expand All @@ -98,6 +101,7 @@ public function changeSchema(IOutput $output, Closure $schemaClosure, array $opt
$table->addColumn('state', Types::SMALLINT, [
'default' => 0,
'notnull' => false,
'unsigned' => true,
]);

$table->setPrimaryKey(['id']);
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/BotService.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public function afterChatMessageSent(ChatParticipantEvent $event, MessageParser
'type' => 'Note',
'id' => $event->getComment()->getId(),
'name' => 'message',
'content' => json_encode($messageData),
'content' => json_encode($messageData, JSON_THROW_ON_ERROR),
'mediaType' => 'text/markdown', // FIXME or text/plain when markdown is disabled
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a reminder. I don't know if it should be fixed now or later

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it's for the future, in 27.1 we only support "everything is markdown"

],
'target' => [
Expand Down
1 change: 0 additions & 1 deletion tests/integration/features/bootstrap/CommandLineTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ public function theCommandOutputContainsTheText($text) {
Assert::assertTrue(false, 'The command did not output the expected text on stdout but stderr');
}

var_dump($this->lastStdOut);
Assert::assertStringContainsString($text, $this->lastStdOut, 'The command did not output the expected text on stdout');
}

Expand Down