Skip to content

Commit

Permalink
Add information about storing mentions and event in audit logs (#1439)
Browse files Browse the repository at this point in the history
  • Loading branch information
mszostok authored May 8, 2024
1 parent c3c1bbe commit 3487564
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 9 deletions.
19 changes: 19 additions & 0 deletions pkg/api/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ const (
ExternalSelect SelectType = "external"
)

// DividerStyle is a style of Divider element between section blocks.
type DividerStyle string

// Represents a divider styles.
const (
// DividerStyleDefault put a block divider, like an <hr>, to split up different sections inside of a single message.
// It is the default style for backwards compatibility.
DividerStyleDefault DividerStyle = ""
// DividerStyleTopNone
DividerStyleTopNone DividerStyle = "none"
)

// MessageType defines the message type.
type MessageType string

Expand Down Expand Up @@ -126,8 +138,15 @@ type Body struct {
Plaintext string `json:"plaintext,omitempty" yaml:"plaintext"`
}

// SectionStyle holds section style.
type SectionStyle struct {
Divider DividerStyle `json:"divider,omitempty" yaml:"dividerStyle"`
}

// Section holds section related fields.
type Section struct {
Style SectionStyle `json:"style,omitempty" yaml:"style"`

Base `json:",inline" yaml:"base"`
Buttons Buttons `json:"buttons,omitempty" yaml:"buttons"`
MultiSelect MultiSelect `json:"multiSelect,omitempty" yaml:"multiSelect"`
Expand Down
28 changes: 23 additions & 5 deletions pkg/bot/interactive/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,33 @@ func (h *HelpMessage) basicCommands() []api.Section {
}

func (h *HelpMessage) footer() []api.Section {
btns := api.Buttons{
h.btnBuilder.ForURL("Give feedback", "https://feedback.botkube.io", api.ButtonStylePrimary),
h.btnBuilder.ForURL("Read our docs", "https://docs.botkube.io"),
h.btnBuilder.ForURL("Join our Slack", "https://join.botkube.io"),
h.btnBuilder.ForURL("Follow us on Twitter", "https://twitter.com/botkube_io"),
}

if !remote.IsEnabled() {
return []api.Section{
{
Buttons: btns,
},
}
}

return []api.Section{
{
Buttons: []api.Button{
h.btnBuilder.ForURL("Give feedback", "https://feedback.botkube.io", api.ButtonStylePrimary),
h.btnBuilder.ForURL("Read our docs", "https://docs.botkube.io"),
h.btnBuilder.ForURL("Join our Slack", "https://join.botkube.io"),
h.btnBuilder.ForURL("Follow us on Twitter", "https://twitter.com/botkube_io"),
Context: api.ContextItems{
{Text: fmt.Sprintf("👀 _All %s mentions and events are visible to your Botkube Cloud organisation’s administrators._", api.MessageBotNamePlaceholder)},
},
},
{
Style: api.SectionStyle{
Divider: api.DividerStyleTopNone,
},
Buttons: btns,
},
}
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/bot/slack_renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ func (b *SlackRenderer) RenderAsSlackBlocks(msg interactive.CoreMessage) []slack
blocks = append(blocks, b.mdTextSection(formatx.AdaptiveCodeBlock(msg.BaseBody.CodeBlock)))
}

all := len(msg.Sections)
for idx, s := range msg.Sections {
blocks = append(blocks, b.renderSection(s)...)
if !(idx == all-1) { // if not the last one, append divider
if idx > 0 && s.Style.Divider != api.DividerStyleTopNone {
blocks = append(blocks, slack.NewDividerBlock())
}
blocks = append(blocks, b.renderSection(s)...)
}

for _, i := range msg.PlaintextInputs {
blocks = append(blocks, b.renderInput(i))
}
Expand Down
2 changes: 1 addition & 1 deletion test/msg-layouts/help_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
// - Slack: https://app.slack.com/block-kit-builder/
// - Teams: https://adaptivecards.io/designer/
// - Discord: it's only markdown, just post as a normal message in discord channel
// - Mattermost: it's only markdown, just post as a normal message in discord channel
// - Mattermost: it's only markdown, just post as a normal message in mattermost channel
//
// To update the golden files:
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,15 @@
{
"type": "divider"
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "👀 _All @Botkube mentions and events are visible to your Botkube Cloud organisation’s administrators._"
}
]
},
{
"type": "actions",
"elements": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,14 @@
}
]
},
{
"type": "TextBlock",
"text": "_👀 _All @Botkube mentions and events are visible to your Botkube Cloud organisation’s administrators.__",
"isSubtle": true,
"weight": "lighter",
"wrap": true,
"separator": true
},
{
"type": "ActionSet",
"actions": [
Expand Down

0 comments on commit 3487564

Please sign in to comment.