changeset 1c74e60a2463 in trypod:default
details: https://hg.tryton.org/trypod?cmd=changeset;node=1c74e60a2463
description:
        Add avatar to logged user
diffstat:

 trypod.py |  8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diffs (28 lines):

diff -r bdbb319395de -r 1c74e60a2463 trypod.py
--- a/trypod.py Sat Mar 30 18:21:11 2019 +0100
+++ b/trypod.py Thu Dec 05 19:04:40 2019 +0100
@@ -1,3 +1,4 @@
+import hashlib
 import httplib
 import os
 import json
@@ -118,6 +119,7 @@
                 'realname': user._realname,
                 'address': user._address,
                 'token': None,  # TODO
+                'avatar': avatar(user._address),
                 })
     abort(404)
 
@@ -323,5 +325,11 @@
         if _normalize_name(lname) == name:
             return hg.repository(lui, path)
 
+
+def avatar(email):
+    digest = hashlib.md5(email.strip()).hexdigest()
+    return 'https://www.gravatar.com/avatar/' + digest
+
+
 if __name__ == '__main__':
     app.run(host='0.0.0.0', debug=True)

Reply via email to