Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Unit tests, Passing rawData along with messages now #14

Merged
merged 3 commits into from
May 24, 2024

Conversation

mrajatttt
Copy link
Contributor

@mrajatttt mrajatttt commented May 22, 2024

Issue #, if available:

Description of changes:

  • Added Unit tests for main files
Screenshot 2024-05-22 at 3 14 15 PM
  • Adding parameter 'rawData' to pass message JSON along with formatted object

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@mrajatttt mrajatttt requested a review from a team as a code owner May 22, 2024 22:16
@mrajatttt mrajatttt requested review from mliao95 and doreechi and removed request for a team May 22, 2024 22:16
}

public class TranscriptItem: TranscriptItemProtocol {
public var id = UUID()
public var timeStamp: String
public var contentType: String
public var rawData: [String: Any]?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For future reference, we should split the rawData changes into a separate PR.

@@ -0,0 +1,50 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file used anywhere or does it have to be run manually?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used as of now, might consider running github actions using it later but for now, just wanted it for safe keep. I will remove it if i found it useless.

mliao95
mliao95 previously approved these changes May 22, 2024
@@ -55,8 +41,8 @@ public class Message: TranscriptItem, MessageProtocol {
case ContentType.interactiveText.rawValue:
return decodeInteractiveContent(from: text)
default:
// Handle or log unsupported content types
return nil
// Handle or log unsupported content types - Sending as Plain Text for now.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this the correct default for unsupported content type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the fallback option i have added plain text instead of throwing an error.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think translating message to plaintext if content type isn’t recognized is what UI should be doing. I think we should just be ignoring content types that aren’t explicitly expected

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so return an error?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we’re already doing this in chat interface but we should be ignoring/not doing anything if there’s a content type we don’t recognize. There shouldn’t be any translation or error thrown since new content types can be added at any time we should explicitly have to make changes to start handling those messages on the client

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood

@@ -20,10 +20,10 @@ public class Metadata: TranscriptItem, MetadataProtocol {
public var messageId: String?
public var eventDirection: MessageDirection?

init(status: MessageStatus? = nil, messageId: String? = nil, timeStamp: String, contentType: String, eventDirection: MessageDirection? = .Common) {
init(status: MessageStatus? = nil, messageId: String? = nil, timeStamp: String, contentType: String, eventDirection: MessageDirection? = .Common, rawData: [String: Any]) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general, what's the purpose of rawData? Is it the message content? If so, should we name it content instead of rawData

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes its the message content as we receive from websocket. We could rename it to content but in rawData we are also including "contentType": application/json, "topic": aws/chat

For example:
raw data for transcript Item/message looks like this

Optional(["content": {"AbsoluteTime":"2024-05-23T19:41:26.578Z","ContentType":"application/
vnd.amazonaws.connect.event.participant.joined","Id":"6b532881-2835-4981-abb0-
a7a4b422d013","Type":"EVENT","ParticipantId":"48f25338-d51c-41ae-
b10a-7bd55f6e2406","DisplayName":"C","ParticipantRole":"CUSTOMER","InitialContactId":"ec34
9471-1139-4fa4-af6c-c277a903d3e7"}, "contentType": application/json, "topic": aws/chat])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, so it's an item? https://docs.aws.amazon.com/connect/latest/APIReference/API_connect-participant_Item.html can we rename it that. I feel like rawData isn't specific enough

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But it says An item - message or event - that has been sent. and the params of that matches to the params of content. @mliao95 any opinion here?

@mrajatttt mrajatttt requested a review from doreechi May 24, 2024 17:20
@mrajatttt mrajatttt merged commit 8f94774 into main May 24, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants