Mastodon does not immediately generate link previews and adds a bit of random time to it to avoid sites being brought to their knees should a toot become viral. It can vary from a few minutes to a few hours in my experience.
I can have a look at the code if you want details.
That's great to hear! I'd love to be able to keep my contacts in Nextcloud and use Nametag for the PRM part.