Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Handle duplicated sessions more gracefully with the internal signaling
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed May 29, 2020
commit a9bc1b6321411dc421c956b4750a779d6611d547
12 changes: 11 additions & 1 deletion lib/Controller/SignalingController.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,17 @@ public function pullMessages(string $token): DataResponse {
$data[] = ['type' => 'usersInRoom', 'data' => $this->getUsersInRoom($room, $pingTimestamp)];
} catch (RoomNotFoundException $e) {
$data[] = ['type' => 'usersInRoom', 'data' => []];
return new DataResponse($data, Http::STATUS_NOT_FOUND);

// Was the session killed or the complete conversation?
try {
$this->manager->getRoomForParticipantByToken($token, $this->userId);

// Session was killed, make the UI redirect to an error
return new DataResponse($data, Http::STATUS_CONFLICT);
} catch (RoomNotFoundException $e) {
// Complete conversation was killed, bye!
return new DataResponse($data, Http::STATUS_NOT_FOUND);
}
}

return new DataResponse($data);
Expand Down
30 changes: 29 additions & 1 deletion src/utils/signaling.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@ import { rejoinConversation } from '../services/participantsService'
import CancelableRequest from './cancelableRequest'
import { EventBus } from '../services/EventBus'
import axios from '@nextcloud/axios'
import { generateOcsUrl, generateUrl } from '@nextcloud/router'
import {
generateOcsUrl,
generateUrl,
} from '@nextcloud/router'
import {
showError,
showWarning,
} from '@nextcloud/dialogs'
import SessionStorage from '../services/SessionStorage'

const Signaling = {
Base: {},
Expand Down Expand Up @@ -431,6 +435,30 @@ Signaling.Internal.prototype._startPullingMessages = function() {
// User navigated away in the meantime. Ignore
} else if (axios.isCancel(error)) {
console.debug('Pulling messages request was cancelled')
} else if (error.response && error.response.status === 409) {
console.error('Session was killed but the conversation still exists')
this._trigger('pullMessagesStoppedOnFail')

OC.dialogs.confirmDestructive(
t('spreed', 'You joined the conversation in another window or device. This is currently not supported by Nextcloud Talk. What do you want to do?'),
t('spreed', 'Duplicate session'),
{
type: OC.dialogs.YES_NO_BUTTONS,
confirm: t('spreed', 'Restart here'),
confirmClasses: 'error',
cancel: t('spreed', 'Leave this page'),
},
decision => {
if (!decision) {
// Cancel
SessionStorage.removeItem('joined_conversation')
window.location = generateUrl('/apps/spreed')
} else {
// Confirm
window.location = generateUrl('call/' + token)
}
}
)
} else if (error.response && (error.response.status === 404 || error.response.status === 403)) {
console.error('Stop pulling messages because room does not exist or is not accessible')
this._trigger('pullMessagesStoppedOnFail')
Expand Down