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

feature: Added Public Ably Message Parsers #249

Conversation

splindsay-92
Copy link
Contributor

@splindsay-92 splindsay-92 commented Jul 4, 2024

Context

  • CHA-337
  • Users may wish to make use of ably's integration offerings, such as webhooks/AWS lambdas, where messages/reactions etc. sent to the room can be filtered and sent to an integration. It would be useful to have some functions set up that users can pass an encoded inbound message-like object and decode them straight into a chat type like a message or reaction.

Description

  • Added two functions that take an encoded ably message, such as those sent via integration rules, and try to convert them into chat types.

    • Added fromEncodedChatMessage function that will try and convert the message into a chat message.
    • Added fromEncodedReaction function that will try and convert the message into a reaction.
  • Added getEntityTypeFromEncoded function that will also take an encoded message, and attempt to resolve the chat entity type, currently either a chat message or reaction. This can then be used to inform the user which of the two fromEncoded function you need to use.

  • Added two functions that take an ably inbound message, and try to convert them into chat types.

    • Added fromAblyMessageToReaction function that will take an ably inboundMessage and try to convert it to a reaction
    • Added fromAblyMessageToChatMessage function that will take an ably inboundMessage and try to convert it to a chat message.
  • Added getEntityTypeFromAblyMessage function that will take inboundMessage, and attempt to resolve the chat entity type, currently either a chat message or reaction. This can then be used to inform the user which of the two fromAblyMessage functions you need to use.

  • Moved message and reaction parsing to internal folders for reuse outside their previous classes. Added testing for message and reaction parsing since it wasn't covered comprehensively.

Checklist

  • QA'd by the author.
  • Unit tests created (if applicable).
  • Integration tests created (if applicable).
  • Follow coding style guidelines found here.
  • TypeDoc updated (if applicable).
  • (Optional) Update documentation for new features.

@github-actions github-actions bot temporarily deployed to staging/pull/249/typedoc July 4, 2024 08:50 Inactive
@splindsay-92 splindsay-92 force-pushed the CHA-337-implement-public-facing-from-encoded-and-from-ably-message-functions branch from a4ca505 to a174606 Compare July 4, 2024 09:15
@splindsay-92 splindsay-92 requested a review from AndyTWF July 4, 2024 09:16
@github-actions github-actions bot temporarily deployed to staging/pull/249/typedoc July 4, 2024 09:16 Inactive
src/Helpers.ts Outdated Show resolved Hide resolved
@splindsay-92 splindsay-92 force-pushed the CHA-337-implement-public-facing-from-encoded-and-from-ably-message-functions branch from a174606 to b355c5a Compare July 4, 2024 11:42
@github-actions github-actions bot temporarily deployed to staging/pull/249/typedoc July 4, 2024 11:42 Inactive
@splindsay-92
Copy link
Contributor Author

Considering these aren't specifically for use in the chat SDK, should their use be documented elsewhere?

src/Helpers.ts Outdated Show resolved Hide resolved
src/Helpers.ts Outdated Show resolved Hide resolved
src/Helpers.ts Outdated Show resolved Hide resolved
src/Helpers.ts Outdated Show resolved Hide resolved
src/Helpers.ts Outdated Show resolved Hide resolved
src/Messages.ts Outdated Show resolved Hide resolved
src/internal/parsers/messageParser.ts Outdated Show resolved Hide resolved
test/Helpers.test.ts Outdated Show resolved Hide resolved
test/internal/parsers/messageParser.test.ts Outdated Show resolved Hide resolved
test/internal/parsers/reactionParser.test.ts Outdated Show resolved Hide resolved
@splindsay-92 splindsay-92 force-pushed the CHA-337-implement-public-facing-from-encoded-and-from-ably-message-functions branch from b355c5a to b8cf9a0 Compare July 9, 2024 16:22
@paddybyers
Copy link
Member

Considering these aren't specifically for use in the chat SDK, should their use be documented elsewhere?

They should always be documented somewhere in the repo that they're implemented, and possibly also in the central Ably docs. But I think something should be added here.

@splindsay-92 splindsay-92 force-pushed the CHA-337-implement-public-facing-from-encoded-and-from-ably-message-functions branch 4 times, most recently from 365e826 to 2069268 Compare July 10, 2024 06:53
@github-actions github-actions bot temporarily deployed to staging/pull/249/typedoc July 10, 2024 06:54 Inactive
@splindsay-92
Copy link
Contributor Author

Considering these aren't specifically for use in the chat SDK, should their use be documented elsewhere?

They should always be documented somewhere in the repo that they're implemented, and possibly also in the central Ably docs. But I think something should be added here.

They will have typedocs, but I wasn't sure whether to include example usage in the README too, following ably-js which seems this is isn't the case for functions like fromEncoded. I could only see these documented in the library migration readme, but this didn't document their usage.

@splindsay-92 splindsay-92 force-pushed the CHA-337-implement-public-facing-from-encoded-and-from-ably-message-functions branch from 2069268 to 6db30d5 Compare July 10, 2024 15:35
@github-actions github-actions bot temporarily deployed to staging/pull/249/typedoc July 10, 2024 15:36 Inactive
@splindsay-92 splindsay-92 force-pushed the CHA-337-implement-public-facing-from-encoded-and-from-ably-message-functions branch from 6db30d5 to 962a92a Compare July 10, 2024 15:43
@github-actions github-actions bot temporarily deployed to staging/pull/249/typedoc July 10, 2024 15:44 Inactive
@splindsay-92 splindsay-92 force-pushed the CHA-337-implement-public-facing-from-encoded-and-from-ably-message-functions branch from 962a92a to b520d55 Compare July 12, 2024 12:13
@github-actions github-actions bot temporarily deployed to staging/pull/249/typedoc July 12, 2024 12:14 Inactive
Copy link

github-actions bot commented Jul 12, 2024

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 92.21% (🎯 91%) 1932 / 2095
🟢 Statements 92.21% (🎯 91%) 1932 / 2095
🟢 Functions 96.39% (🎯 92%) 187 / 194
🟢 Branches 92.86% (🎯 92%) 521 / 561
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
src/core/helpers.ts 96.15% 94.11% 100% 96.15% 99-100
src/core/message-parser.ts 100% 100% 100% 100%
src/core/messages.ts 93.47% 92.3% 100% 93.47% 338-340, 370-374, 387-391, 499-500
src/core/reaction-parser.ts 100% 100% 100% 100%
src/core/room-reactions.ts 98.19% 96.29% 100% 98.19% 176-177
Generated in workflow #1148

@splindsay-92 splindsay-92 changed the title CHA-337: Added Public Ably Message Parsers (feature) Added Public Ably Message Parsers Jul 12, 2024
@splindsay-92 splindsay-92 changed the title (feature) Added Public Ably Message Parsers feature: Added Public Ably Message Parsers Jul 12, 2024
@splindsay-92 splindsay-92 force-pushed the CHA-337-implement-public-facing-from-encoded-and-from-ably-message-functions branch from b520d55 to 161c6e2 Compare July 14, 2024 10:06
@github-actions github-actions bot temporarily deployed to staging/pull/249/typedoc July 14, 2024 10:07 Inactive
@splindsay-92 splindsay-92 force-pushed the CHA-337-implement-public-facing-from-encoded-and-from-ably-message-functions branch from 161c6e2 to 0ed32a5 Compare July 14, 2024 11:01
@github-actions github-actions bot temporarily deployed to staging/pull/249/typedoc July 14, 2024 11:02 Inactive
@splindsay-92 splindsay-92 force-pushed the CHA-337-implement-public-facing-from-encoded-and-from-ably-message-functions branch from 0ed32a5 to c02bd8e Compare July 14, 2024 12:12
@github-actions github-actions bot temporarily deployed to staging/pull/249/typedoc July 14, 2024 12:13 Inactive
@splindsay-92 splindsay-92 force-pushed the CHA-337-implement-public-facing-from-encoded-and-from-ably-message-functions branch from c02bd8e to 03f37db Compare July 14, 2024 12:25
@github-actions github-actions bot temporarily deployed to staging/pull/249/typedoc July 14, 2024 12:25 Inactive
@splindsay-92 splindsay-92 force-pushed the CHA-337-implement-public-facing-from-encoded-and-from-ably-message-functions branch from 03f37db to 027099e Compare July 15, 2024 11:04
@github-actions github-actions bot temporarily deployed to staging/pull/249/typedoc July 15, 2024 11:04 Inactive
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
src/Messages.ts Outdated Show resolved Hide resolved
src/RoomReactions.ts Outdated Show resolved Hide resolved
src/helpers.ts Outdated Show resolved Hide resolved
src/messageParser.ts Outdated Show resolved Hide resolved
src/messageParser.ts Outdated Show resolved Hide resolved
src/reactionParser.ts Outdated Show resolved Hide resolved
src/reactionParser.ts Outdated Show resolved Hide resolved
@splindsay-92 splindsay-92 force-pushed the CHA-337-implement-public-facing-from-encoded-and-from-ably-message-functions branch from 027099e to 7c86864 Compare July 15, 2024 19:05
@github-actions github-actions bot temporarily deployed to staging/pull/249/typedoc July 15, 2024 19:05 Inactive
@splindsay-92 splindsay-92 force-pushed the CHA-337-implement-public-facing-from-encoded-and-from-ably-message-functions branch from 7c86864 to ec6636d Compare July 15, 2024 19:08
@github-actions github-actions bot temporarily deployed to staging/pull/249/typedoc July 15, 2024 19:09 Inactive
@splindsay-92 splindsay-92 force-pushed the CHA-337-implement-public-facing-from-encoded-and-from-ably-message-functions branch from ec6636d to 7a71a01 Compare July 16, 2024 15:07
@github-actions github-actions bot temporarily deployed to staging/pull/249/typedoc July 16, 2024 15:07 Inactive
@splindsay-92 splindsay-92 force-pushed the CHA-337-implement-public-facing-from-encoded-and-from-ably-message-functions branch from 7a71a01 to 60243df Compare July 17, 2024 18:06
@github-actions github-actions bot temporarily deployed to staging/pull/249/typedoc July 17, 2024 18:07 Inactive
These functions allow the user to convert encoded messages, such as those received on an integration, and inbound messages, such as those received on a channel subscription, into chat types.

- Added two functions that take an encoded object, such as those sent via integration rules, and try to convert them into chat types.
- Added `chatMessageFromEncoded` function that will try and convert the encoded object into a chat message.
- Added `reactionFromEncoded` function that will try and convert the encoded object into a reaction.
- Added `getEntityTypeFromEncoded` function that will also take an encoded object, and attempt to resolve the chat entity type, currently either a chat message or reaction. This can then be used to inform the user which of the two fromEncoded function you need to use.
- Added `reactionFromAblyMessage` function that will take an ably inboundMessage and try to convert it to a reaction
- Added `chatMessageFromAblyMessage` function that will take an ably inboundMessage and try to convert it to a chat message.
- Added `getEntityTypeFromAblyMessage` function that will take an inboundMessage, and attempt to resolve the chat entity type, currently either a chat message or reaction. This can then be used to inform the user which of the two fromAblyMessage functions you need to use.
- Added testing for message and reaction parsing since it wasn't covered comprehensively.
- Added some example usage to the README.md
@splindsay-92 splindsay-92 force-pushed the CHA-337-implement-public-facing-from-encoded-and-from-ably-message-functions branch from 60243df to c707b65 Compare July 17, 2024 19:03
@splindsay-92 splindsay-92 merged commit 3346011 into main Jul 18, 2024
8 checks passed
@splindsay-92 splindsay-92 deleted the CHA-337-implement-public-facing-from-encoded-and-from-ably-message-functions branch July 18, 2024 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants