@wireapp/core 20.7.2 → 21.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,22 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [21.0.0](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@20.7.2...@wireapp/core@21.0.0) (2022-01-18)
7
+
8
+
9
+ ### Features
10
+
11
+ * **core:** Send availability status only to directly connected members ([#4213](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/issues/4213)) ([73bad2f](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/commit/73bad2fb8f75a473b686fa9273b1c03774afd5c7))
12
+
13
+
14
+ ### BREAKING CHANGES
15
+
16
+ * **core:** the setAvailability of the user service will by default now only send to directly connected users. To send to absolutely all the users in the team call `setAvailability` with the `{sendAll: true}` option
17
+
18
+
19
+
20
+
21
+
6
22
  ## [20.7.2](https://github.com/wireapp/wire-web-packages/tree/main/packages/core/compare/@wireapp/core@20.7.1...@wireapp/core@20.7.2) (2022-01-12)
7
23
 
8
24
  **Note:** Version bump only for package @wireapp/core
package/package.json CHANGED
@@ -69,6 +69,6 @@
69
69
  "test:project": "yarn dist && yarn test",
70
70
  "test:node": "nyc jasmine --config=jasmine.json"
71
71
  },
72
- "version": "20.7.2",
73
- "gitHead": "57da347406b301aa1d3ea80ab6b53c9740a645ff"
72
+ "version": "21.0.0",
73
+ "gitHead": "0c11c749cae20f3a86839385aeb8486170598339"
74
74
  }
@@ -8,6 +8,13 @@ export declare class BroadcastService {
8
8
  private readonly cryptographyService;
9
9
  private readonly messageService;
10
10
  constructor(apiClient: APIClient, cryptographyService: CryptographyService);
11
- getPreKeyBundlesFromTeam(teamId: string, skipOwnClients?: boolean): Promise<UserPreKeyBundleMap>;
11
+ /**
12
+ * Will create a key bundle for all the users of the team
13
+ *
14
+ * @param teamId
15
+ * @param skipOwnClients=false
16
+ * @param onlyDirectConnections=false Will generate a bundle only for directly connected users (users the self user has conversation with). Allows avoiding broadcasting messages to too many people
17
+ */
18
+ getPreKeyBundlesFromTeam(teamId: string, skipOwnClients?: boolean, onlyDirectConnections?: boolean): Promise<UserPreKeyBundleMap>;
12
19
  broadcastGenericMessage(genericMessage: GenericMessage, recipients: UserPreKeyBundleMap | UserClients, sendAsProtobuf?: boolean): Promise<ClientMismatch>;
13
20
  }
@@ -27,9 +27,20 @@ class BroadcastService {
27
27
  this.cryptographyService = cryptographyService;
28
28
  this.messageService = new MessageService_1.MessageService(this.apiClient, this.cryptographyService);
29
29
  }
30
- async getPreKeyBundlesFromTeam(teamId, skipOwnClients = false) {
31
- const { members: teamMembers } = await this.apiClient.teams.member.api.getAllMembers(teamId);
32
- let members = teamMembers.map(member => ({ id: member.user }));
30
+ /**
31
+ * Will create a key bundle for all the users of the team
32
+ *
33
+ * @param teamId
34
+ * @param skipOwnClients=false
35
+ * @param onlyDirectConnections=false Will generate a bundle only for directly connected users (users the self user has conversation with). Allows avoiding broadcasting messages to too many people
36
+ */
37
+ async getPreKeyBundlesFromTeam(teamId, skipOwnClients = false, onlyDirectConnections = false) {
38
+ const teamMembers = onlyDirectConnections
39
+ ? (await this.apiClient.conversation.api.getConversations()).conversations
40
+ .map(({ members }) => members.others.map(user => user.id).concat(members.self.id))
41
+ .flat()
42
+ : (await this.apiClient.teams.member.api.getAllMembers(teamId)).members.map(({ user }) => user);
43
+ let members = Array.from(new Set(teamMembers)).map(member => ({ id: member }));
33
44
  if (skipOwnClients) {
34
45
  const selfUser = await this.apiClient.self.api.getSelf();
35
46
  members = members.filter(member => member.id !== selfUser.id);
@@ -11,5 +11,15 @@ export declare class UserService {
11
11
  constructor(apiClient: APIClient, broadcastService: BroadcastService, conversationService: ConversationService, connectionService: ConnectionService);
12
12
  getUser(userId: string | QualifiedId): Promise<User>;
13
13
  getUsers(userIds: string[] | QualifiedId[]): Promise<User[]>;
14
- setAvailability(teamId: string, type: AvailabilityType, sendAsProtobuf?: boolean): Promise<void>;
14
+ /**
15
+ * Sends a availability update to members of the same team
16
+ * @param teamId
17
+ * @param type
18
+ * @param options.sendAll=false will broadcast the message to all the members of the team (instead of just direct connections). Should be avoided in a big team
19
+ * @param options.sendAsProtobuf=false
20
+ */
21
+ setAvailability(teamId: string, type: AvailabilityType, { sendAll, sendAsProtobuf }: {
22
+ sendAll: boolean;
23
+ sendAsProtobuf?: boolean;
24
+ }): Promise<void>;
15
25
  }
@@ -44,9 +44,16 @@ class UserService {
44
44
  ? this.apiClient.user.api.postListUsers({ qualified_ids: userIds })
45
45
  : this.apiClient.user.api.getUsers({ ids: userIds });
46
46
  }
47
- async setAvailability(teamId, type, sendAsProtobuf) {
47
+ /**
48
+ * Sends a availability update to members of the same team
49
+ * @param teamId
50
+ * @param type
51
+ * @param options.sendAll=false will broadcast the message to all the members of the team (instead of just direct connections). Should be avoided in a big team
52
+ * @param options.sendAsProtobuf=false
53
+ */
54
+ async setAvailability(teamId, type, { sendAll = false, sendAsProtobuf = false }) {
48
55
  // Get pre-key bundles for members of your own team
49
- const preKeyBundlesFromTeam = await this.broadcastService.getPreKeyBundlesFromTeam(teamId);
56
+ const preKeyBundlesFromTeam = await this.broadcastService.getPreKeyBundlesFromTeam(teamId, false, !sendAll);
50
57
  // Get pre-key bundles for all of your other 1:1 connections
51
58
  const connections = await this.connectionService.getConnections();
52
59
  const acceptedConnections = connections.filter(connection => connection.status === connection_1.ConnectionStatus.ACCEPTED);