Skip to content
Merged
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
fix: allow to add e-mail guests when creating a conversation
- introduce 'forceTypes' in autocomplete request

Signed-off-by: Maksim Sukharev <[email protected]>
  • Loading branch information
Antreesy authored and backportbot[bot] committed Nov 6, 2024
commit 58122e1e9238992cdc3d8b432c9091120d2f84e8
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ import DialpadPanel from '../UIShared/DialpadPanel.vue'
import TransitionWrapper from '../UIShared/TransitionWrapper.vue'

import { useArrowNavigation } from '../../composables/useArrowNavigation.js'
import { SHARE } from '../../constants.js'
import { autocompleteQuery } from '../../services/coreService.ts'
import CancelableRequest from '../../utils/cancelableRequest.js'

Expand Down Expand Up @@ -208,7 +209,11 @@ 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: 'new',
forceTypes: [SHARE.TYPE.EMAIL], // e-mail guests are allowed directly after conversation creation
})

this.searchResults = response?.data?.ocs?.data || []
if (this.searchResults.length === 0) {
Expand Down
8 changes: 5 additions & 3 deletions src/services/coreService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type SearchPayload = {
searchText: string
token?: string | 'new'
onlyUsers?: boolean
forceTypes?: typeof SHARE.TYPE[keyof typeof SHARE.TYPE][]
}

/**
Expand All @@ -26,18 +27,19 @@ type SearchPayload = {
* @param payload.searchText The string that will be used in the search query.
* @param [payload.token] The token of the conversation (if any) | 'new' for new conversations
* @param [payload.onlyUsers] Whether to return only registered users
* @param [payload.forceTypes] Whether to force some types to be included in query
* @param options options
*/
const autocompleteQuery = async function({ searchText, token = 'new', onlyUsers = false }: SearchPayload, options: object) {
const autocompleteQuery = async function({ searchText, token = 'new', onlyUsers = false, forceTypes = [] }: SearchPayload, options: object) {
const shareTypes = onlyUsers
? [SHARE.TYPE.USER]
? [SHARE.TYPE.USER].concat(forceTypes)
: [
SHARE.TYPE.USER,
SHARE.TYPE.GROUP,
SHARE.TYPE.CIRCLE,
token !== 'new' ? SHARE.TYPE.EMAIL : null,
canInviteToFederation ? SHARE.TYPE.REMOTE : null,
].filter(type => type !== null)
].filter(type => type !== null).concat(forceTypes)

return axios.get(generateOcsUrl('core/autocomplete/get'), {
...options,
Expand Down