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
21 changes: 15 additions & 6 deletions lib/Settings/Admin/AdminSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,13 @@ protected function initGeneralSettings(): void {
}

protected function initAllowedGroups(): void {
$this->initialStateService->provideInitialState('talk', 'start_conversations', $this->talkConfig->getAllowedConversationsGroupIds());
$this->initialStateService->provideInitialState('talk', 'start_calls', (int) $this->serverConfig->getAppValue('spreed', 'start_calls', Room::START_CALL_EVERYONE));
$this->initialStateService->provideInitialState('talk', 'allowed_groups', $this->talkConfig->getAllowedTalkGroupIds());

$groups = $this->getGroupDetailsArray($this->talkConfig->getAllowedConversationsGroupIds());
$this->initialStateService->provideInitialState('talk', 'start_conversations', $groups);

$groups = $this->getGroupDetailsArray($this->talkConfig->getAllowedTalkGroupIds());
$this->initialStateService->provideInitialState('talk', 'allowed_groups', $groups);
}

protected function initCommands(): void {
Expand Down Expand Up @@ -475,7 +479,14 @@ protected function initRequestSignalingServerTrial(): void {
}

protected function initSIPBridge(): void {
$gids = $this->talkConfig->getSIPGroups();
$groups = $this->getGroupDetailsArray($this->talkConfig->getSIPGroups());

$this->initialStateService->provideInitialState('talk', 'sip_bridge_groups', $groups);
$this->initialStateService->provideInitialState('talk', 'sip_bridge_shared_secret', $this->talkConfig->getSIPSharedSecret());
$this->initialStateService->provideInitialState('talk', 'sip_bridge_dialin_info', $this->talkConfig->getDialInInfo());
}

protected function getGroupDetailsArray(array $gids): array {
$groups = [];
foreach ($gids as $gid) {
$group = $this->groupManager->get($gid);
Expand All @@ -487,9 +498,7 @@ protected function initSIPBridge(): void {
}
}

$this->initialStateService->provideInitialState('talk', 'sip_bridge_groups', $groups);
$this->initialStateService->provideInitialState('talk', 'sip_bridge_shared_secret', $this->talkConfig->getSIPSharedSecret());
$this->initialStateService->provideInitialState('talk', 'sip_bridge_dialin_info', $this->talkConfig->getDialInInfo());
return $groups;
}

/**
Expand Down
46 changes: 36 additions & 10 deletions src/components/AdminSettings/AllowedGroups.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
:loading="loadingGroups"
:show-no-options="false"
:close-on-select="false"
track-by="id"
label="displayname"
@search-change="searchGroup" />

<button class="button primary"
Expand All @@ -67,6 +69,8 @@
:loading="loadingGroups"
:show-no-options="false"
:close-on-select="false"
track-by="id"
label="displayname"
@search-change="searchGroup" />

<button class="button primary"
Expand Down Expand Up @@ -131,11 +135,26 @@ export default {

mounted() {
this.loading = true
this.allowedGroups = loadState('talk', 'allowed_groups')
this.canStartConversations = loadState('talk', 'start_conversations')
this.allowedGroups = loadState('talk', 'allowed_groups').sort(function(a, b) {
return a.displayname.localeCompare(b.displayname)
})
this.canStartConversations = loadState('talk', 'start_conversations').sort(function(a, b) {
return a.displayname.localeCompare(b.displayname)
})
this.startCalls = startCallOptions[parseInt(loadState('talk', 'start_calls'))]
this.groups = [...new Set(this.allowedGroups.concat(this.canStartConversations))].sort(function(a, b) {
return a.localeCompare(b)

// Make a unique list with the groups we know from allowedGroups and canStartConversations
// Unique checking is done by turning the group objects (with id and name)
// into json strings and afterwards back again
const mergedGroups = Array.from(
new Set(
this.allowedGroups.concat(this.canStartConversations)
.map(g => JSON.stringify(g))
)
).map(g => JSON.parse(g))

this.groups = mergedGroups.sort(function(a, b) {
return a.displayname.localeCompare(b.displayname)
})
this.loading = false

Expand All @@ -146,14 +165,13 @@ export default {
searchGroup: debounce(async function(query) {
this.loadingGroups = true
try {
const res = await axios.get(generateOcsUrl('cloud', 2) + 'groups', {
const response = await axios.get(generateOcsUrl('cloud', 2) + 'groups/details', {
search: query,
limit: 20,
offset: 0,
})
// remove duplicates and sort
this.groups = [...new Set(res.data.ocs.data.groups)].sort(function(a, b) {
return a.localeCompare(b)
this.groups = response.data.ocs.data.groups.sort(function(a, b) {
return a.displayname.localeCompare(b.displayname)
})
} catch (err) {
console.error('Could not fetch groups', err)
Expand All @@ -167,7 +185,11 @@ export default {
this.loadingGroups = true
this.saveLabelAllowedGroups = t('spreed', 'Saving …')

OCP.AppConfig.setValue('spreed', 'allowed_groups', JSON.stringify(this.allowedGroups), {
const groups = this.allowedGroups.map(group => {
return group.id
})

OCP.AppConfig.setValue('spreed', 'allowed_groups', JSON.stringify(groups), {
success: function() {
this.loading = false
this.loadingGroups = false
Expand All @@ -184,7 +206,11 @@ export default {
this.loadingGroups = true
this.saveLabelStartConversations = t('spreed', 'Saving …')

OCP.AppConfig.setValue('spreed', 'start_conversations', JSON.stringify(this.canStartConversations), {
const groups = this.canStartConversations.map(group => {
return group.id
})

OCP.AppConfig.setValue('spreed', 'start_conversations', JSON.stringify(groups), {
success: function() {
this.loading = false
this.loadingGroups = false
Expand Down