A teenager is in custody after a social media threat against a recently opened mosque alluding to a terrorist attack.