Attractive and repulsive contributions of medium fluctuations to nuclear superfluidity