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
Extract user to a local variable outside the **if** statement and then check if user == null instead of calling containsKey?