Skip to content

Commit 09244e7

Browse files
Add persistentId field in Message for common attribute
Add persistentId field in Message for common attribute
2 parents 8ef6b2b + 74fd5f2 commit 09244e7

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,11 +630,12 @@ open class TranscriptItem(
630630
id: String = "",
631631
timeStamp: String,
632632
override var contentType: String,
633-
override var serializedContent: String? = null
633+
override var serializedContent: String? = null,
634+
persistentId: String = ""
634635
)
635636
```
636637
* `id`
637-
* Id for the message. Unique to each message in the transcript.
638+
* Id for the message. Unique to each message in the transcript. Id can be used only for the ACPS APIs requests.
638639
* Type: `String`
639640
* `timeStamp`
640641
* Time when the message or event was sent. Formatted in ISO 8601 (e.g. `yyyy-MM-ddThh:mm:ss.SSSZ` or ` 2019-11-08T02:41:28.172Z`)
@@ -645,6 +646,9 @@ open class TranscriptItem(
645646
* `serializedContent`
646647
* The raw JSON format of the received WebSocket message
647648
* Type: Map of `String?`
649+
* `persistentId`
650+
* Id for the message, Unique to each message throughout chat session. This can be used only for tracking purposes by the client.
651+
* Type: `String`
648652

649653
--------
650654
### TranscriptData

chat-sdk/src/main/java/com/amazon/connect/chat/sdk/model/Message.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ data class Message(
3131
override var displayName: String? = null,
3232
override var messageDirection: MessageDirection? = null,
3333
var attachmentId: String? = null,
34-
override var metadata: MessageMetadataProtocol? = null
34+
override var metadata: MessageMetadataProtocol? = null,
35+
override var persistentId: String? = null,
3536
) : TranscriptItem(id, timeStamp, contentType, serializedContent), MessageProtocol {
3637

3738
val content: MessageContent?

chat-sdk/src/main/java/com/amazon/connect/chat/sdk/model/TranscriptItem.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,24 @@ interface TranscriptItemProtocol {
88
val timeStamp: String
99
var contentType: String
1010
var serializedContent: String?
11+
var persistentId: String?
1112
}
1213

1314
open class TranscriptItem(
1415
override var id: String,
1516
override var timeStamp: String,
1617
override var contentType: String,
17-
override var serializedContent: String? = null
18+
override var serializedContent: String? = null,
19+
override var persistentId: String? = null
1820
) : TranscriptItemProtocol {
1921

2022
internal fun updateId(newId: String) {
2123
this.id = newId
2224
}
2325

26+
internal fun updatePersistentId() {
27+
this.persistentId = this.id
28+
}
2429
internal fun updateTimeStamp(newTimeStamp: String) {
2530
this.timeStamp = newTimeStamp
2631
}

chat-sdk/src/main/java/com/amazon/connect/chat/sdk/repository/ChatService.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ class ChatServiceImpl @Inject constructor(
395395
// already have that item in our internalTranscript, so we will just apply existing
396396
// metadata to new item.
397397
if (existingItem is Message && item is Message) {
398+
item.persistentId = existingItem.persistentId
398399
if (existingItem.metadata != null && item.metadata == null) {
399400
item.metadata = existingItem.metadata
400401
}
@@ -432,6 +433,7 @@ class ChatServiceImpl @Inject constructor(
432433
if (transcriptDict[newId] != null) {
433434
transcriptDict.remove(oldId)
434435
internalTranscript.removeAll { it.id == oldId }
436+
transcriptDict[newId]?.persistentId = oldId
435437
// Send out updated transcript
436438
coroutineScope.launch {
437439
_transcriptListPublisher.emit(TranscriptData(internalTranscript, previousTranscriptNextToken))
@@ -440,6 +442,7 @@ class ChatServiceImpl @Inject constructor(
440442
// Update the placeholder message's ID to the new ID
441443
(placeholderMessage as TranscriptItem).updateId(newId)
442444
placeholderMessage.metadata?.status = MessageStatus.Sent
445+
placeholderMessage.persistentId = oldId
443446
transcriptDict.remove(oldId)
444447
transcriptDict[newId] = placeholderMessage
445448
}
@@ -457,6 +460,7 @@ class ChatServiceImpl @Inject constructor(
457460
tempMessage.text = message.text
458461
tempMessage.contentType = message.contentType
459462
tempMessage.attachmentId = message.attachmentId
463+
tempMessage.updatePersistentId()
460464
currentDict.remove(tempMessage.id)
461465
currentDict[message.id] = tempMessage
462466
handleTranscriptItemUpdate(tempMessage)

0 commit comments

Comments
 (0)