mirror of
https://github.com/status-im/status-go.git
synced 2025-02-19 18:28:18 +00:00
feat(communities): handle markdown in imported discord messages
This commit is contained in:
parent
006d0ba847
commit
caa20e616e
@ -483,7 +483,14 @@ func runMentionsAndLinksVisitor(parsedText ast.Node, identity string) *MentionsA
|
|||||||
// PrepareContent return the parsed content of the message, the line-count and whether
|
// PrepareContent return the parsed content of the message, the line-count and whether
|
||||||
// is a right-to-left message
|
// is a right-to-left message
|
||||||
func (m *Message) PrepareContent(identity string) error {
|
func (m *Message) PrepareContent(identity string) error {
|
||||||
parsedText := markdown.Parse([]byte(m.Text), nil)
|
var parsedText ast.Node
|
||||||
|
switch m.ContentType {
|
||||||
|
case protobuf.ChatMessage_DISCORD_MESSAGE:
|
||||||
|
parsedText = markdown.Parse([]byte(m.GetDiscordMessage().Content), nil)
|
||||||
|
default:
|
||||||
|
parsedText = markdown.Parse([]byte(m.Text), nil)
|
||||||
|
}
|
||||||
|
|
||||||
visitor := runMentionsAndLinksVisitor(parsedText, identity)
|
visitor := runMentionsAndLinksVisitor(parsedText, identity)
|
||||||
m.Mentions = visitor.mentions
|
m.Mentions = visitor.mentions
|
||||||
m.Links = visitor.links
|
m.Links = visitor.links
|
||||||
|
@ -2419,6 +2419,14 @@ func (m *Messenger) RequestImportDiscordCommunity(request *requests.ImportDiscor
|
|||||||
ChatMessage: chatMessage,
|
ChatMessage: chatMessage,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = messageToSave.PrepareContent(common.PubkeyToHex(&m.identity.PublicKey))
|
||||||
|
if err != nil {
|
||||||
|
m.logger.Error("failed to prepare message content", zap.Error(err))
|
||||||
|
importProgress.AddTaskError(discord.ImportMessagesTask, discord.Error(err.Error()))
|
||||||
|
importProgress.UpdateTaskProgress(discord.ImportMessagesTask, progressValue)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// Handle pin messages
|
// Handle pin messages
|
||||||
if discordMessage.Type == string(discord.MessageTypeChannelPinned) && discordMessage.Reference != nil {
|
if discordMessage.Type == string(discord.MessageTypeChannelPinned) && discordMessage.Reference != nil {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user