<p>So by my reckoning that function is about ten times longer than it needs to be... Something like this should be all you need I think:</p>
<div class="highlight highlight-ruby"><pre><span class="pl-k">def</span> <span class="pl-en">gravatar_enable</span>(<span class="pl-smi">user</span>)
<span class="pl-k">return</span> <span class="pl-k">if</span> user.image.present?
hash <span class="pl-k">=</span> <span class="pl-c1">Digest</span>::<span class="pl-c1">MD5</span>.hexdigest(user.email.downcase)
url <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">"</span>https://www.gravatar.com/avatar/<span class="pl-pse">#{</span><span class="pl-s1">hash</span><span class="pl-pse"><span class="pl-s1">}</span></span>?d=404<span class="pl-pds">"</span></span>
response <span class="pl-k">-</span> <span class="pl-c1">OSM</span>.http_client.get(<span class="pl-c1">URI</span>.parse(url))
user.image_use_gravatar <span class="pl-k">=</span> response.success?
<span class="pl-k">end</span></pre></div>
<p>Obviously the tests also need to pass...</p>
<p>My only other comment would be, if the current behaviour violates the privacy policy then does this actually fix it? We are still automatically enabling it for anybody that has a gravatar after alll...</p>
<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br>Reply to this email directly or <a href="https://github.com/openstreetmap/openstreetmap-website/pull/1036#issuecomment-132722622">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABWnLTVP4CGprDVDznWWYKRcl_-FB5v7ks5opLvmgaJpZM4Ft4-4.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
<link itemprop="url" href="https://github.com/openstreetmap/openstreetmap-website/pull/1036#issuecomment-132722622"></link>
<meta itemprop="name" content="View Pull Request"></meta>
</div>
<meta itemprop="description" content="View this Pull Request on GitHub"></meta>
</div>