Fix activity feed bug introduced with Rails 4.1
Extract message-building code to dedicated classes
Use database instead of filesystem for maintenance flag
Use database locks instead of files for news sync