replace mention name with public key (#4579)

* replace mention with public key

* bump version
This commit is contained in:
frank 2024-01-18 21:18:01 +08:00 committed by GitHub
parent 0bd4a06edc
commit ea3e59ffee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 2 deletions

View File

@ -1 +1 @@
0.172.4
0.172.5

View File

@ -2297,6 +2297,14 @@ func (m *Messenger) sendChatMessage(ctx context.Context, message *common.Message
}
message.DisplayName = displayName
replacedText, err := m.mentionsManager.ReplaceWithPublicKey(message.ChatId, message.Text)
if err == nil {
message.Text = replacedText
} else {
m.logger.Error("failed to replace text with public key", zap.String("chatID", message.ChatId), zap.String("text", message.Text))
}
if len(message.ImagePath) != 0 {
err := message.LoadImage()

View File

@ -63,7 +63,13 @@ func (m *Messenger) EditMessage(ctx context.Context, request *requests.EditMessa
editMessage := NewEditMessage()
editMessage.Text = request.Text
replacedText, err := m.mentionsManager.ReplaceWithPublicKey(message.ChatId, request.Text)
if err != nil {
m.logger.Error("failed to replace text with public key", zap.String("chatID", message.ChatId), zap.String("text", request.Text))
// use original text as fallback
replacedText = request.Text
}
editMessage.Text = replacedText
editMessage.ContentType = request.ContentType
editMessage.ChatId = message.ChatId
editMessage.MessageId = message.ID