Skip to content

Commit

Permalink
msgconv/mediaretry: add appropriate suffix to error notice
Browse files Browse the repository at this point in the history
  • Loading branch information
tulir committed Oct 1, 2024
1 parent 9eae335 commit 7e82d69
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pkg/connector/connector.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ func (wa *WhatsAppConnector) Init(bridge *bridgev2.Bridge) {
wa.MsgConv = msgconv.New(bridge)
wa.MsgConv.AnimatedStickerConfig = wa.Config.AnimatedSticker
wa.MsgConv.FetchURLPreviews = wa.Config.URLPreviews
wa.MsgConv.OldMediaSuffix = "Requesting old media is not enabled on this bridge."
if wa.Config.HistorySync.MediaRequests.AutoRequestMedia {
if wa.Config.HistorySync.MediaRequests.RequestMethod == MediaRequestMethodImmediate {
wa.MsgConv.OldMediaSuffix = "Media will be requested from your phone automatically soon."
} else if wa.Config.HistorySync.MediaRequests.RequestMethod == MediaRequestMethodLocalTime {
wa.MsgConv.OldMediaSuffix = "Media will be requested from your phone automatically overnight."
}
}
wa.DB = wadb.New(bridge.ID, bridge.DB.Database, bridge.Log.With().Str("db_section", "whatsapp").Logger())
wa.Bridge.Commands.(*commands.Processor).AddHandlers(
cmdAccept,
Expand Down
1 change: 1 addition & 0 deletions pkg/msgconv/msgconv.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type MessageConverter struct {
HTMLParser *format.HTMLParser
AnimatedStickerConfig AnimatedStickerConfig
FetchURLPreviews bool
OldMediaSuffix string
}

func New(br *bridgev2.Bridge) *MessageConverter {
Expand Down
2 changes: 1 addition & 1 deletion pkg/msgconv/wa-media.go
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ func (mc *MessageConverter) makeMediaFailure(ctx context.Context, mediaInfo *Pre
Error: waid.MsgErrMediaNotFound,
MediaMeta: serializedMedia,
}
errorMsg = fmt.Sprintf("Old %s. Viewing old media is not currently supported.", mediaInfo.TypeDescription)
errorMsg = fmt.Sprintf("Old %s. %s", mediaInfo.TypeDescription, mc.OldMediaSuffix)
}
zerolog.Ctx(ctx).WithLevel(logLevel).Err(err).
Str("media_type", mediaInfo.TypeDescription).
Expand Down

0 comments on commit 7e82d69

Please sign in to comment.