Fix fetching accounts by JIDs

Fixes a null pointer exception when publishing avatars (and probably others that I didn't encounter).