diff --git a/blocks.go b/blocks.go
index e32a445..852ecb4 100644
--- a/blocks.go
+++ b/blocks.go
@@ -8,6 +8,7 @@ import (
"path"
"strconv"
"strings"
+ "time"
"github.com/slack-go/slack"
"github.com/yuin/goldmark"
@@ -266,6 +267,10 @@ func (portal *Portal) SlackBlocksToMatrix(blocks slack.Blocks, attachments []sla
htmlText.WriteString(portal.blocksToHtml(blocks, false, userTeam))
+ if len(attachments) > 0 && htmlText.String() != "" {
+ htmlText.WriteString("
")
+ }
+
for _, attachment := range attachments {
if attachment.IsMsgUnfurl {
for _, message_block := range attachment.MessageBlocks {
@@ -273,6 +278,65 @@ func (portal *Portal) SlackBlocksToMatrix(blocks slack.Blocks, attachments []sla
htmlText.WriteString(fmt.Sprintf("
%s", attachment.AuthorName, renderedAttachment, attachment.FromURL, attachment.Footer)) } + } else { + if len(attachment.Pretext) > 0 { + htmlText.WriteString(fmt.Sprintf("%s
%s%s
") + if len(attachment.AuthorName) > 0 { + if len(attachment.AuthorLink) > 0 { + htmlText.WriteString(fmt.Sprintf("%s") } }
", + attachment.AuthorLink, attachment.AuthorName)) + } else { + htmlText.WriteString(fmt.Sprintf("%s
", attachment.AuthorName)) + } + } + if len(attachment.Title) > 0 { + if len(attachment.TitleLink) > 0 { + htmlText.WriteString(fmt.Sprintf("%s
", + attachment.TitleLink, portal.mrkdwnToMatrixHtml(attachment.Title))) + } else { + htmlText.WriteString(fmt.Sprintf("%s
", portal.mrkdwnToMatrixHtml(attachment.Title))) + } + } + if len(attachment.Text) > 0 { + htmlText.WriteString(portal.mrkdwnToMatrixHtml(attachment.Text)) + } else if len(attachment.Fallback) > 0 { + htmlText.WriteString(portal.mrkdwnToMatrixHtml(attachment.Fallback)) + } + if len(attachment.Fields) > 0 { + htmlText.WriteString(""); + var short = false + for _, field := range attachment.Fields { + if !short { + htmlText.WriteString("
"); + } + if len(attachment.Footer) > 0 { + htmlText.WriteString(fmt.Sprintf("%s", portal.mrkdwnToMatrixHtml(attachment.Footer))) + } + if len(attachment.Ts) > 0 { + if len(attachment.Footer) > 0 { + htmlText.WriteString(" | ") + } else { + htmlText.WriteString("") + } + ts, _ := attachment.Ts.Int64() + t := time.Unix(ts, 0) + htmlText.WriteString(fmt.Sprintf("%s", t.Local().Format("Jan 02, 2006 15:04:05"))) + } + if len(attachment.Footer) > 0 || len(attachment.Ts) > 0 { + htmlText.WriteString("") + } + htmlText.WriteString("") + } + htmlText.WriteString(fmt.Sprintf(" ") + } + } + htmlText.WriteString("%s ", + field.Title, portal.mrkdwnToMatrixHtml(field.Value))) + short = field.Short + if !short { + htmlText.WriteString("
%s