Skip to content

Commit

Permalink
lib: add support for context block and verbatim option
Browse files Browse the repository at this point in the history
  • Loading branch information
sewenthy committed Sep 24, 2024
1 parent a6276b7 commit d484cb4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
9 changes: 8 additions & 1 deletion examples/echo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ let slack_echo_event_handler ctx event =
Blocks
{
blocks =
[ Section { text = { text_type = Mrkdwn; text = "some other text in a section" }; accessory = None } ];
[
Section
{
verbatim = Some false;
text = { text_type = Mrkdwn; text = "some other text in a section" };
accessory = None;
};
];
}
| false -> Message_attachment (make_message_attachment ~text:"i unfurled this link!" ())
in
Expand Down
12 changes: 9 additions & 3 deletions lib/slack.atd
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type text_object <ocaml attr="deriving make"> = {
}

type message_text_block <ocaml attr="deriving make"> = {
?verbatim: bool nullable;
text: text_object;
?accessory: accessory_object nullable;
}
Expand All @@ -63,10 +64,15 @@ type divider = {
?empty: bool nullable; (* having a simple variant make Type_field adapter not work*)
}

type context_object = {
elements: text_object list;
}

type message_block = [
Section <json name="section"> of message_text_block
| Image <json name="image"> of image_object
Context <json name="context"> of context_object
| Divider <json name="divider"> of divider
| Image <json name="image"> of image_object
| Section <json name="section"> of message_text_block
] <ocaml repr="classic"> <json adapter.ocaml="Atdgen_runtime.Json_adapter.Type_field">

type post_message_req <ocaml attr="deriving make"> = {
Expand Down Expand Up @@ -110,7 +116,7 @@ type update_message_res = {

(** Not supporting file upload through form using `file` currently *)
type files_upload_req <ocaml attr="deriving make"> = {
(** channels: comma-separated values e.g. [C1234567890,C2345678901,C3456789012]--when it's empty,
(** channels: comma-separated values e.g. [C1234567890,C2345678901,C3456789012]--when it's empty,
it does return a file id but the file is not shared to any channel.
*)
?channels: string nullable;
Expand Down

0 comments on commit d484cb4

Please sign in to comment.