-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add option to disable end-to-end encryption to allow legacy cli…
…ents. Signed-off-by: Joachim Bauch <bauch@struktur.de>
- Loading branch information
Showing
17 changed files
with
251 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
* SPDX-License-Identifier: AGPL-3.0-or-later | ||
*/ | ||
|
||
namespace OCA\Talk\Migration; | ||
|
||
use Closure; | ||
use OCP\DB\ISchemaWrapper; | ||
use OCP\DB\Types; | ||
use OCP\Migration\IOutput; | ||
use OCP\Migration\SimpleMigrationStep; | ||
|
||
class Version21000Date20241212134329 extends SimpleMigrationStep { | ||
/** | ||
* @param IOutput $output | ||
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper` | ||
* @param array $options | ||
* | ||
* @return ISchemaWrapper | ||
*/ | ||
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ISchemaWrapper { | ||
/** @var ISchemaWrapper $schema */ | ||
$schema = $schemaClosure(); | ||
|
||
$table = $schema->getTable('talk_rooms'); | ||
if (!$table->hasColumn('encrypted')) { | ||
$table->addColumn('encrypted', Types::BOOLEAN, [ | ||
'notnull' => false, | ||
'default' => true, | ||
]); | ||
} | ||
|
||
return $schema; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<!-- | ||
- SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
- SPDX-License-Identifier: AGPL-3.0-or-later | ||
--> | ||
|
||
<template> | ||
<div class="app-settings-subsection"> | ||
<h4 class="app-settings-section__subtitle"> | ||
{{ t('spreed', 'Security') }} | ||
</h4> | ||
|
||
<div> | ||
<NcCheckboxRadioSwitch :checked="!hasEncryptionEnabled" | ||
type="switch" | ||
aria-describedby="encryption_settings_hint" | ||
:disabled="isEncryptionLoading" | ||
@update:checked="toggleSetting()"> | ||
{{ t('spreed', 'Disable end-to-end encryption to allow legacy clients.') }} | ||
</NcCheckboxRadioSwitch> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import { showError, showSuccess } from '@nextcloud/dialogs' | ||
import { t } from '@nextcloud/l10n' | ||
|
||
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js' | ||
|
||
export default { | ||
name: 'SecuritySettings', | ||
|
||
components: { | ||
NcCheckboxRadioSwitch, | ||
}, | ||
|
||
data() { | ||
return { | ||
isEncryptionLoading: false, | ||
} | ||
}, | ||
|
||
computed: { | ||
token() { | ||
return this.$store.getters.getToken() | ||
}, | ||
|
||
conversation() { | ||
return this.$store.getters.conversation(this.token) || this.$store.getters.dummyConversation | ||
}, | ||
|
||
hasEncryptionEnabled() { | ||
return this.conversation.encrypted || false | ||
}, | ||
}, | ||
|
||
methods: { | ||
t, | ||
async toggleSetting() { | ||
const enabled = !this.conversation.encrypted | ||
try { | ||
await this.$store.dispatch('setEncryptionEnabled', { | ||
token: this.token, | ||
enabled, | ||
}) | ||
if (this.conversation.encrypted) { | ||
showSuccess(t('spreed', 'End-to-end encryption is now enabled')) | ||
} else { | ||
showSuccess(t('spreed', 'End-to-end encryption is now disabled')) | ||
} | ||
} catch (e) { | ||
// TODO check "precondition failed" | ||
if (!this.conversation.encrypted) { | ||
console.error('Error occurred when enabling end-to-end encryption', e) | ||
showError(t('spreed', 'Error occurred when enabling end-to-end encryption')) | ||
} else { | ||
console.error('Error occurred when disabling end-to-end encryption', e) | ||
showError(t('spreed', 'Error occurred when disabling end-to-end encryption')) | ||
} | ||
} | ||
}, | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.