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

Add SlackEvent to data model #28

Closed
rwblickhan opened this issue Oct 6, 2018 · 3 comments
Closed

Add SlackEvent to data model #28

rwblickhan opened this issue Oct 6, 2018 · 3 comments
Assignees
Labels
theme:feature Request a new feature.

Comments

@rwblickhan
Copy link
Collaborator

Add a SlackEvent class to model/ to represent a Slack event parsed from JSON. In particular, it should have (de)serialization functions (to convert to and from JSON). It may also be helpful to have "sub data types;" for instance an enum for the possible event types (or at least the ones relevant to Rocket 2.0's MVP).

@rwblickhan rwblickhan added the theme:feature Request a new feature. label Oct 6, 2018
@rwblickhan rwblickhan added this to Backlog/feature requests in Rocket 2 Planning via automation Oct 6, 2018
@rmcreyes rmcreyes moved this from Backlog/feature requests to In progress in Rocket 2 Planning Oct 6, 2018
@rmcreyes
Copy link
Collaborator

It seems as though each Slack event's JSON string has an inner JSON object as a property, and this object has a different structure depending on the kind of event.

This is a full example of the structure of a Slack reaction_added event. Take notice of the event object:
image

The event documentation provides detail of the structure of other events, where in most cases only the event attribute's structure is shown, and in others the full structure is shown, like in this link_shared event:

image

In some cases, the event does not even have an event attribute at all, like in this app_rate_limited event:
image

The simplest way to handle this in my opinion is to serialize the outer attributes, as well as the type attribute of the inner event object to identify the kind of event at least, and leave the inner event object as a String attribute of the SlackEvent class being built, but I am open to suggestions as to how to handle this.

@rmcreyes
Copy link
Collaborator

Also since Python represents JSON objects as dictionaries with strings as keys, I also propose a solution that has the class expose the event fields through a function that takes a string and returns the value associated with the key:
image
where __event_obj is a dictionary.

rmcreyes pushed a commit that referenced this issue Oct 11, 2018
rmcreyes pushed a commit that referenced this issue Oct 11, 2018
@rmcreyes rmcreyes moved this from In progress to Needs review in Rocket 2 Planning Oct 11, 2018
@rmcreyes rmcreyes moved this from Needs review to Blocked in Rocket 2 Planning Oct 11, 2018
@rwblickhan
Copy link
Collaborator Author

I believe we've decided not to go down this route, at least for the time being; closing.

Rocket 2 Planning automation moved this from Blocked to Done Dec 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme:feature Request a new feature.
Projects
Development

Successfully merging a pull request may close this issue.

2 participants