Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion packages/api-client/src/auth/AuthAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class AuthAPI {
LOGIN: '/login',
LOGOUT: 'logout',
REGISTER: '/register',
REMOVE: 'remove',
SELF: 'self',
SEND: 'send',
SSO: '/sso',
Expand Down Expand Up @@ -68,7 +69,7 @@ export class AuthAPI {
password,
},
method: 'post',
url: `${AuthAPI.URL.COOKIES}/remove`,
url: `${AuthAPI.URL.COOKIES}/${AuthAPI.URL.REMOVE}`,
withCredentials: true,
};

Expand Down
3 changes: 2 additions & 1 deletion packages/api-client/src/client/ClientAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export class ClientAPI {
public static readonly URL = {
CLIENTS: '/clients',
CAPABILITIES: 'capabilities',
PREKEYS: 'prekeys',
};

public async postClient(newClient: NewClient): Promise<RegisteredClient> {
Expand Down Expand Up @@ -108,7 +109,7 @@ export class ClientAPI {
public async getClientPreKeys(clientId: string): Promise<PreKeyBundle> {
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<PreKeyBundle>(config, true);
Expand Down
28 changes: 19 additions & 9 deletions packages/api-client/src/conversation/ConversationAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import type {
MessageSendingStatus,
NewConversation,
NewOTRMessage,
RemoteConversations,
} from './';
import type {
ConversationAccessUpdateEvent,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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<ConversationIds> {
const config: AxiosRequestConfig = {
Expand All @@ -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<ConversationIds>(config);
Expand All @@ -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<Conversation[]> {
public async getListConversations(): Promise<RemoteConversations> {
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<Conversations>(config);
return data.conversations.filter(conversation => conversation.qualified_id?.domain !== ownDomain);
const {data} = await this.client.sendJSON<RemoteConversations>(config);
return data;
}

/**
* Get all remote conversations from a federated backend.
*/
public async getRemoteConversations(ownDomain: string): Promise<Conversation[]> {
const data = await this.getListConversations();
return data.found?.filter(conversation => conversation.qualified_id?.domain !== ownDomain) || [];
}

/**
Expand Down
27 changes: 27 additions & 0 deletions packages/api-client/src/conversation/RemoteConversations.ts
Original file line number Diff line number Diff line change
@@ -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[];
}
1 change: 1 addition & 0 deletions packages/api-client/src/conversation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
3 changes: 2 additions & 1 deletion packages/api-client/src/user/UserAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export class UserAPI {
BY_HANDLE: 'by-handle',
CALLS: '/calls',
CLIENTS: 'clients',
CONFIG: 'config',
CONTACTS: 'contacts',
DELETE: '/delete',
HANDLES: 'handles',
Expand Down Expand Up @@ -124,7 +125,7 @@ export class UserAPI {
public async getCallsConfiguration(): Promise<RTCConfiguration> {
const config: AxiosRequestConfig = {
method: 'get',
url: `${UserAPI.URL.CALLS}/config`,
url: `${UserAPI.URL.CALLS}/${UserAPI.URL.CONFIG}`,
};

const response = await this.client.sendJSON<RTCConfiguration>(config);
Expand Down