Skip to content

Commit

Permalink
Add support for ContextBlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
twouters committed Oct 10, 2023
1 parent 0f5eedc commit 4821243
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,19 @@ func (portal *Portal) renderSlackBlock(block slack.Block, userTeam *database.Use
htmlText.WriteString(portal.renderSlackRichTextElement(len(b.Elements), element, userTeam))
}
return format.UnwrapSingleParagraph(htmlText.String()), false
case *slack.ContextBlock:
var htmlText strings.Builder
var unsupported bool = false
for _, element := range b.ContextElements.Elements {
if mrkdwnElem, ok := element.(*slack.TextBlockObject); ok {
htmlText.WriteString(fmt.Sprintf("<sup>%s</sup>", portal.mrkdwnToMatrixHtml(mrkdwnElem.Text)))
} else {
portal.log.Debugfln("Unsupported Slack block element: %s", element.MixedElementType())
htmlText.WriteString("<i>Slack message contains unsupported elements.</i>")
unsupported = true
}
}
return htmlText.String(), unsupported
default:
portal.log.Debugfln("Unsupported Slack block: %s", b.BlockType())
return "<i>Slack message contains unsupported elements.</i>", true
Expand Down

0 comments on commit 4821243

Please sign in to comment.