diff options
author | Maksim Sukharev <antreesy.web@gmail.com> | 2024-01-29 11:12:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-29 11:12:27 +0100 |
commit | 68727365abde32f40e41f46c8655c229c602e5a2 (patch) | |
tree | 58ab313daa9ab9f09a009fa341abc52eaf70a7a8 | |
parent | 29592c29bdaac0b543b138933305b541f6ef75f1 (diff) | |
parent | 34596cc5adae05e83af888d5a14ac6bc77b9b41a (diff) |
Merge pull request #11462 from nextcloud/feat/11279/join-conversation-after-accept
feat(Federation): join conversation after accepting the invitation
-rw-r--r-- | src/App.vue | 71 |
1 files changed, 53 insertions, 18 deletions
diff --git a/src/App.vue b/src/App.vue index 8dfeebafb..2d1791814 100644 --- a/src/App.vue +++ b/src/App.vue @@ -41,6 +41,7 @@ import debounce from 'debounce' import PreventUnload from 'vue-prevent-unload' import { getCurrentUser } from '@nextcloud/auth' +import axios from '@nextcloud/axios' import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus' import { generateUrl } from '@nextcloud/router' @@ -519,26 +520,52 @@ export default { * @param {string} event.action.type The request type used for the action * @param {boolean} event.cancelAction Option to cancel the action so no page reload is happening */ - interceptNotificationActions(event) { - if (event.notification.app !== 'spreed' || event.action.type !== 'WEB') { + async interceptNotificationActions(event) { + if (event.notification.app !== 'spreed') { return } - const [, load] = event.action.url.split('/call/') - if (!load) { - return - } + switch (event.action.type) { + case 'WEB': { + const load = event.action.url.split('/call/').pop() + if (!load) { + return + } - const [token, hash] = load.split('#') - this.$router.push({ - name: 'conversation', - hash: hash ? `#${hash}` : '', - params: { - token, - }, - }) + const [token, hash] = load.split('#') + this.$router.push({ + name: 'conversation', + hash: hash ? `#${hash}` : '', + params: { + token, + }, + }) - event.cancelAction = true + event.cancelAction = true + break + } + case 'POST': { + // Federation invitation handling + if (event.notification.objectType === 'remote_talk_share') { + try { + const response = await axios.post(event.action.url) + this.$store.dispatch('addConversation', response.data.ocs.data) + this.$router.push({ + name: 'conversation', + params: { + token: response.data.ocs.data.token, + }, + }) + + event.cancelAction = true + } catch (error) { + console.error(error) + } + } + break + } + default: break + } }, /** @@ -553,7 +580,8 @@ export default { return } - if (event.notification.objectType === 'chat') { + switch (event.notification.objectType) { + case 'chat': { if (event.notification.subjectRichParameters?.reaction) { // Ignore reaction notifications in case of one-to-one and always-notify return @@ -562,12 +590,19 @@ export default { this.$store.dispatch('updateConversationLastMessageFromNotification', { notification: event.notification, }) + break } - - if (event.notification.objectType === 'call') { + case 'call': { this.$store.dispatch('updateCallStateFromNotification', { notification: event.notification, }) + break + } + // Federation invitation handling + case 'remote_talk_share': { + break + } + default: break } }, |