Skip to content

Commit

Permalink
fix: use talk-message-current instead
Browse files Browse the repository at this point in the history
Signed-off-by: Dorra Jaouad <[email protected]>
  • Loading branch information
DorraJaouad committed Jan 16, 2025
1 parent 22cc5f2 commit 572fb3d
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 47 deletions.
5 changes: 4 additions & 1 deletion src/components/RightSidebar/RightSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,10 @@ export default {

sidebarTitle() {
return this.showSearchMessagesTab
? t('spreed', 'Search in {name}', { name: this.conversation.displayName })
? t('spreed', 'Search in {name}', { name: this.conversation.displayName }, undefined, {
escape: false,
sanitize: false,
})
: this.conversation.displayName
}
},
Expand Down
46 changes: 12 additions & 34 deletions src/components/RightSidebar/SearchMessages/SearchMessagesTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,45 +31,22 @@ import TransitionWrapper from '../../UIShared/TransitionWrapper.vue'

import { useIsInCall } from '../../../composables/useIsInCall.js'
import { useStore } from '../../../composables/useStore.js'
import { ATTENDEE } from '../../../constants.js'
import { searchMessages } from '../../../services/coreService.ts'
import { EventBus } from '../../../services/EventBus.ts'
import {
CoreUnifiedSearchResultEntry,
UserFilterObject,
} from '../../../types/index.ts'
import CancelableRequest from '../../../utils/cancelableRequest.js'

type UserFilterObject = {
id: string
displayName: string
isNoUser: boolean
user: string
disableMenu: boolean
showUserStatus: boolean
}

type MessageSearchResultAttributes = {
conversation: string
messageId: string
actorType: string
actorId: string
timestamp: string
}

type MessageSearchResultEntry = {
subline: string
thumbnailUrl: string
title: string
resourceUrl: string
icon: string
rounded: boolean
attributes: MessageSearchResultAttributes
to: Route
}

const emit = defineEmits<{
(event: 'close'): void
}>()

const searchBox = ref(null)
const isFocused = ref(false)
const searchResults = ref<MessageSearchResultEntry[]>([])
const searchResults = ref<(CoreUnifiedSearchResultEntry & {to: Route})[]>([])
const searchText = ref('')
const fromUser = ref<UserFilterObject | null>(null)
const sinceDate = ref<Date | null>(null)
Expand All @@ -87,6 +64,7 @@ const token = computed(() => store.getters.getToken())
const participantsInitialised = computed(() => store.getters.participantsInitialised(token.value))
const participants = computed<UserFilterObject>(() => {
return store.getters.participantsList(token.value)
.filter(({ actorType }) => actorType === ATTENDEE.ACTOR_TYPE.USERS)
.map(({ actorId, displayName, actorType }: { actorId: string; displayName: string; actorType: string}) => ({
id: actorId,
displayName,
Expand Down Expand Up @@ -182,13 +160,13 @@ async function fetchSearchResults(isNew = true) {
return
}
const response = await request({
term: term.length !== 0 ? term : null,
term,
person: fromUser.value?.id,
since: sinceDate.value?.toISOString(),
until: untilDate.value?.toISOString(),
since: !isNaN(sinceDate.value) ? sinceDate.value?.toISOString() : null,
until: !isNaN(untilDate.value) ? untilDate.value?.toISOString() : null,
limit: searchLimit.value,
cursor: searchCursor.value || null,
conversation: token.value,
from: `/call/${token.value}`,
})

const data = response?.data?.ocs?.data
Expand All @@ -206,7 +184,7 @@ async function fetchSearchResults(isNew = true) {
}
}

searchResults.value = searchResults.value.concat(entries.map((entry : Omit<MessageSearchResultEntry, 'to'>) => {
searchResults.value = searchResults.value.concat(entries.map((entry : CoreUnifiedSearchResultEntry) => {
return {
...entry,
to: {
Expand Down
17 changes: 5 additions & 12 deletions src/services/coreService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { getTalkConfig, hasTalkFeature } from './CapabilitiesManager.ts'
import { SHARE } from '../constants.js'
import type {
TaskProcessingResponse,
UnifiedSearchResponse,
SearchMessagePayload,
} from '../types/index.ts'

const canInviteToFederation = hasTalkFeature('local', 'federation-v1')
Expand All @@ -23,15 +25,6 @@ type SearchPayload = {
forceTypes?: typeof SHARE.TYPE[keyof typeof SHARE.TYPE][]
}

type SearchMessagePayload = {
term: string,
person?: string,
since?: string,
until?: string,
cursor?: number,
limit?: number,
conversation?: string }

/**
* Fetch possible conversations
*
Expand Down Expand Up @@ -72,11 +65,11 @@ const deleteTaskById = async function(id: number, options?: object): Promise<nul
return axios.delete(generateOcsUrl('taskprocessing/task/{id}', { id }), options)
}

const searchMessages = async function(params: SearchMessagePayload, options: object) {
return axios.get(generateOcsUrl('search/providers/talk-message/search'), {
const searchMessages = async function(params: SearchMessagePayload, options: object): UnifiedSearchResponse {
return axios.get(generateOcsUrl('search/providers/talk-message-current/search'), {
...options,
params,
}).catch(() => {})
})
}

export {
Expand Down
46 changes: 46 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,49 @@ export type setSipSettingsParams = Required<operations['settings-setsip-settings
export type setSipSettingsResponse = ApiResponse<operations['settings-setsip-settings']['responses'][200]['content']['application/json']>
export type setUserSettingsParams = Required<operations['settings-set-user-setting']>['requestBody']['content']['application/json']
export type setUserSettingsResponse = ApiResponse<operations['settings-set-user-setting']['responses'][200]['content']['application/json']>

// Unified Search
export type MessageSearchResultAttributes = {
conversation: string
messageId: string
actorType: string
actorId: string
timestamp: string
}

export type CoreUnifiedSearchResultEntry = {
thumbnailUrl: string;
title: string;
subline: string;
resourceUrl: string;
icon: string;
rounded: boolean;
attributes: MessageSearchResultAttributes;
}

export type UserFilterObject = {
id: string
displayName: string
isNoUser: boolean
user: string
disableMenu: boolean
showUserStatus: boolean
}

export type CoreUnifiedSearchResult = {
name: string;
isPaginated: boolean;
entries: CoreUnifiedSearchResultEntry[];
cursor: number | string | null;
}
export type UnifiedSearchResponse = ApiResponseUnwrapped<CoreUnifiedSearchResult>

export type SearchMessagePayload = {
term: string,
person?: string,
since?: string,
until?: string,
cursor?: number,
limit?: number,
from?: string
}

0 comments on commit 572fb3d

Please sign in to comment.