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 reactions to conversation history #239

Merged
merged 5 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public interface LiteMessageIF {

List<Block> getBlocks();

List<Reaction> getReactions();

@JsonProperty("ts")
String getTimestamp();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.hubspot.slack.client.models;

import java.util.List;

import org.immutables.value.Value.Immutable;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategy.SnakeCaseStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.hubspot.immutables.style.HubSpotStyle;

@Immutable
@HubSpotStyle
@JsonNaming(SnakeCaseStrategy.class)
public interface ReactionIF {
@JsonProperty("name")
String getName();
@JsonProperty("count")
Integer getCount();
Copy link
Contributor

Choose a reason for hiding this comment

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

Integer -> int

@JsonProperty("users")
Copy link
Contributor

Choose a reason for hiding this comment

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

We tend to use @JsonProperty only if the name of the method is different from JSON key.
In this case, we don't need to name each property explicitly since for example count is automatically deserialized and stored in getCount. That's the magic of the immutables.

List<String> getUser();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we rename this to getUsers? I imagine the list is returned when multiple users reacted with the same emoji.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, we won't need JsonProperty annotation in this case.

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,19 @@
"text": "Shutters shut and shutters and so shutters shut and shutters and so and so shutters and so shutters shut and so shutters shut and shutters and so.",
"thread_ts": "1482960137.003543",
"parent_user_id": "U061F7AUR",
"ts": "1483037603.017503"
"ts": "1483037603.017503",
"reactions": [
{
"name": "astonished",
"count": 3,
"users": [ "U061F7AUR", "U062F7AUR", "U063F7AUR"]
},
{
"name": "facepalm",
"count": 34,
"users": [ "U061F7AUR", "U062F7AUR", "U063F7AUR", "U064F7AUR", "U065F7AUR" ]
}
]
Comment on lines +39 to +50
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding these.
Can we also please make sure that these reactions are parsed in the corresponding integration test?

},
{
"type": "message",
Expand All @@ -51,7 +63,19 @@
"text": "I love you Alice B. Toklas and so does Gertrude Stein.",
"thread_ts": "1482960137.003543",
"parent_user_id": "U061F7AUR",
"ts": "1483125339.020269"
"ts": "1483125339.020269",
"reactions": [
{
"name": "grin",
"count": 2,
"users": [ "U061F7AUR", "U062F7AUR"]
},
{
"name": "wink",
"count": 50,
"users": [ "U061F7AUR", "U062F7AUR", "U063F7AUR" ]
}
]
}
],
"has_more": true,
Expand Down