Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ And in the works for the [coming versions](https://github.com/nextcloud/spreed/m

]]></description>

<version>11.0.0-dev.8</version>
<version>11.0.0-dev.9</version>
<licence>agpl</licence>

<author>Daniel Calviño Sánchez</author>
Expand Down
8 changes: 4 additions & 4 deletions lib/GuestManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ 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();
} else {
$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']);
Expand All @@ -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();
Expand All @@ -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();
Expand Down
144 changes: 144 additions & 0 deletions lib/Migration/Version11000Date20201209142525.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?php

declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, Joas Schilling <[email protected]>
*
* @author Joas Schilling <[email protected]>
*
* @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 <http://www.gnu.org/licenses/>.
*
*/

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();
}
}
58 changes: 58 additions & 0 deletions lib/Migration/Version11000Date20201209142526.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

declare(strict_types=1);
/**
* @copyright Copyright (c) 2020, Joas Schilling <[email protected]>
*
* @author Joas Schilling <[email protected]>
*
* @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 <http://www.gnu.org/licenses/>.
*
*/

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;
}
}
47 changes: 26 additions & 21 deletions lib/Migration/Version2001Date20171026134605.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
46 changes: 25 additions & 21 deletions lib/Migration/Version3002Date20180319104030.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
}
Loading