mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 09:27:43 +00:00
Factor out Gravatar hash calculation
(imported from commit 29872722fb4856773d98fc987a1e2d6eb99ad8b2)
This commit is contained in:
5
zephyr/lib/avatar.py
Normal file
5
zephyr/lib/avatar.py
Normal file
@@ -0,0 +1,5 @@
|
||||
import hashlib
|
||||
|
||||
def gravatar_hash(email):
|
||||
"""Compute the Gravatar hash for an email address."""
|
||||
return hashlib.md5(email.lower()).hexdigest()
|
||||
@@ -10,6 +10,7 @@ import os
|
||||
import simplejson
|
||||
from django.db import transaction
|
||||
from zephyr.lib import bugdown
|
||||
from zephyr.lib.avatar import gravatar_hash
|
||||
|
||||
@cache_with_key(lambda self: 'display_recipient_dict:%d' % (self.id))
|
||||
def get_display_recipient(recipient):
|
||||
@@ -219,7 +220,7 @@ class Message(models.Model):
|
||||
'subject' : self.subject,
|
||||
'content' : content,
|
||||
'timestamp' : calendar.timegm(self.pub_date.timetuple()),
|
||||
'gravatar_hash' : hashlib.md5(self.sender.user.email.lower()).hexdigest(),
|
||||
'gravatar_hash' : gravatar_hash(self.sender.user.email),
|
||||
}
|
||||
|
||||
def to_log_dict(self):
|
||||
|
||||
@@ -19,6 +19,7 @@ from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
from zephyr.decorator import asynchronous
|
||||
from zephyr.lib.query import last_n
|
||||
from zephyr.lib.avatar import gravatar_hash
|
||||
|
||||
from confirmation.models import Confirmation
|
||||
|
||||
@@ -26,7 +27,6 @@ import datetime
|
||||
import simplejson
|
||||
import socket
|
||||
import re
|
||||
import hashlib
|
||||
import urllib
|
||||
import time
|
||||
|
||||
@@ -186,7 +186,7 @@ def home(request):
|
||||
|
||||
return render_to_response('zephyr/index.html',
|
||||
{'user_profile': user_profile,
|
||||
'email_hash' : hashlib.md5(user_profile.user.email).hexdigest(),
|
||||
'email_hash' : gravatar_hash(user_profile.user.email),
|
||||
'people' : people,
|
||||
'streams' : streams,
|
||||
'have_initial_messages':
|
||||
|
||||
Reference in New Issue
Block a user