summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2023-08-04 14:15:01 +0200
committerJoas Schilling <coding@schilljs.com>2023-08-08 10:46:56 +0200
commitb66fd19c86c251c225dc625add95c79a50134d64 (patch)
tree46f4c1fcd88ca9d005a5b61826b542bf005a8c3e
parent5a68ea2a447c3b688cd7c4b8db76b2e5c9aaf144 (diff)
fix: Fix code quality based on review
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--lib/Chat/ChatManager.php2
-rw-r--r--lib/Chat/Parser/SystemMessage.php5
-rw-r--r--lib/Chat/Parser/UserMention.php2
-rw-r--r--lib/Migration/Version18000Date20230504205823.php4
-rw-r--r--lib/Service/BotService.php2
-rw-r--r--tests/integration/features/bootstrap/CommandLineTrait.php1
6 files changed, 9 insertions, 7 deletions
diff --git a/lib/Chat/ChatManager.php b/lib/Chat/ChatManager.php
index e95976d7a..c644b87a2 100644
--- a/lib/Chat/ChatManager.php
+++ b/lib/Chat/ChatManager.php
@@ -300,7 +300,7 @@ class ChatManager {
try {
$this->commentsManager->save($comment);
- if ($participant !== null) {
+ if ($participant instanceof Participant) {
$this->participantService->updateLastReadMessage($participant, (int) $comment->getId());
}
diff --git a/lib/Chat/Parser/SystemMessage.php b/lib/Chat/Parser/SystemMessage.php
index 0b2dc2847..41e062c95 100644
--- a/lib/Chat/Parser/SystemMessage.php
+++ b/lib/Chat/Parser/SystemMessage.php
@@ -586,7 +586,6 @@ class SystemMessage {
$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();
@@ -596,11 +595,11 @@ class SystemMessage {
} 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) {
diff --git a/lib/Chat/Parser/UserMention.php b/lib/Chat/Parser/UserMention.php
index 0274f7e8f..9bd54fb66 100644
--- a/lib/Chat/Parser/UserMention.php
+++ b/lib/Chat/Parser/UserMention.php
@@ -136,7 +136,7 @@ class UserMention {
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] = [
diff --git a/lib/Migration/Version18000Date20230504205823.php b/lib/Migration/Version18000Date20230504205823.php
index 1a13e409f..32cbc0c26 100644
--- a/lib/Migration/Version18000Date20230504205823.php
+++ b/lib/Migration/Version18000Date20230504205823.php
@@ -66,6 +66,7 @@ class Version18000Date20230504205823 extends SimpleMigrationStep {
]);
$table->addColumn('error_count', Types::BIGINT, [
'default' => 0,
+ 'unsigned' => true,
]);
$table->addColumn('last_error_date', Types::DATETIME, [
'notnull' => false,
@@ -77,6 +78,7 @@ class Version18000Date20230504205823 extends SimpleMigrationStep {
$table->addColumn('state', Types::SMALLINT, [
'default' => 0,
'notnull' => false,
+ 'unsigned' => true,
]);
$table->setPrimaryKey(['id']);
@@ -90,6 +92,7 @@ class Version18000Date20230504205823 extends SimpleMigrationStep {
]);
$table->addColumn('bot_id', Types::BIGINT, [
'default' => 0,
+ 'unsigned' => true,
]);
$table->addColumn('token', Types::STRING, [
'length' => 64,
@@ -98,6 +101,7 @@ class Version18000Date20230504205823 extends SimpleMigrationStep {
$table->addColumn('state', Types::SMALLINT, [
'default' => 0,
'notnull' => false,
+ 'unsigned' => true,
]);
$table->setPrimaryKey(['id']);
diff --git a/lib/Service/BotService.php b/lib/Service/BotService.php
index 64d047503..e371c6ac0 100644
--- a/lib/Service/BotService.php
+++ b/lib/Service/BotService.php
@@ -95,7 +95,7 @@ class BotService {
'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
],
'target' => [
diff --git a/tests/integration/features/bootstrap/CommandLineTrait.php b/tests/integration/features/bootstrap/CommandLineTrait.php
index 544282fda..968486a8b 100644
--- a/tests/integration/features/bootstrap/CommandLineTrait.php
+++ b/tests/integration/features/bootstrap/CommandLineTrait.php
@@ -161,7 +161,6 @@ trait CommandLineTrait {
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');
}