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
Autoformat, I take no credit