Introduce a privacy settings for the read_status

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2020-09-25 11:50:04 +02:00
Родитель b672400bf0
Коммит 4ebae32362
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 7076EA9751AACDDA
8 изменённых файлов: 144 добавлений и 10 удалений

Просмотреть файл

@ -26,6 +26,7 @@ declare(strict_types=1);
namespace OCA\Talk\Controller;
use OCA\Files_Sharing\SharedStorage;
use OCA\Talk\Participant;
use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\OCSController;
@ -103,6 +104,11 @@ class SettingsController extends OCSController {
return false;
}
if ($setting === 'read_status_privacy') {
return $value === Participant::PRIVACY_PUBLIC ||
$value === Participant::PRIVACY_PRIVATE;
}
return false;
}

Просмотреть файл

@ -48,6 +48,9 @@ class Participant {
public const NOTIFY_MENTION = 2;
public const NOTIFY_NEVER = 3;
public const PRIVACY_PRIVATE = 'private';
public const PRIVACY_PUBLIC = 'public';
/** @var Room */
protected $room;
/** @var Attendee */

Просмотреть файл

@ -87,6 +87,11 @@ trait TInitialState {
$appManager->isEnabledForUser('circles', $user)
);
$this->initialStateService->provideInitialState(
'talk', 'read_status_privacy',
$this->serverConfig->getUserValue($user->getUID(), 'spreed', 'read_status_privacy', Participant::PRIVACY_PUBLIC)
);
$attachmentFolder = $this->talkConfig->getAttachmentFolder($user->getUID());
if ($attachmentFolder) {
@ -127,6 +132,11 @@ trait TInitialState {
false
);
$this->initialStateService->provideInitialState(
'talk', 'read_status_privacy',
Participant::PRIVACY_PUBLIC
);
$this->initialStateService->provideInitialState(
'talk', 'attachment_folder',
''

Просмотреть файл

@ -38,6 +38,17 @@
:disabled="attachmentFolderLoading"
@click="selectAttachmentFolder">
</AppSettingsSection>
<AppSettingsSection v-if="!isGuest"
:title="t('spreed', 'Privacy')"
class="app-settings-section">
<input id="read_status_privacy"
:checked="readStatusPrivacyIsPublic"
type="checkbox"
name="read_status_privacy"
class="checkbox"
@change="toggleReadStatusPrivacy">
<label for="read_status_privacy">{{ t('spreed', 'Share my read-status and show the read-status of others') }}</label>
</AppSettingsSection>
<AppSettingsSection :title="t('spreed', 'Keyboard shortcuts')">
<p>{{ t('spreed', 'Speed up your Talk experience with these quick shortcuts.') }}</p>
@ -95,7 +106,11 @@
<script>
import { getFilePickerBuilder, showError } from '@nextcloud/dialogs'
import { setAttachmentFolder } from '../../services/settingsService'
import {
setAttachmentFolder,
setReadStatusPrivacy,
} from '../../services/settingsService'
import { PRIVACY } from '../../constants'
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import MediaDevicesPreview from '../MediaDevicesPreview'
import AppSettingsDialog from '@nextcloud/vue/dist/Components/AppSettingsDialog'
@ -129,6 +144,14 @@ export default {
isGuest() {
return !this.$store.getters.getUserId()
},
readStatusPrivacyIsPublic() {
return this.readStatusPrivacy === PRIVACY.PUBLIC
},
readStatusPrivacy() {
return this.$store.getters.getReadStatusPrivacy()
},
},
mounted() {
@ -167,6 +190,20 @@ export default {
})
},
async toggleReadStatusPrivacy() {
let newPrivacy = PRIVACY.PUBLIC
if (this.readStatusPrivacyIsPublic) {
newPrivacy = PRIVACY.PRIVATE
}
try {
this.$store.commit('updateReadStatusPrivacy', newPrivacy)
await setReadStatusPrivacy(newPrivacy)
} catch (exception) {
showError(t('spreed', 'Error while setting read status privacy'))
}
},
handleShowSettings() {
this.showSettings = true
},

Просмотреть файл

@ -96,3 +96,7 @@ export const FLOW = {
ROOM_MENTION: 3,
},
}
export const PRIVACY = {
PRIVATE: 'private',
PUBLIC: 'public',
}

Просмотреть файл

@ -24,7 +24,7 @@ import axios from '@nextcloud/axios'
import { generateOcsUrl } from '@nextcloud/router'
/**
* Gets the conversation token for a given file id
* Sets the attachment folder setting for the user
*
* @param {string} path The name of the folder
* @returns {Object} The axios response
@ -36,6 +36,19 @@ const setAttachmentFolder = async function(path) {
})
}
/**
* Sets the read status privacy setting for the user
*
* @param {string} privacy The selected value, either 'private' or 'public'
* @returns {Object} The axios response
*/
const setReadStatusPrivacy = async function(privacy) {
return axios.post(generateOcsUrl('apps/spreed/api/v1/settings', 2) + 'user', {
key: 'read_status_privacy',
value: privacy,
})
}
/**
* Save the SIP settings
*
@ -54,5 +67,6 @@ const setSIPSettings = async function(sipGroups, sharedSecret, dialInInfo) {
export {
setAttachmentFolder,
setReadStatusPrivacy,
setSIPSettings,
}

Просмотреть файл

@ -23,18 +23,19 @@
import Vue from 'vue'
import Vuex, { Store } from 'vuex'
import actorStore from './actorStore'
import callViewStore from './callViewStore'
import conversationsStore from './conversationsStore'
import fileUploadStore from './fileUploadStore'
import guestNameStore from './guestNameStore'
import messagesStore from './messagesStore'
import newGroupConversationStore from './newGroupConversationStore'
import participantsStore from './participantsStore'
import quoteReplyStore from './quoteReplyStore'
import settingsStore from './settingsStore'
import sidebarStore from './sidebarStore'
import talkHashStore from './talkHashStore'
import tokenStore from './tokenStore'
import windowVisibilityStore from './windowVisibilityStore'
import fileUploadStore from './fileUploadStore'
import newGroupConversationStore from './newGroupConversationStore'
import callViewStore from './callViewStore'
import talkHashStore from './talkHashStore'
Vue.use(Vuex)
@ -43,18 +44,19 @@ const mutations = {}
export default new Store({
modules: {
actorStore,
callViewStore,
conversationsStore,
fileUploadStore,
guestNameStore,
messagesStore,
newGroupConversationStore,
participantsStore,
quoteReplyStore,
settingsStore,
sidebarStore,
talkHashStore,
tokenStore,
windowVisibilityStore,
fileUploadStore,
newGroupConversationStore,
callViewStore,
talkHashStore,
},
mutations,

Просмотреть файл

@ -0,0 +1,58 @@
/**
* @copyright Copyright (c) 2020 Joas Schilling <coding@schilljs.com>
*
* @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/>.
*
*/
import { loadState } from '@nextcloud/initial-state'
const state = {
readStatusPrivacy: loadState('talk', 'read_status_privacy'),
}
const getters = {
getReadStatusPrivacy: (state) => () => {
return state.readStatusPrivacy
},
}
const mutations = {
/**
* Updates the token
*
* @param {object} state current store state;
* @param {string} privacy The token of the active conversation
*/
updateReadStatusPrivacy(state, privacy) {
state.readStatusPrivacy = privacy
},
}
const actions = {
/**
* Updates the token
*
* @param {object} context default store context;
* @param {string} privacy The new selected privacy
*/
updateReadStatusPrivacy(context, privacy) {
context.commit('updateReadStatusPrivacy', privacy)
},
}
export default { state, mutations, getters, actions }