Skip to content

Commit

Permalink
fix: allow to add e-mail guests when creating a conversation
Browse files Browse the repository at this point in the history
- introduce 'pending' token in autocomplete request
- make conversation public automatically
- show toast about invitations sent

Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy committed Nov 5, 2024
1 parent f52f5ff commit d595f91
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,10 @@ export default {
const { request, cancel } = CancelableRequest(autocompleteQuery)
this.cancelSearchPossibleConversations = cancel
const response = await request({ searchText: this.searchText })
const response = await request({
searchText: this.searchText,
token: 'pending',
})
this.searchResults = response?.data?.ocs?.data || []
if (this.searchResults.length === 0) {
Expand Down
11 changes: 9 additions & 2 deletions src/components/NewConversationDialog/NewConversationDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ import { provide, ref } from 'vue'
import AlertCircle from 'vue-material-design-icons/AlertCircle.vue'
import Check from 'vue-material-design-icons/Check.vue'
import { showSuccess } from '@nextcloud/dialogs'
import { t } from '@nextcloud/l10n'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
Expand All @@ -121,7 +122,7 @@ import LoadingComponent from '../LoadingComponent.vue'
import { useId } from '../../composables/useId.ts'
import { useIsInCall } from '../../composables/useIsInCall.js'
import { CONVERSATION } from '../../constants.js'
import { ATTENDEE, CONVERSATION } from '../../constants.js'
import { setConversationPassword } from '../../services/conversationsService.js'
import { addParticipant } from '../../services/participantsService.js'
import { copyConversationLinkToClipboard } from '../../utils/handleUrl.ts'
Expand Down Expand Up @@ -293,9 +294,11 @@ export default {
this.page = 2
try {
const emailParticipants = this.selectedParticipants.filter(participant => participant?.source === ATTENDEE.ACTOR_TYPE.EMAILS)
this.newConversation.token = await this.$store.dispatch('createGroupConversation', {
conversationName: this.conversationName,
isPublic: this.isPublic,
isPublic: this.isPublic || emailParticipants.length,
})
// Gather all secondary requests to run in parallel
Expand Down Expand Up @@ -328,6 +331,10 @@ export default {
}
await Promise.all(promises)
for (const participant of emailParticipants) {
showSuccess(t('spreed', 'Invitation was sent to {actorId}', { actorId: participant.id }))
}
} catch (exception) {
console.error('Error creating new conversation: ', exception)
this.isLoading = false
Expand Down
8 changes: 5 additions & 3 deletions src/services/coreService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const canInviteToFederation = hasTalkFeature('local', 'federation-v1')

type SearchPayload = {
searchText: string
token?: string
token?: string | 'new' | 'pending'
onlyUsers?: boolean
}

Expand All @@ -24,7 +24,8 @@ type SearchPayload = {
*
* @param payload the wrapping object;
* @param payload.searchText The string that will be used in the search query.
* @param [payload.token] The token of the conversation (if any), or "new" for a new one
* @param [payload.token] The token of the conversation (if any)
* | 'new' for new conversations | 'pending' for new, but token will be known by the time of using autocomplete results
* @param [payload.onlyUsers] Whether to return only registered users
* @param options options
*/
Expand All @@ -38,13 +39,14 @@ const autocompleteQuery = async function({ searchText, token = 'new', onlyUsers
token !== 'new' ? SHARE.TYPE.EMAIL : null,
canInviteToFederation ? SHARE.TYPE.REMOTE : null,
].filter(type => type !== null)
const itemId = token === 'pending' ? 'new' : token

return axios.get(generateOcsUrl('core/autocomplete/get'), {
...options,
params: {
search: searchText,
itemType: 'call',
itemId: token,
itemId,
shareTypes,
},
})
Expand Down

0 comments on commit d595f91

Please sign in to comment.