diff --git a/appinfo/info.xml b/appinfo/info.xml
index 19678f34576..e737c0346de 100644
--- a/appinfo/info.xml
+++ b/appinfo/info.xml
@@ -16,7 +16,7 @@ And in the works for the [coming versions](https://github.com/nextcloud/spreed/m
]]>
- 11.0.0-dev.8
+ 11.0.0-dev.9
agpl
Daniel Calviño Sánchez
diff --git a/lib/GuestManager.php b/lib/GuestManager.php
index 067ffac2730..3d7a6f17899 100644
--- a/lib/GuestManager.php
+++ b/lib/GuestManager.php
@@ -99,7 +99,7 @@ public function updateName(Room $room, Participant $participant, string $display
if ($oldName !== $displayName) {
$query = $this->connection->getQueryBuilder();
- $query->update('talk_guests')
+ $query->update('talk_guestnames')
->set('display_name', $query->createNamedParameter($displayName))
->where($query->expr()->eq('session_hash', $query->createNamedParameter($sessionHash)));
$query->execute();
@@ -107,7 +107,7 @@ public function updateName(Room $room, Participant $participant, string $display
$dispatchEvent = false;
}
} catch (ParticipantNotFoundException $e) {
- $this->connection->insertIfNotExist('*PREFIX*talk_guests', [
+ $this->connection->insertIfNotExist('*PREFIX*talk_guestnames', [
'session_hash' => $sessionHash,
'display_name' => $displayName,
], ['session_hash']);
@@ -128,7 +128,7 @@ public function updateName(Room $room, Participant $participant, string $display
public function getNameBySessionHash(string $sessionHash, bool $allowEmpty = false): string {
$query = $this->connection->getQueryBuilder();
$query->select('display_name')
- ->from('talk_guests')
+ ->from('talk_guestnames')
->where($query->expr()->eq('session_hash', $query->createNamedParameter($sessionHash)));
$result = $query->execute();
@@ -153,7 +153,7 @@ public function getNamesBySessionHashes(array $sessionHashes): array {
$query = $this->connection->getQueryBuilder();
$query->select('*')
- ->from('talk_guests')
+ ->from('talk_guestnames')
->where($query->expr()->in('session_hash', $query->createNamedParameter($sessionHashes, IQueryBuilder::PARAM_STR_ARRAY)));
$result = $query->execute();
diff --git a/lib/Migration/Version11000Date20201209142525.php b/lib/Migration/Version11000Date20201209142525.php
new file mode 100644
index 00000000000..1f4edc318ad
--- /dev/null
+++ b/lib/Migration/Version11000Date20201209142525.php
@@ -0,0 +1,144 @@
+
+ *
+ * @author Joas Schilling
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+namespace OCA\Talk\Migration;
+
+use Closure;
+use Doctrine\DBAL\Types\Types;
+use OCP\DB\ISchemaWrapper;
+use OCP\IDBConnection;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+class Version11000Date20201209142525 extends SimpleMigrationStep {
+ /** @var IDBConnection */
+ protected $connection;
+
+ public function __construct(IDBConnection $connection) {
+ $this->connection = $connection;
+ }
+
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ * @return null|ISchemaWrapper
+ */
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ $changedSchema = false;
+ if (!$schema->hasTable('talk_internalsignaling')) {
+ $table = $schema->createTable('talk_internalsignaling');
+
+ // Auto increment id
+ $table->addColumn('id', Types::BIGINT, [
+ 'autoincrement' => true,
+ 'notnull' => true,
+ ]);
+
+ $table->addColumn('sender', Types::STRING, [
+ 'notnull' => true,
+ 'length' => 255,
+ ]);
+ $table->addColumn('recipient', Types::STRING, [
+ 'notnull' => true,
+ 'length' => 255,
+ ]);
+ $table->addColumn('message', Types::TEXT, [
+ 'notnull' => true,
+ ]);
+ $table->addColumn('timestamp', Types::INTEGER, [
+ 'notnull' => true,
+ 'length' => 11,
+ ]);
+
+ $table->setPrimaryKey(['id']);
+ $table->addIndex(['recipient', 'timestamp'], 'tis_recipient_time');
+
+ $changedSchema = true;
+ }
+
+ if (!$schema->hasTable('talk_guestnames')) {
+ $table = $schema->createTable('talk_guestnames');
+
+ // Auto increment id
+ $table->addColumn('id', Types::BIGINT, [
+ 'autoincrement' => true,
+ 'notnull' => true,
+ ]);
+
+ $table->addColumn('session_hash', Types::STRING, [
+ 'notnull' => false,
+ 'length' => 64,
+ ]);
+ $table->addColumn('display_name', Types::STRING, [
+ 'notnull' => false,
+ 'length' => 64,
+ 'default' => '',
+ ]);
+
+ $table->setPrimaryKey(['id']);
+ $table->addUniqueIndex(['session_hash'], 'tg_session_hash');
+ $changedSchema = true;
+ }
+
+ return $changedSchema ? $schema : null;
+ }
+
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ */
+ public function postSchemaChange(IOutput $output, Closure $schemaClosure, array $options): void {
+ if (!$this->connection->tableExists('talk_guests')) {
+ return;
+ }
+
+ $insert = $this->connection->getQueryBuilder();
+ $insert->insert('talk_guestnames')
+ ->values([
+ 'session_hash' => $insert->createParameter('session_hash'),
+ 'display_name' => $insert->createParameter('display_name'),
+ ]);
+
+ $query = $this->connection->getQueryBuilder();
+ $query->select('*')
+ ->from('talk_guests');
+
+ $result = $query->execute();
+ while ($row = $result->fetch()) {
+ $insert
+ ->setParameter('session_hash', (string) $row['session_hash'])
+ ->setParameter('display_name', (string) $row['display_name'])
+ ;
+ $insert->execute();
+ }
+ $result->closeCursor();
+ }
+}
diff --git a/lib/Migration/Version11000Date20201209142526.php b/lib/Migration/Version11000Date20201209142526.php
new file mode 100644
index 00000000000..85f1a2d38f1
--- /dev/null
+++ b/lib/Migration/Version11000Date20201209142526.php
@@ -0,0 +1,58 @@
+
+ *
+ * @author Joas Schilling
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ *
+ */
+
+namespace OCA\Talk\Migration;
+
+use Closure;
+use OCP\DB\ISchemaWrapper;
+use OCP\Migration\IOutput;
+use OCP\Migration\SimpleMigrationStep;
+
+class Version11000Date20201209142526 extends SimpleMigrationStep {
+ /**
+ * @param IOutput $output
+ * @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
+ * @param array $options
+ * @return null|ISchemaWrapper
+ */
+ public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper {
+ /** @var ISchemaWrapper $schema */
+ $schema = $schemaClosure();
+
+ $changedSchema = false;
+
+ if ($schema->hasTable('talk_signaling')) {
+ $schema->dropTable('talk_signaling');
+ $changedSchema = true;
+ }
+
+ if ($schema->hasTable('talk_guests')) {
+ $schema->dropTable('talk_guests');
+ $changedSchema = true;
+ }
+
+ return $changedSchema ? $schema : null;
+ }
+}
diff --git a/lib/Migration/Version2001Date20171026134605.php b/lib/Migration/Version2001Date20171026134605.php
index bd40b396d2c..958cc16aba7 100644
--- a/lib/Migration/Version2001Date20171026134605.php
+++ b/lib/Migration/Version2001Date20171026134605.php
@@ -60,27 +60,32 @@ public function changeSchema(IOutput $output, \Closure $schemaClosure, array $op
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
- if (!$schema->hasTable('talk_signaling')) {
- $table = $schema->createTable('talk_signaling');
-
- $table->addColumn('sender', Type::STRING, [
- 'notnull' => true,
- 'length' => 255,
- ]);
- $table->addColumn('recipient', Type::STRING, [
- 'notnull' => true,
- 'length' => 255,
- ]);
- $table->addColumn('message', Type::TEXT, [
- 'notnull' => true,
- ]);
- $table->addColumn('timestamp', Type::INTEGER, [
- 'notnull' => true,
- 'length' => 11,
- ]);
-
- $table->addIndex(['recipient', 'timestamp'], 'ts_recipient_time');
- }
+ /**
+ * Table had to be rebuild because it was missing a primary key
+ * @see Version11000Date20201209142525
+ *
+ * if (!$schema->hasTable('talk_signaling')) {
+ * $table = $schema->createTable('talk_signaling');
+ *
+ * $table->addColumn('sender', Type::STRING, [
+ * 'notnull' => true,
+ * 'length' => 255,
+ * ]);
+ * $table->addColumn('recipient', Type::STRING, [
+ * 'notnull' => true,
+ * 'length' => 255,
+ * ]);
+ * $table->addColumn('message', Type::TEXT, [
+ * 'notnull' => true,
+ * ]);
+ * $table->addColumn('timestamp', Type::INTEGER, [
+ * 'notnull' => true,
+ * 'length' => 11,
+ * ]);
+ *
+ * $table->addIndex(['recipient', 'timestamp'], 'ts_recipient_time');
+ * }
+ */
if (!$schema->hasTable('talk_rooms')) {
$table = $schema->createTable('talk_rooms');
diff --git a/lib/Migration/Version3002Date20180319104030.php b/lib/Migration/Version3002Date20180319104030.php
index 35d1228c498..3186b99072a 100644
--- a/lib/Migration/Version3002Date20180319104030.php
+++ b/lib/Migration/Version3002Date20180319104030.php
@@ -24,7 +24,6 @@
*/
namespace OCA\Talk\Migration;
-use Doctrine\DBAL\Types\Type;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\SimpleMigrationStep;
use OCP\Migration\IOutput;
@@ -39,25 +38,30 @@ class Version3002Date20180319104030 extends SimpleMigrationStep {
* @since 13.0.0
*/
public function changeSchema(IOutput $output, \Closure $schemaClosure, array $options): ?ISchemaWrapper {
- /** @var ISchemaWrapper $schema */
- $schema = $schemaClosure();
-
- if (!$schema->hasTable('talk_guests')) {
- $table = $schema->createTable('talk_guests');
-
- $table->addColumn('session_hash', Type::STRING, [
- 'notnull' => false,
- 'length' => 64,
- ]);
- $table->addColumn('display_name', Type::STRING, [
- 'notnull' => false,
- 'length' => 64,
- 'default' => '',
- ]);
-
- $table->addUniqueIndex(['session_hash'], 'tg_session_hash');
- }
-
- return $schema;
+ /**
+ * The table had to be redone so it contains a primary key
+ * @see Version11000Date20201209142525
+ *
+ * $schema = $schemaClosure();
+ *
+ * if (!$schema->hasTable('talk_guests')) {
+ * $table = $schema->createTable('talk_guests');
+ *
+ * $table->addColumn('session_hash', Type::STRING, [
+ * 'notnull' => false,
+ * 'length' => 64,
+ * ]);
+ * $table->addColumn('display_name', Type::STRING, [
+ * 'notnull' => false,
+ * 'length' => 64,
+ * 'default' => '',
+ * ]);
+ *
+ * $table->addUniqueIndex(['session_hash'], 'tg_session_hash');
+ * }
+ *
+ * return $schema;
+ */
+ return null;
}
}
diff --git a/lib/Signaling/Messages.php b/lib/Signaling/Messages.php
index 09d5f5fa6b2..8f695442c0c 100644
--- a/lib/Signaling/Messages.php
+++ b/lib/Signaling/Messages.php
@@ -54,7 +54,7 @@ public function __construct(IDBConnection $db,
*/
public function deleteMessages(array $sessionIds): void {
$query = $this->db->getQueryBuilder();
- $query->delete('talk_signaling')
+ $query->delete('talk_internalsignaling')
->where($query->expr()->in('recipient', $query->createNamedParameter($sessionIds, IQueryBuilder::PARAM_STR_ARRAY)))
->orWhere($query->expr()->in('sender', $query->createNamedParameter($sessionIds, IQueryBuilder::PARAM_STR_ARRAY)));
$query->execute();
@@ -67,7 +67,7 @@ public function deleteMessages(array $sessionIds): void {
*/
public function addMessage(string $senderSessionId, string $recipientSessionId, string $message): void {
$query = $this->db->getQueryBuilder();
- $query->insert('talk_signaling')
+ $query->insert('talk_internalsignaling')
->values(
[
'sender' => $query->createNamedParameter($senderSessionId),
@@ -85,7 +85,7 @@ public function addMessage(string $senderSessionId, string $recipientSessionId,
*/
public function addMessageForAllParticipants(Room $room, string $message): void {
$query = $this->db->getQueryBuilder();
- $query->insert('talk_signaling')
+ $query->insert('talk_internalsignaling')
->values(
[
'sender' => $query->createParameter('sender'),
@@ -123,7 +123,7 @@ public function getAndDeleteMessages(string $sessionId): array {
$query = $this->db->getQueryBuilder();
$query->select('*')
- ->from('talk_signaling')
+ ->from('talk_internalsignaling')
->where($query->expr()->eq('recipient', $query->createNamedParameter($sessionId)))
->andWhere($query->expr()->lte('timestamp', $query->createNamedParameter($time)));
$result = $query->execute();
@@ -134,7 +134,7 @@ public function getAndDeleteMessages(string $sessionId): array {
$result->closeCursor();
$query = $this->db->getQueryBuilder();
- $query->delete('talk_signaling')
+ $query->delete('talk_internalsignaling')
->where($query->expr()->eq('recipient', $query->createNamedParameter($sessionId)))
->andWhere($query->expr()->lte('timestamp', $query->createNamedParameter($time)));
$query->execute();
@@ -151,7 +151,7 @@ public function expireOlderThan(int $olderThan): void {
$time = $this->timeFactory->getTime() - $olderThan;
$query = $this->db->getQueryBuilder();
- $query->delete('talk_signaling')
+ $query->delete('talk_internalsignaling')
->where($query->expr()->lt('timestamp', $query->createNamedParameter($time)));
$query->execute();
}
diff --git a/psalm.xml b/psalm.xml
index 4b701c084c1..6b701399cb7 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -22,6 +22,7 @@
+
diff --git a/tests/integration/spreedcheats/lib/Controller/ApiController.php b/tests/integration/spreedcheats/lib/Controller/ApiController.php
index 194d16ae49a..654a7be9356 100644
--- a/tests/integration/spreedcheats/lib/Controller/ApiController.php
+++ b/tests/integration/spreedcheats/lib/Controller/ApiController.php
@@ -50,7 +50,7 @@ public function __construct(string $appName,
*/
public function resetSpreed(): DataResponse {
$query = $this->db->getQueryBuilder();
- $query->delete('talk_signaling')->execute();
+ $query->delete('talk_internalsignaling')->execute();
$query = $this->db->getQueryBuilder();
$query->delete('talk_rooms')->execute();
@@ -58,6 +58,9 @@ public function resetSpreed(): DataResponse {
$query = $this->db->getQueryBuilder();
$query->delete('talk_attendees')->execute();
+ $query = $this->db->getQueryBuilder();
+ $query->delete('talk_guestnames')->execute();
+
$query = $this->db->getQueryBuilder();
$query->delete('talk_sessions')->execute();