connector/reactions: fallback to sensible defaults if config doesn't have the correct values

Signed-off-by: Sumner Evans <sumner.evans@automattic.com>
This commit is contained in:
Sumner Evans
2024-10-11 10:22:21 -06:00
parent 73d0b189bb
commit 679b4bd157
+10 -2
View File
@@ -184,8 +184,16 @@ func (t *TelegramClient) getReactionLimit(ctx context.Context, sender networkid.
return 0, err
}
if ghost.Metadata.(*GhostMetadata).IsPremium {
return int(config["reactions_user_max_premium"].(float64)), nil
if maxReactions, ok := config["reactions_user_max_premium"].(float64); ok {
return int(maxReactions), nil
} else {
return 3, nil
}
} else {
return int(config["reactions_user_max_default"].(float64)), nil
if maxReactions, ok := config["reactions_user_max_default"].(float64); ok {
return int(maxReactions), nil
} else {
return 1, nil
}
}
}