diff --git a/packages/api-client/src/auth/AuthAPI.ts b/packages/api-client/src/auth/AuthAPI.ts index 8ae52d1154..fa4983d780 100644 --- a/packages/api-client/src/auth/AuthAPI.ts +++ b/packages/api-client/src/auth/AuthAPI.ts @@ -41,6 +41,7 @@ export class AuthAPI { LOGIN: '/login', LOGOUT: 'logout', REGISTER: '/register', + REMOVE: 'remove', SELF: 'self', SEND: 'send', SSO: '/sso', @@ -68,7 +69,7 @@ export class AuthAPI { password, }, method: 'post', - url: `${AuthAPI.URL.COOKIES}/remove`, + url: `${AuthAPI.URL.COOKIES}/${AuthAPI.URL.REMOVE}`, withCredentials: true, }; diff --git a/packages/api-client/src/client/ClientAPI.ts b/packages/api-client/src/client/ClientAPI.ts index 82666a93cd..df2996a943 100644 --- a/packages/api-client/src/client/ClientAPI.ts +++ b/packages/api-client/src/client/ClientAPI.ts @@ -31,6 +31,7 @@ export class ClientAPI { public static readonly URL = { CLIENTS: '/clients', CAPABILITIES: 'capabilities', + PREKEYS: 'prekeys', }; public async postClient(newClient: NewClient): Promise { @@ -108,7 +109,7 @@ export class ClientAPI { public async getClientPreKeys(clientId: string): Promise { const config: AxiosRequestConfig = { method: 'get', - url: `${ClientAPI.URL.CLIENTS}/${clientId}/prekeys`, + url: `${ClientAPI.URL.CLIENTS}/${clientId}/${ClientAPI.URL.PREKEYS}`, }; const response = await this.client.sendJSON(config, true); diff --git a/packages/api-client/src/conversation/ConversationAPI.ts b/packages/api-client/src/conversation/ConversationAPI.ts index c5a677ced6..5cdcfc3449 100644 --- a/packages/api-client/src/conversation/ConversationAPI.ts +++ b/packages/api-client/src/conversation/ConversationAPI.ts @@ -34,6 +34,7 @@ import type { MessageSendingStatus, NewConversation, NewOTRMessage, + RemoteConversations, } from './'; import type { ConversationAccessUpdateEvent, @@ -73,8 +74,9 @@ export class ConversationAPI { CODE: 'code', CODE_CHECK: '/code-check', CONVERSATIONS: '/conversations', + IDS: 'ids', JOIN: '/join', - LIST_CONVERSATIONS: '/list-conversations', + LIST: 'list', MEMBERS: 'members', MESSAGE_TIMER: 'message-timer', MESSAGES: 'messages', @@ -207,6 +209,7 @@ export class ConversationAPI { * @param limit Max. number of IDs to return * @param conversationId Conversation ID to start from (exclusive) * @see https://staging-nginz-https.zinfra.io/swagger-ui/#!/conversations/conversationIds + * @deprecated Use `getListConversations()` instead. */ public async getConversationIds(limit: number, conversationId?: string): Promise { const config: AxiosRequestConfig = { @@ -215,7 +218,7 @@ export class ConversationAPI { size: limit, start: conversationId, }, - url: `${ConversationAPI.URL.CONVERSATIONS}/ids`, + url: `${ConversationAPI.URL.CONVERSATIONS}/${ConversationAPI.URL.IDS}`, }; const response = await this.client.sendJSON(config); @@ -237,18 +240,25 @@ export class ConversationAPI { } /** - * Get all remote conversations from a federated backend. - * @see https://staging-nginz-https.zinfra.io/api/swagger-ui/#/default/post_list_conversations + * Get conversation metadata for a list of conversation ids + * @see https://staging-nginz-https.zinfra.io/api/swagger-ui/#/default/post_conversations_list_v2 */ - public async getRemoteConversations(ownDomain: string): Promise { + public async getListConversations(): Promise { const config: AxiosRequestConfig = { - data: {}, method: 'post', - url: ConversationAPI.URL.LIST_CONVERSATIONS, + url: `${ConversationAPI.URL.CONVERSATIONS}/${ConversationAPI.URL.LIST}/${ConversationAPI.URL.V2}`, }; - const {data} = await this.client.sendJSON(config); - return data.conversations.filter(conversation => conversation.qualified_id?.domain !== ownDomain); + const {data} = await this.client.sendJSON(config); + return data; + } + + /** + * Get all remote conversations from a federated backend. + */ + public async getRemoteConversations(ownDomain: string): Promise { + const data = await this.getListConversations(); + return data.found?.filter(conversation => conversation.qualified_id?.domain !== ownDomain) || []; } /** diff --git a/packages/api-client/src/conversation/RemoteConversations.ts b/packages/api-client/src/conversation/RemoteConversations.ts new file mode 100644 index 0000000000..a0add47509 --- /dev/null +++ b/packages/api-client/src/conversation/RemoteConversations.ts @@ -0,0 +1,27 @@ +/* + * Wire + * Copyright (C) 2021 Wire Swiss GmbH + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + * + */ + +import {QualifiedId} from '../user/QualifiedId'; +import {Conversation} from './Conversation'; + +export interface RemoteConversations { + failed?: QualifiedId[]; + found?: Conversation[]; + not_found?: QualifiedId[]; +} diff --git a/packages/api-client/src/conversation/index.ts b/packages/api-client/src/conversation/index.ts index c831bf86b2..b5f65de994 100644 --- a/packages/api-client/src/conversation/index.ts +++ b/packages/api-client/src/conversation/index.ts @@ -36,5 +36,6 @@ export * from './OtherMember'; export * from './OTRClientMap'; export * from './OTRRecipients'; export * from './QualifiedUserClients'; +export * from './RemoteConversations'; export * from './ServiceRef'; export * from './UserClients'; diff --git a/packages/api-client/src/user/UserAPI.ts b/packages/api-client/src/user/UserAPI.ts index 3aec85e4b8..2f312a2c82 100644 --- a/packages/api-client/src/user/UserAPI.ts +++ b/packages/api-client/src/user/UserAPI.ts @@ -52,6 +52,7 @@ export class UserAPI { BY_HANDLE: 'by-handle', CALLS: '/calls', CLIENTS: 'clients', + CONFIG: 'config', CONTACTS: 'contacts', DELETE: '/delete', HANDLES: 'handles', @@ -124,7 +125,7 @@ export class UserAPI { public async getCallsConfiguration(): Promise { const config: AxiosRequestConfig = { method: 'get', - url: `${UserAPI.URL.CALLS}/config`, + url: `${UserAPI.URL.CALLS}/${UserAPI.URL.CONFIG}`, }; const response = await this.client.sendJSON(config);