1use serde::{Deserialize, Serialize};
2
3use crate::util::Style;
4
5#[derive(Debug, Deserialize, Serialize)]
6#[serde(tag = "type")]
7pub enum Text {
8 #[serde(rename = "mrkdwn")]
9 Markdown(MarkdownText),
10
11 #[serde(rename = "plain_text")]
12 PlainText(PlainText),
13}
14
15impl Text {
16 pub fn plain<S: Into<String>>(text: S) -> Self {
17 Self::PlainText(PlainText {
18 text: text.into(),
19 emoji: true,
20 })
21 }
22
23 pub fn markdown<S: Into<String>>(text: S) -> Self {
24 Self::Markdown(MarkdownText {
25 text: text.into(),
26 verbatim: false,
27 })
28 }
29}
30
31impl Default for Text {
32 fn default() -> Self {
33 Text::Markdown(Default::default())
34 }
35}
36
37#[derive(Debug, Deserialize, Serialize, Default)]
38pub struct MarkdownText {
39 pub text: String,
40
41 #[serde(default)]
42 pub verbatim: bool,
43}
44
45#[derive(Debug, Deserialize, Serialize, Default)]
46pub struct PlainText {
47 pub text: String,
48
49 #[serde(default)]
50 pub emoji: bool,
51}
52
53#[derive(Debug, Deserialize, Serialize, Default)]
54pub struct ConfirmationDialog {
55 pub title: Text,
56 pub text: Text,
57 pub confirm: Text,
58 pub deny: Text,
59
60 #[serde(skip_serializing_if = "std::option::Option::is_none")]
61 pub style: std::option::Option<Style>,
62}
63
64#[derive(Debug, Deserialize, Serialize, Default)]
65pub struct Option {
66 pub text: Text,
67 pub value: String,
68
69 #[serde(skip_serializing_if = "std::option::Option::is_none")]
70 pub description: std::option::Option<Text>,
71
72 #[serde(skip_serializing_if = "std::option::Option::is_none")]
73 pub url: std::option::Option<String>,
74}
75
76#[derive(Debug, Deserialize, Serialize, Default)]
77pub struct OptionGroup {
78 pub label: Text,
79 pub options: Vec<Option>,
80}
81
82#[derive(Debug, Deserialize, Serialize, Default)]
83pub struct DispatchAction {
84 #[serde(default)]
85 pub trigger_actions_on: Vec<String>,
86}
87#[derive(Debug, Deserialize, Serialize, Default)]
88pub struct FilterAction {
89 #[serde(default)]
90 pub include: Vec<String>,
91
92 #[serde(default)]
93 pub exclude_external_shared_channels: bool,
94
95 #[serde(default)]
96 pub exclude_bot_users: bool,
97}