Skip to content

feat: refactor and test Event types#24

Draft
JadedEvan wants to merge 19 commits intoGompei:mainfrom
JadedEvan:feat/refactor-event-typings
Draft

feat: refactor and test Event types#24
JadedEvan wants to merge 19 commits intoGompei:mainfrom
JadedEvan:feat/refactor-event-typings

Conversation

@JadedEvan
Copy link
Copy Markdown
Contributor

Note this is currently a WIP

The goal of this PR is the following

  1. Simplify the Event types (currently Event, EventTypeCallback) into a simpler structure. Currently there is a fair amount of abstraction that isn't really necessary
  2. Introduce additional unit tests to validate serialization / deserialization. The goal is ensure that inbound JSON payloads deserialize correctly as compared to the JSON in the Slack API documentation.

For point two above, I've introduced the assert-json-diff crate which allows you to more easily find the differences between serde_json Value objects. The goal is to use this to ensure that we have all the expected keys in the JSON objects.

BREAKING CHANGE: reworks the API and types for how Events are used
within this library. Removes the existing `EventType` in favor of a
simpler version where event properties are expressed directly on the
enum variants.

Fixes some composition issues specifically with message events. Adds
some additional types to better distinguish between basic messages and
message subtypes that are used in the Slack Events API.

Introduces the `assert-json-diff` crate to validate serialization and
deserialization of different types
These tests are known to be failing. This demonstrates that the current
enum implementation is incomplete compared to the examples provided by
the Slack documentation
Adds additional tests to validate that data is serializing / deserializing
into the expected types with expected fields
@gitguardian
Copy link
Copy Markdown

gitguardian bot commented Apr 9, 2023

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id Secret Commit Filename
- Generic High Entropy Secret 6ac5a55 src/event_api/event.rs View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

Fixes an issue where the fields for the `app_requested` event were
defined incorrectly
@JadedEvan
Copy link
Copy Markdown
Contributor Author

FYI @Gompei - my motivation currently with this draft PR is to demonstrate some of the suggestions that I made in #23. My secondary goal is to add some more unit tests (as I've described in a few other PRs and issues). If you're supportive of this direction LMK - I'd like to continue through the Events API stuff presented here.

Also adds links to Event API documentation for each variant for convenience
Adds `reaction_added`, `reaction_removed`, `pin_added`,
`pin_removed` events
Adds events for `shared_channel_invite_received`,
`shared_channel_invite_declined`, `shared_channel_invite_approved`,
`shared_channel_invite_rejected`

Fixes an typo for field in `UserProfile`
Also introduces a custom deserializer to handle string quoted integer
values ("7") and unquoted integer values (7). Note that the Slack API
documentation is ambiguous and often uses both
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.

1 participant