Skip to content

Commit 93d0f5e

Browse files
danielgerlagminnieliuMinnie Liu
authored
Feature/chat preview4 (Communication Identifier changes) (Azure#19404)
* update swagger * comm identifier changes * exception constructors * preview4 updates * update message types in README.md * markdown issue * updated CHANGELOG.md * PR feedback Co-authored-by: minnieliu <minnieliu96@hotmail.com> Co-authored-by: Minnie Liu <peiliu@microsoft.com>
1 parent 15f43be commit 93d0f5e

File tree

137 files changed

+5712
-5101
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+5712
-5101
lines changed

sdk/communication/azure-communication-chat/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
# Release History
22

33
## 1.0.0-beta.5 (Unreleased)
4+
### Breaking Changes
5+
6+
- ChatMessage - `senderId` renamed to `senderCommunicationIdentifier`, changed type to `CommunicationIdentifier`.
7+
- ChatMessageReadReceipt - `senderId` renamed to `senderCommunicationIdentifier`, changed type to `CommunicationIdentifier`.
8+
- ChatParticipant - `user` renamed to `communicationIdentifier`, changed type to `CommunicationIdentifier`.
9+
- ChatThread - `createdBy` renamed to `createdByCommunicationIdentifier`, changed type to `CommunicationIdentifier`.
10+
- ChatMessageContent - `initiator` renamed to `initiatorCommunicationIdentifier`, changed type to `CommunicationIdentifier`.
11+
412

513
## 1.0.0-beta.4 (2021-02-09)
614
### Breaking Changes

sdk/communication/azure-communication-chat/README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ The `ChatThread` object also contains the `getId()` method which retrieves the u
111111
List<ChatParticipant> participants = new ArrayList<ChatParticipant>();
112112

113113
ChatParticipant firstParticipant = new ChatParticipant()
114-
.setUser(user1)
114+
.setCommunicationIdentifier(user1)
115115
.setDisplayName("Participant Display Name 1");
116116

117117
ChatParticipant secondParticipant = new ChatParticipant()
118-
.setUser(user2)
118+
.setCommunicationIdentifier(user2)
119119
.setDisplayName("Participant Display Name 2");
120120

121121
participants.add(firstParticipant);
@@ -232,13 +232,15 @@ The original time of message creation can be accessed using `chatMessage.getCrea
232232

233233
listMessages returns different types of messages which can be identified by `chatMessage.getType()`. These types are:
234234

235-
-`Text`: Regular chat message sent by a thread member.
235+
- `text`: Regular chat message sent by a thread participant.
236236

237-
-`ThreadActivity/TopicUpdate`: System message that indicates the topic has been updated.
237+
- `html`: HTML chat message sent by a thread participant.
238238

239-
-`ThreadActivity/AddMember`: System message that indicates one or more participants have been added to the chat thread.
239+
- `topicUpdated`: System message that indicates the topic has been updated.
240240

241-
-`ThreadActivity/DeleteMember`: System message that indicates a participant has been removed from the chat thread.
241+
- `participantAdded`: System message that indicates one or more participants have been added to the chat thread.
242+
243+
- `participantRemoved`: System message that indicates a participant has been removed from the chat thread.
242244

243245
For more details, see [Message Types](https://docs.microsoft.com/azure/communication-services/concepts/chat/concepts#message-types).
244246

@@ -270,7 +272,7 @@ String chatMessageId = "Id";
270272
chatThreadClient.deleteMessage(chatMessageId);
271273
```
272274

273-
### Chat Thread Member Operations
275+
### Chat Thread Participant Operations
274276

275277
#### List chat participants
276278

@@ -283,7 +285,7 @@ chatParticipantsResponse.iterableByPage().forEach(resp -> {
283285
System.out.printf("Response headers are %s. Url %s and status code %d %n", resp.getHeaders(),
284286
resp.getRequest().getUrl(), resp.getStatusCode());
285287
resp.getItems().forEach(chatParticipant -> {
286-
System.out.printf("Participant id is %s.", chatParticipant.getUser().getId());
288+
System.out.printf("Participant id is %s.", ((CommunicationUserIdentifier) chatParticipant.getCommunicationIdentifier()).getId());
287289
});
288290
});
289291
```
@@ -293,7 +295,7 @@ chatParticipantsResponse.iterableByPage().forEach(resp -> {
293295
Use `addParticipants` method to add participants to the thread identified by threadId.
294296
`addChatParticipantsOptions` describes the request object containing the members to be added; Use `.setParticipants()` to set the participants to be added to the thread;
295297

296-
- `user`, required, is the CommunicationUser you've created by using the CommunicationIdentityClient. More info at: [Create A User](https://docs.microsoft.com/azure/communication-services/quickstarts/access-tokens?pivots=programming-language-java#create-a-user).
298+
- `communicationIdentifier`, required, is the CommunicationIdentifier you've created by using the CommunicationIdentityClient. More info at: [Create A User](https://docs.microsoft.com/azure/communication-services/quickstarts/access-tokens?pivots=programming-language-java#create-a-user).
297299
- `display_name`, optional, is the display name for the thread member.
298300
- `share_history_time`, optional, is the time from which the chat history is shared with the member. To share history since the inception of the chat thread, set this property to any date equal to, or less than the thread creation time. To share no history previous to when the member was added, set it to the current date. To share partial history, set it to the required date.
299301

@@ -302,11 +304,11 @@ Use `addParticipants` method to add participants to the thread identified by thr
302304
List<ChatParticipant> participants = new ArrayList<ChatParticipant>();
303305

304306
ChatParticipant firstParticipant = new ChatParticipant()
305-
.setUser(user1)
307+
.setCommunicationIdentifier(user1)
306308
.setDisplayName("Display Name 1");
307309

308310
ChatParticipant secondParticipant = new ChatParticipant()
309-
.setUser(user2)
311+
.setCommunicationIdentifier(user2)
310312
.setDisplayName("Display Name 2");
311313

312314
participants.add(firstParticipant);
@@ -320,7 +322,7 @@ chatThreadClient.addParticipants(addChatParticipantsOptions);
320322
#### Remove participant
321323

322324
Use `removeParticipant` method to remove a participant from the chat thread identified by chatThreadId.
323-
`user` is the CommunicationUser you've created.
325+
`identifier` is the CommunicationIdentifier you've created.
324326

325327
<!-- embedme ./src/samples/java/com/azure/communication/chat/ReadmeSamples.java#L251-L251 -->
326328
```Java

sdk/communication/azure-communication-chat/src/main/java/com/azure/communication/chat/ChatThreadAsyncClient.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.azure.communication.chat.implementation.converters.ChatMessageConverter;
1212
import com.azure.communication.chat.implementation.converters.ChatParticipantConverter;
1313
import com.azure.communication.chat.implementation.converters.ChatMessageReadReceiptConverter;
14+
import com.azure.communication.chat.implementation.converters.CommunicationIdentifierConverter;
1415
import com.azure.communication.chat.implementation.converters.SendChatMessageResultConverter;
1516
import com.azure.communication.chat.implementation.models.SendReadReceiptRequest;
1617
import com.azure.communication.chat.models.AddChatParticipantsOptions;
@@ -24,7 +25,7 @@
2425
import com.azure.communication.chat.models.SendChatMessageOptions;
2526
import com.azure.communication.chat.models.UpdateChatMessageOptions;
2627
import com.azure.communication.chat.models.UpdateChatThreadOptions;
27-
import com.azure.communication.common.CommunicationUserIdentifier;
28+
import com.azure.communication.common.CommunicationIdentifier;
2829
import com.azure.core.annotation.ReturnType;
2930
import com.azure.core.annotation.ServiceClient;
3031
import com.azure.core.annotation.ServiceMethod;
@@ -219,15 +220,15 @@ Mono<Response<AddChatParticipantsResult>> addParticipants(AddChatParticipantsOpt
219220
/**
220221
* Remove a participant from a thread.
221222
*
222-
* @param user User identity of the participant to remove from the thread.
223+
* @param identifier Identity of the participant to remove from the thread.
223224
* @return the completion.
224225
*/
225226
@ServiceMethod(returns = ReturnType.SINGLE)
226-
public Mono<Void> removeParticipant(CommunicationUserIdentifier user) {
227+
public Mono<Void> removeParticipant(CommunicationIdentifier identifier) {
227228
try {
228-
Objects.requireNonNull(user, "'user' cannot be null.");
229-
Objects.requireNonNull(user.getId(), "'user.getId()' cannot be null.");
230-
return withContext(context -> removeParticipant(user, context)
229+
Objects.requireNonNull(identifier, "'identifier' cannot be null.");
230+
231+
return withContext(context -> removeParticipant(identifier, context)
231232
.flatMap((Response<Void> res) -> {
232233
return Mono.empty();
233234
}));
@@ -240,15 +241,15 @@ public Mono<Void> removeParticipant(CommunicationUserIdentifier user) {
240241
/**
241242
* Remove a participant from a thread.
242243
*
243-
* @param user User identity of the participant to remove from the thread.
244+
* @param identifier Identity of the participant to remove from the thread.
244245
* @return the completion.
245246
*/
246247
@ServiceMethod(returns = ReturnType.SINGLE)
247-
public Mono<Response<Void>> removeParticipantWithResponse(CommunicationUserIdentifier user) {
248+
public Mono<Response<Void>> removeParticipantWithResponse(CommunicationIdentifier identifier) {
248249
try {
249-
Objects.requireNonNull(user, "'user' cannot be null.");
250-
Objects.requireNonNull(user.getId(), "'user.getId()' cannot be null.");
251-
return withContext(context -> removeParticipant(user, context));
250+
Objects.requireNonNull(identifier, "'identifier' cannot be null.");
251+
252+
return withContext(context -> removeParticipant(identifier, context));
252253
} catch (RuntimeException ex) {
253254
return monoError(logger, ex);
254255
}
@@ -257,14 +258,15 @@ public Mono<Response<Void>> removeParticipantWithResponse(CommunicationUserIdent
257258
/**
258259
* Remove a participant from a thread.
259260
*
260-
* @param user User identity of the participant to remove from the thread.
261+
* @param identifier Identity of the participant to remove from the thread.
261262
* @param context The context to associate with this operation.
262263
* @return the completion.
263264
*/
264-
Mono<Response<Void>> removeParticipant(CommunicationUserIdentifier user, Context context) {
265+
Mono<Response<Void>> removeParticipant(CommunicationIdentifier identifier, Context context) {
265266
context = context == null ? Context.NONE : context;
266267

267-
return this.chatThreadClient.removeChatParticipantWithResponseAsync(chatThreadId, user.getId(), context);
268+
return this.chatThreadClient.removeChatParticipantWithResponseAsync(
269+
chatThreadId, CommunicationIdentifierConverter.convert(identifier), context);
268270
}
269271

270272
/**

sdk/communication/azure-communication-chat/src/main/java/com/azure/communication/chat/ChatThreadClient.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import com.azure.communication.chat.models.ListReadReceiptOptions;
1313
import com.azure.communication.chat.models.SendChatMessageOptions;
1414
import com.azure.communication.chat.models.UpdateChatMessageOptions;
15-
import com.azure.communication.common.CommunicationUserIdentifier;
15+
import com.azure.communication.common.CommunicationIdentifier;
1616
import com.azure.core.annotation.ReturnType;
1717
import com.azure.core.annotation.ServiceClient;
1818
import com.azure.core.annotation.ServiceMethod;
@@ -132,25 +132,25 @@ public Response<AddChatParticipantsResult> addParticipantWithResponse(ChatPartic
132132
/**
133133
* Remove a participant from a thread.
134134
*
135-
* @param user User identity of the participant to remove from the thread.
135+
* @param identifier Identity of the participant to remove from the thread.
136136
* @param context The context to associate with this operation.
137137
* @return the completion.
138138
*/
139139
@ServiceMethod(returns = ReturnType.SINGLE)
140-
public Response<Void> removeParticipantWithResponse(CommunicationUserIdentifier user, Context context) {
140+
public Response<Void> removeParticipantWithResponse(CommunicationIdentifier identifier, Context context) {
141141

142-
return this.client.removeParticipant(user, context).block();
142+
return this.client.removeParticipant(identifier, context).block();
143143
}
144144

145145
/**
146146
* Remove a participant from a thread.
147147
*
148-
* @param user User identity of the thread participant to remove from the thread.
148+
* @param identifier Identity of the thread participant to remove from the thread.
149149
*/
150150
@ServiceMethod(returns = ReturnType.SINGLE)
151-
public void removeParticipant(CommunicationUserIdentifier user) {
151+
public void removeParticipant(CommunicationIdentifier identifier) {
152152

153-
this.client.removeParticipant(user).block();
153+
this.client.removeParticipant(identifier).block();
154154
}
155155

156156
/**

sdk/communication/azure-communication-chat/src/main/java/com/azure/communication/chat/implementation/AzureCommunicationChatServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public ChatImpl getChatClient() {
121121
this.httpPipeline = httpPipeline;
122122
this.serializerAdapter = serializerAdapter;
123123
this.endpoint = endpoint;
124-
this.apiVersion = "2020-11-01-preview3";
124+
this.apiVersion = "2021-01-27-preview4";
125125
this.chatThreadClient = new ChatThreadImpl(this);
126126
this.chatClient = new ChatImpl(this);
127127
}

0 commit comments

Comments
 (0)