Persist presence data to the database if requested

This allows us to restart the server without users being aware (well providing it restarts quickly enough).

Fixes #213