I think we're just learning about immunity both from infections and from vaccines. It also depends on the variant that you're talking about.
I think there's certainly evidence that for variants prior to omicron, if you had an infection, you could have quite significant immunity. That has to be monitored in terms of how long that immunity lasts for and the quality of that immune response, but when omicron arrived, it was a game-changer.
There are many things about omicron that were a bit different. It can cause a milder illness and maybe infect only your respiratory tract before your body gets to work fighting it, and that immunity to omicron variants might be quite variable, so we're still learning about that.
What is important is that we have to understand what we call “hybrid immunity” as well. Some of the studies—and they're quite sparse at the moment—show that if you're unvaccinated and you get infected, you're more likely to get reinfected with omicron. If you are vaccinated and you're infected, you're less likely to. Your body generates more neutralizing antibodies, perhaps, but those questions remain.
I think it is not a simple question. It may be dependent on the variant as well.