Fix Talk conversation creation with NC22

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2021-07-09 20:15:07 +02:00
parent b21dcf90ef
commit c28f61c63f
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
5 changed files with 24 additions and 5 deletions

View File

@ -139,6 +139,7 @@ class PublicViewController extends Controller {
$this->initialStateService->provideInitialState($this->appName, 'show_week_numbers', ($defaultWeekNumbers === 'yes'));
$this->initialStateService->provideInitialState($this->appName, 'skip_popover', ($defaultSkipPopover === 'yes'));
$this->initialStateService->provideInitialState($this->appName, 'talk_enabled', false);
$this->initialStateService->provideInitialState($this->appName, 'talk_api_version', 'v1');
$this->initialStateService->provideInitialState($this->appName, 'timezone', $defaultTimezone);
$this->initialStateService->provideInitialState($this->appName, 'slot_duration', $defaultSlotDuration);
$this->initialStateService->provideInitialState($this->appName, 'default_reminder', $defaultDefaultReminder);

View File

@ -110,6 +110,7 @@ class ViewController extends Controller {
$showTasks = $this->config->getUserValue($this->userId, $this->appName, 'showTasks', $defaultShowTasks) === 'yes';
$talkEnabled = $this->appManager->isEnabledForUser('spreed');
$talkApiVersion = version_compare($this->appManager->getAppVersion('spreed'), '12.0.0', '>=') ? 'v4' : 'v1';
$tasksEnabled = $this->appManager->isEnabledForUser('tasks');
$this->initialStateService->provideInitialState($this->appName, 'app_version', $appVersion);
@ -120,6 +121,7 @@ class ViewController extends Controller {
$this->initialStateService->provideInitialState($this->appName, 'show_week_numbers', $showWeekNumbers);
$this->initialStateService->provideInitialState($this->appName, 'skip_popover', $skipPopover);
$this->initialStateService->provideInitialState($this->appName, 'talk_enabled', $talkEnabled);
$this->initialStateService->provideInitialState($this->appName, 'talk_api_version', $talkApiVersion);
$this->initialStateService->provideInitialState($this->appName, 'timezone', $timezone);
$this->initialStateService->provideInitialState($this->appName, 'slot_duration', $slotDuration);
$this->initialStateService->provideInitialState($this->appName, 'default_reminder', $defaultReminder);

View File

@ -23,6 +23,7 @@
import HTTPClient from '@nextcloud/axios'
import { translate as t } from '@nextcloud/l10n'
import { generateUrl, generateOcsUrl } from '@nextcloud/router'
import { loadState } from '@nextcloud/initial-state'
/**
* Creates a new public talk room
@ -31,9 +32,10 @@ import { generateUrl, generateOcsUrl } from '@nextcloud/router'
* @returns {Promise<String>}
*/
export async function createTalkRoom(eventTitle = null) {
const apiVersion = loadState('calendar', 'talk_api_version')
let response
try {
response = await HTTPClient.post(generateOcsUrl('apps/spreed/api/v1/', 2) + 'room', {
response = await HTTPClient.post(generateOcsUrl('apps/spreed/api/' + apiVersion + '/', 2) + 'room', {
roomType: 3,
roomName: eventTitle || t('calendar', 'Chat room for event'),
})

View File

@ -101,7 +101,7 @@ class PublicViewControllerTest extends TestCase {
->with('imagePath456')
->willReturn('absoluteImagePath456');
$this->initialStateService->expects(self::exactly(13))
$this->initialStateService
->method('provideInitialState')
->withConsecutive(
['calendar', 'app_version', '1.0.0'],
@ -112,6 +112,7 @@ class PublicViewControllerTest extends TestCase {
['calendar', 'show_week_numbers', true],
['calendar', 'skip_popover', true],
['calendar', 'talk_enabled', false],
['calendar', 'talk_api_version', 'v1'],
['calendar', 'timezone', 'defaultTimezone'],
['calendar', 'slot_duration', 'defaultSlotDuration'],
['calendar', 'default_reminder', 'defaultDefaultReminder'],
@ -177,7 +178,7 @@ class PublicViewControllerTest extends TestCase {
->with('imagePath456')
->willReturn('absoluteImagePath456');
$this->initialStateService->expects(self::exactly(13))
$this->initialStateService
->method('provideInitialState')
->withConsecutive(
['calendar', 'app_version', '1.0.0'],
@ -188,6 +189,7 @@ class PublicViewControllerTest extends TestCase {
['calendar', 'show_week_numbers', true],
['calendar', 'skip_popover', true],
['calendar', 'talk_enabled', false],
['calendar', 'talk_api_version', 'v1'],
['calendar', 'timezone', 'defaultTimezone'],
['calendar', 'slot_duration', 'defaultSlotDuration'],
['calendar', 'default_reminder', 'defaultDefaultReminder'],

View File

@ -102,6 +102,11 @@ class ViewControllerTest extends TestCase {
['spreed', null, true],
['tasks', null, true]
]);
$this->appManager
->method('getAppVersion')
->willReturnMap([
['spreed', true, '12.0.0'],
]);
$this->initialStateService
->method('provideInitialState')
@ -114,6 +119,7 @@ class ViewControllerTest extends TestCase {
['calendar', 'show_week_numbers', true],
['calendar', 'skip_popover', true],
['calendar', 'talk_enabled', true],
['calendar', 'talk_api_version', 'v4'],
['calendar', 'timezone', 'Europe/Berlin'],
['calendar', 'slot_duration', '00:15:00'],
['calendar', 'default_reminder', '00:10:00'],
@ -167,9 +173,14 @@ class ViewControllerTest extends TestCase {
$this->appManager
->method('isEnabledForUser')
->willReturnMap([
['spreed', null, true],
['spreed', null, false],
['tasks', null, false]
]);
$this->appManager
->method('getAppVersion')
->willReturnMap([
['spreed', true, '11.3.0'],
]);
$this->initialStateService
->method('provideInitialState')
@ -181,7 +192,8 @@ class ViewControllerTest extends TestCase {
['calendar', 'show_weekends', true],
['calendar', 'show_week_numbers', true],
['calendar', 'skip_popover', true],
['calendar', 'talk_enabled', true],
['calendar', 'talk_enabled', false],
['calendar', 'talk_api_version', 'v1'],
['calendar', 'timezone', 'Europe/Berlin'],
['calendar', 'slot_duration', '00:15:00'],
['calendar', 'default_reminder', '00:10:00'],