fix: edit message even if converting link previews to proto

This commit is contained in:
Igor Sirotin 2023-11-08 17:28:55 +00:00 committed by Igor Sirotin
parent b5c82adb70
commit eab6118f12
2 changed files with 11 additions and 5 deletions

View File

@ -2309,9 +2309,10 @@ func (m *Messenger) sendChatMessage(ctx context.Context, message *common.Message
}
}
unfurledLinks, err := message.ConvertLinkPreviewsToProto()
// We consider link previews non-critical data, so we do not want to block
// messages from being sent.
unfurledLinks, err := message.ConvertLinkPreviewsToProto()
if err != nil {
m.logger.Error("failed to convert link previews", zap.Error(err))
} else {

View File

@ -69,17 +69,22 @@ func (m *Messenger) EditMessage(ctx context.Context, request *requests.EditMessa
editMessage.MessageId = message.ID
editMessage.Clock = clock
// We consider link previews non-critical data, so we do not want to block
// messages from being sent.
unfurledLinks, err := message.ConvertLinkPreviewsToProto()
if err != nil {
return nil, err
m.logger.Error("failed to convert link previews", zap.Error(err))
} else {
editMessage.UnfurledLinks = unfurledLinks
}
editMessage.UnfurledLinks = unfurledLinks
unfurledStatusLinks, err := message.ConvertStatusLinkPreviewsToProto()
if err != nil {
return nil, err
m.logger.Error("failed to convert status link previews", zap.Error(err))
} else {
editMessage.UnfurledStatusLinks = unfurledStatusLinks
}
editMessage.UnfurledStatusLinks = unfurledStatusLinks
err = m.applyEditMessage(editMessage.EditMessage, message)
if err != nil {