<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/xhtml; charset=utf-8">
<style>
div.markdown { white-space: normal; }
body { font-family: sans-serif; }
h1 { font-size: 1.4em; }
h2 { font-size: 1.2em; }
h3 { font-size: 1.1em; }
blockquote { margin: 0 0 5px; padding-left: 5px; border-left: 2px solid #777777; color: #777777; }
blockquote blockquote { border-left-color: #999999; color: #999999; }
blockquote blockquote blockquote { border-left-color: #BBBBBB; color: #BBBBBB; }
a { color: #3983C4; }
blockquote a { color: #777777; }
blockquote blockquote a { color: #999999; }
blockquote blockquote blockquote a { color: #BBBBBB; }
pre { margin-left: 15px; margin-right: 15px; padding: 5px; background-color: #F7F7F7; border-radius: 5px 5px 5px 5px; overflow-x: auto; max-width: 90vw; }
pre.highlighted { color: black; }
code { margin: 0; padding: 0 0.4em; border-radius: 3px; background-color: #F7F7F7; }
pre > code { padding: 0px; }
math[display="inline"] > mrow { padding:5px; }
div.footnotes li p { margin: 0.2em 0; }
</style>
</head>
<body>
<div class="markdown">
<p dir="auto">On 21 Feb 2019, at 15:35, Benny Kjær Nielsen wrote:</p>
<blockquote>
<p dir="auto">I still haven't integrated MailMate with images from Contacts, but I realized that it was fairly easy to use the <a href="https://www.gravatar.com">Gravatar</a> service.</p>
</blockquote>
<p dir="auto">One alternative could be use <a href="https://www.libravatar.org/">Libravatar</a> and its <a href="https://wiki.libravatar.org/api/">federated api</a> which makes it possible to run your own avatar server. </p>
<p dir="auto">Since MailMate doesn't support the federated api (yet) one could use Apache installed on macOS to redirect or reverse proxy to different avatar servers.</p>
<p dir="auto">I.e. change <code>headersFormatting.plist</code> to something like:</p>
<pre class="highlighted"><code><span style="color: #A00000">--- headersFormatting-2.plist 2019-03-01 00:18:48.000000000 +0100</span>
<span style="color: #00A000">+++ headersFormatting.plist 2019-03-01 00:41:08.000000000 +0100</span>
<span style="color: #800080; font-weight: bold">@@ -5,7 +5,7 @@</span>
(
// Gravatar example with link
{
<span style="color: #A00000">- formatString = "<a href=\"https://www.gravatar.com/${from.address.#md5}\"><img style=\"float: left; height: 60px;\" src=\"https://www.gravatar.com/avatar/${from.address.#md5}\"/></a>";</span>
<span style="color: #00A000">+ formatString = "<img style=\"float: left; height: 60px;\" src=\"http://localhost/avatar/${from.address.#md5}?s=60&d=identicon\" srcset=\"http://localhost/avatar/${from.address.#md5}?s=60&d=identicon 1x, http://localhost/avatar/${from.address.#md5}?s=90&d=identicon 1.5x,http://localhost/avatar/${from.address.#md5}?s=120&d=identicon 2x\"/>";</span>
},
{
separator = { string = "\n"; };
</code></pre>
<p dir="auto">and by <a href="https://httpd.apache.org/docs/current/rewrite/rewritemap.html">using Apache RewriteMap</a>, redirect </p>
<pre class="highlighted"><code><span style="color: #007020">LoadModule</span> ssl_module libexec/apache2/mod_ssl.so
<span style="color: #007020">LoadModule</span> rewrite_module libexec/apache2/mod_rewrite.so
<span style="color: #007700"><VirtualHost</span> <span style="background-color: #fff0f0">localhost:80</span><span style="color: #007700">></span>
<span style="color: #007020">CustomLog</span> <span style="color: #DD2200; background-color: #fff0f0">/var/log/apache2/avatar-rewrite-access.log</span> combined
<span style="color: #007020">ErrorLog</span> <span style="color: #DD2200; background-color: #fff0f0">/var/log/apache2/avatar-rewrite-error.log</span>
<span style="color: #007020">SSLProxyEngine</span> <span style="color: #008800; font-weight: bold">On</span>
<span style="color: #007020">RewriteEngine</span> <span style="color: #008800; font-weight: bold">On</span>
<span style="color: #007020">RewriteMap</span> hash2avatarurl <span style="background-color: #fff0f0">"txt:/Library/WebServer/hash2avatarurl.txt"</span>
<span style="color: #007020">RewriteRule</span> <span style="background-color: #fff0f0">"^/avatar/(.*)"</span> <span style="background-color: #fff0f0">"${hash2avatarurl:$1|https://www.gravatar.com/avatar/00000000000000000000000000000000}"</span> [R,L]
<span style="color: #007700"></VirtualHost></span>
</code></pre>
<p dir="auto">or reverse proxy</p>
<pre class="highlighted"><code><span style="color: #007020">LoadModule</span> proxy_module libexec/apache2/mod_proxy.so
<span style="color: #007020">LoadModule</span> proxy_http_module libexec/apache2/mod_proxy_http.so
<span style="color: #007020">LoadModule</span> ssl_module libexec/apache2/mod_ssl.so
<span style="color: #007020">LoadModule</span> rewrite_module libexec/apache2/mod_rewrite.so
<span style="color: #007020">LoadModule</span> cache_module libexec/apache2/mod_cache.so
<span style="color: #007020">LoadModule</span> cache_socache_module libexec/apache2/mod_cache_socache.so
<span style="color: #007020">LoadModule</span> socache_shmcb_module libexec/apache2/mod_socache_shmcb.so
<span style="color: #007700"><VirtualHost</span> <span style="background-color: #fff0f0">localhost:80</span><span style="color: #007700">></span>
<span style="color: #007020">LogLevel</span> <span style="color: #008800; font-weight: bold">info</span> rewrite:trace3 socache_shmcb:debug
<span style="color: #007020">CustomLog</span> <span style="color: #DD2200; background-color: #fff0f0">/var/log/apache2/avatar-proxy-access.log</span> combined
<span style="color: #007020">ErrorLog</span> <span style="color: #DD2200; background-color: #fff0f0">/var/log/apache2/avatar-proxy-error.log</span>
<span style="color: #007020">CacheSocache</span> shmcb:/var/tmp/avatarproxyshmcbcache(512000)
<span style="color: #007020">CacheQuickHandler</span> <span style="color: #008800; font-weight: bold">off</span>
<span style="color: #007020">CacheStoreExpired</span> <span style="color: #008800; font-weight: bold">On</span>
<span style="color: #007020">CacheIgnoreNoLastMod</span> <span style="color: #008800; font-weight: bold">On</span>
<span style="color: #007020">CacheIgnoreCacheControl</span> <span style="color: #008800; font-weight: bold">On</span>
<span style="color: #007020">CacheDefaultExpire</span> <span style="color: #6600EE; font-weight: bold">86400</span>
<span style="color: #007020">CacheMinExpire</span> <span style="color: #6600EE; font-weight: bold">86400</span>
<span style="color: #007020">CacheMaxExpire</span> <span style="color: #6600EE; font-weight: bold">604800</span>
<span style="color: #007020">CacheHeader</span> <span style="color: #008800; font-weight: bold">On</span>
<span style="color: #007020">CacheDetailHeader</span> <span style="color: #008800; font-weight: bold">On</span>
<span style="color: #007700"><Location</span> <span style="background-color: #fff0f0">"/avatar"</span><span style="color: #007700">></span>
<span style="color: #007020">CacheEnable</span> socache
<span style="color: #007700"></Location></span>
<span style="color: #007020">SSLProxyEngine</span> <span style="color: #008800; font-weight: bold">on</span>
<span style="color: #007020">RewriteEngine</span> <span style="color: #008800; font-weight: bold">On</span>
<span style="color: #007020">RewriteMap</span> hash2avatarurl <span style="background-color: #fff0f0">"dbm:/Library/WebServer/hash2avatarurl.dbm"</span>
<span style="color: #007020">RewriteRule</span> <span style="background-color: #fff0f0">"^/avatar/(.*)"</span> <span style="background-color: #fff0f0">"${hash2avatarurl:$1|https://www.gravatar.com/avatar/00000000000000000000000000000000}"</span> [P]
<span style="color: #007700"></VirtualHost></span>
</code></pre>
<p dir="auto">where <code>hash2avatarurl.txt</code> looks like:</p>
<pre class="highlighted"><code>54d652cfd5beed169d4d585b134c65e1 https://secure.gravatar.com/avatar/54d652cfd5beed169d4d585b134c65e1
967b1e0903bb424fdf75fa38bcaf9af0 https://seccdn.libravatar.org/avatar/967b1e0903bb424fdf75fa38bcaf9af0
</code></pre>
</div>
</body>
</html>