fix mobile detection, add error if chat message can't save in database