Skip to content

Commit 7e82d69

Browse files
committed
msgconv/mediaretry: add appropriate suffix to error notice
1 parent 9eae335 commit 7e82d69

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

pkg/connector/connector.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@ func (wa *WhatsAppConnector) Init(bridge *bridgev2.Bridge) {
4848
wa.MsgConv = msgconv.New(bridge)
4949
wa.MsgConv.AnimatedStickerConfig = wa.Config.AnimatedSticker
5050
wa.MsgConv.FetchURLPreviews = wa.Config.URLPreviews
51+
wa.MsgConv.OldMediaSuffix = "Requesting old media is not enabled on this bridge."
52+
if wa.Config.HistorySync.MediaRequests.AutoRequestMedia {
53+
if wa.Config.HistorySync.MediaRequests.RequestMethod == MediaRequestMethodImmediate {
54+
wa.MsgConv.OldMediaSuffix = "Media will be requested from your phone automatically soon."
55+
} else if wa.Config.HistorySync.MediaRequests.RequestMethod == MediaRequestMethodLocalTime {
56+
wa.MsgConv.OldMediaSuffix = "Media will be requested from your phone automatically overnight."
57+
}
58+
}
5159
wa.DB = wadb.New(bridge.ID, bridge.DB.Database, bridge.Log.With().Str("db_section", "whatsapp").Logger())
5260
wa.Bridge.Commands.(*commands.Processor).AddHandlers(
5361
cmdAccept,

pkg/msgconv/msgconv.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type MessageConverter struct {
3636
HTMLParser *format.HTMLParser
3737
AnimatedStickerConfig AnimatedStickerConfig
3838
FetchURLPreviews bool
39+
OldMediaSuffix string
3940
}
4041

4142
func New(br *bridgev2.Bridge) *MessageConverter {

pkg/msgconv/wa-media.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ func (mc *MessageConverter) makeMediaFailure(ctx context.Context, mediaInfo *Pre
426426
Error: waid.MsgErrMediaNotFound,
427427
MediaMeta: serializedMedia,
428428
}
429-
errorMsg = fmt.Sprintf("Old %s. Viewing old media is not currently supported.", mediaInfo.TypeDescription)
429+
errorMsg = fmt.Sprintf("Old %s. %s", mediaInfo.TypeDescription, mc.OldMediaSuffix)
430430
}
431431
zerolog.Ctx(ctx).WithLevel(logLevel).Err(err).
432432
Str("media_type", mediaInfo.TypeDescription).

0 commit comments

Comments
 (0)