-
Notifications
You must be signed in to change notification settings - Fork 60
[DRAFT] feat(talk): add "Join by link" action #1541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ShGKme
wants to merge
1
commit into
main
Choose a base branch
from
feat/open-link
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+151
−4
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
src/talk/renderer/TitleBar/components/OpenConversationLinkDialog.vue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| <!-- | ||
| - SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| - SPDX-License-Identifier: AGPL-3.0-or-later | ||
| --> | ||
|
|
||
| <script setup lang="ts"> | ||
| import axios from '@nextcloud/axios' | ||
| import { t } from '@nextcloud/l10n' | ||
| import { generateOcsUrl, generateUrl } from '@nextcloud/router' | ||
| import { ref, watch } from 'vue' | ||
| import NcDialog from '@nextcloud/vue/components/NcDialog' | ||
| import NcTextField from '@nextcloud/vue/components/NcTextField' | ||
| import { appData } from '../../../../app/AppData.js' | ||
| import { openConversation } from '../../TalkWrapper/talk.service.ts' | ||
| import { parseConversationToken } from '../../utils/parseConversationToken.ts' | ||
|
|
||
| const emit = defineEmits<{ | ||
| close: [] | ||
| }>() | ||
|
|
||
| const placeholder = generateUrl('/call/…', {}, { baseURL: appData.serverUrl! }) | ||
|
|
||
| const url = ref('') | ||
|
|
||
| const parsedToken = ref({ error: '', token: '' }) | ||
|
|
||
| watch(url, () => { | ||
| parsedToken.value = parseConversationToken(url.value) | ||
| }) | ||
|
|
||
| /** Handle prompt submit */ | ||
| async function onSubmit() { | ||
| if (!parsedToken.value.token) { | ||
| return false | ||
| } | ||
|
|
||
| try { | ||
| await axios.get(generateOcsUrl('/apps/spreed/api/v4/room/{token}', { token: parsedToken.value.token })) | ||
| } catch { | ||
| parsedToken.value = { error: t('talk_desktop', 'Conversation not found'), token: '' } | ||
| return false | ||
| } | ||
|
|
||
| await openConversation(parsedToken.value.token) | ||
| return true | ||
| } | ||
| </script> | ||
|
|
||
| <template> | ||
| <NcDialog | ||
| open | ||
| :name="t('talk_desktop', 'Open conversation link')" | ||
| size="normal" | ||
| :buttons="[{ | ||
| label: t('talk_desktop', 'Cancel'), | ||
| }, { | ||
| label: t('talk_desktop', 'Open'), | ||
| variant: 'primary', | ||
| type: 'submit', | ||
| disabled: !parsedToken.token, | ||
| callback: onSubmit, | ||
| }]" | ||
| close-on-click-outside | ||
| @close="emit('close')"> | ||
| <NcTextField | ||
| v-model="url" | ||
| :label="t('talk_desktop', 'Conversation URL')" | ||
| :placeholder | ||
| type="url" | ||
| :helper-text="parsedToken.error" | ||
| :success="!!parsedToken.token" | ||
| :error="!!parsedToken.error" | ||
| @keydown.enter="onSubmit" /> | ||
| </NcDialog> | ||
| </template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| /*! | ||
| * SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors | ||
| * SPDX-License-Identifier: AGPL-3.0-or-later | ||
| */ | ||
|
|
||
| import { t } from '@nextcloud/l10n' | ||
| import { appData } from '../../../app/AppData.js' | ||
| import { createURL } from '../../../shared/utils.ts' | ||
|
|
||
| /** | ||
| * Parse URL string to get current server conversation token or error message if invalid | ||
| * TODO: currently parsing error has messages for UI in the open conversation link dialog. | ||
| * TODO: when it is needed in other places - return error code and translate on the component | ||
| * | ||
| * @param maybeConversationUrl - URL | ||
| */ | ||
| export function parseConversationToken(maybeConversationUrl: string): { token: string, error: string } { | ||
| // No input - no output | ||
| if (!maybeConversationUrl) { | ||
| return { error: '', token: '' } | ||
| } | ||
|
|
||
| const url = createURL(maybeConversationUrl) | ||
| if (!url) { | ||
| return { error: t('talk_desktop', 'Invalid URL'), token: '' } | ||
| } | ||
|
|
||
| if (!maybeConversationUrl.startsWith(appData.serverUrl!)) { | ||
| return { error: t('talk_desktop', 'Opening conversations from other servers is not currently supported'), token: '' } | ||
| } | ||
|
|
||
| let pathname = maybeConversationUrl.slice((appData.serverUrl as unknown as string).length) | ||
| const indexPhp = pathname.indexOf('/index.php') | ||
| if (indexPhp === 0) { | ||
| pathname = pathname.slice('/index.php'.length) | ||
| } | ||
|
|
||
| const [isMatched, token] = pathname.match(/^\/call\/([a-z0-9]+)\/?$/i) ?? [false, ''] | ||
| if (!isMatched) { | ||
| return { error: t('talk_desktop', 'Invalid URL'), token: '' } | ||
| } | ||
|
|
||
| return { token, error: '' } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.