Skip to content

Commit 98030bf

Browse files
authored
Merge pull request #424 from seratch/add-style-to-rich-text-emoji
Add style to rich_text emoji elements
2 parents 81201f7 + b3837a8 commit 98030bf

File tree

3 files changed

+169
-1
lines changed

3 files changed

+169
-1
lines changed

json-logs/samples/api/im.history.json

Lines changed: 126 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,132 @@
2323
],
2424
"subscribed": false,
2525
"user": "U00000000",
26-
"bot_link": ""
26+
"bot_link": "",
27+
"client_msg_id": "",
28+
"team": "T00000000",
29+
"edited": {
30+
"user": "U00000000",
31+
"ts": "0000000000.000000"
32+
},
33+
"blocks": [
34+
{
35+
"type": "",
36+
"elements": [
37+
{
38+
"type": "",
39+
"text": {
40+
"type": "",
41+
"text": "",
42+
"emoji": false
43+
},
44+
"action_id": "",
45+
"url": "",
46+
"value": "",
47+
"style": "",
48+
"confirm": {
49+
"title": {
50+
"type": "",
51+
"text": "",
52+
"emoji": false
53+
},
54+
"text": {
55+
"type": "",
56+
"text": "",
57+
"emoji": false
58+
},
59+
"confirm": {
60+
"type": "",
61+
"text": "",
62+
"emoji": false
63+
},
64+
"deny": {
65+
"type": "",
66+
"text": "",
67+
"emoji": false
68+
}
69+
},
70+
"placeholder": {
71+
"type": "",
72+
"text": "",
73+
"emoji": false
74+
},
75+
"initial_channel": "",
76+
"response_url_enabled": false,
77+
"initial_conversation": "",
78+
"filter": {
79+
"exclude_external_shared_channels": false,
80+
"exclude_bot_users": false
81+
},
82+
"initial_date": "",
83+
"initial_option": {
84+
"text": {
85+
"type": "",
86+
"text": "",
87+
"emoji": false
88+
},
89+
"value": "",
90+
"description": {
91+
"type": "",
92+
"text": "",
93+
"emoji": false
94+
},
95+
"url": ""
96+
},
97+
"min_query_length": 12345,
98+
"image_url": "",
99+
"alt_text": "",
100+
"fallback": "",
101+
"image_width": 12345,
102+
"image_height": 12345,
103+
"image_bytes": 12345,
104+
"initial_user": ""
105+
},
106+
{
107+
"type": "",
108+
"image_url": "",
109+
"alt_text": "",
110+
"fallback": "",
111+
"image_width": 12345,
112+
"image_height": 12345,
113+
"image_bytes": 12345
114+
}
115+
],
116+
"block_id": "",
117+
"fallback": "",
118+
"image_url": "",
119+
"image_width": 12345,
120+
"image_height": 12345,
121+
"image_bytes": 12345,
122+
"alt_text": "",
123+
"title": {
124+
"type": "",
125+
"text": "",
126+
"emoji": false
127+
},
128+
"text": {
129+
"type": "",
130+
"text": "",
131+
"emoji": false
132+
},
133+
"fields": [
134+
{
135+
"type": "",
136+
"text": "",
137+
"emoji": false,
138+
"verbatim": false
139+
}
140+
],
141+
"accessory": {
142+
"type": "",
143+
"image_url": "",
144+
"alt_text": "",
145+
"fallback": "",
146+
"image_width": 12345,
147+
"image_height": 12345,
148+
"image_bytes": 12345
149+
}
150+
}
151+
]
27152
}
28153
],
29154
"has_more": false,

slack-api-model/src/main/java/com/slack/api/model/block/element/RichTextSectionElement.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public static class Emoji implements RichTextElement {
6565
private final String type = TYPE;
6666
private String name;
6767
private Integer skinTone;
68+
private TextStyle style;
6869
}
6970

7071
@Data

slack-api-model/src/test/java/test_locally/api/model/block/BlockKitTest.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,48 @@ public void rich_text_fail_on_unknown() {
625625
}
626626
}
627627

628+
@Test
629+
public void richText_emoji_with_style() {
630+
String json = "{\n" +
631+
" \"blocks\": [\n" +
632+
" {\n" +
633+
" \"type\": \"rich_text\",\n" +
634+
" \"block_id\": \"UiW\",\n" +
635+
" \"elements\": [\n" +
636+
" {\n" +
637+
" \"type\": \"rich_text_section\",\n" +
638+
" \"elements\": [\n" +
639+
" {\n" +
640+
" \"type\": \"text\",\n" +
641+
" \"text\": \"This is a text part.\"\n" +
642+
" },\n" +
643+
" {\n" +
644+
" \"type\": \"emoji\",\n" +
645+
" \"name\": \"house\",\n" +
646+
" \"style\": {\n" +
647+
" \"bold\": true\n," +
648+
" \"strike\": true" +
649+
" }\n" +
650+
" },\n" +
651+
" {\n" +
652+
" \"type\": \"link\",\n" +
653+
" \"url\": \"https://medium.com/slack-developer-blog\",\n" +
654+
" \"text\": \"Slack Platform Blog\",\n" +
655+
" \"style\": {\n" +
656+
" \"bold\": true\n," +
657+
" \"strike\": true" +
658+
" }\n" +
659+
" }\n" +
660+
" ]\n" +
661+
" }\n" +
662+
" ]\n" +
663+
" }\n" +
664+
" ]\n" +
665+
"}";
666+
Message message = GsonFactory.createSnakeCase().fromJson(json, Message.class);
667+
assertThat(message, is(notNullValue()));
668+
}
669+
628670
String unknownBlocksJson = "{blocks: [{\n" +
629671
" \"type\": \"unknown_block\",\n" +
630672
" \"block_id\": \"input123\",\n" +

0 commit comments

Comments
 (0)