2017-02-21 03:41:20 +01:00
|
|
|
from django.conf import settings
|
|
|
|
|
|
|
|
from typing import Text
|
|
|
|
|
|
|
|
from zerver.lib.avatar_hash import gravatar_hash, user_avatar_hash
|
|
|
|
from zerver.lib.upload import upload_backend
|
|
|
|
from zerver.models import Realm
|
|
|
|
|
2017-11-05 11:15:10 +01:00
|
|
|
def realm_icon_url(realm: Realm) -> Text:
|
2017-02-21 03:41:20 +01:00
|
|
|
return get_realm_icon_url(realm)
|
|
|
|
|
2017-11-05 11:15:10 +01:00
|
|
|
def get_realm_icon_url(realm: Realm) -> Text:
|
2017-11-03 03:12:25 +01:00
|
|
|
if realm.icon_source == 'U':
|
2017-02-21 03:41:20 +01:00
|
|
|
return upload_backend.get_realm_icon_url(realm.id, realm.icon_version)
|
|
|
|
elif settings.ENABLE_GRAVATAR:
|
2017-03-13 19:48:49 +01:00
|
|
|
hash_key = gravatar_hash(realm.string_id)
|
2017-11-04 05:34:38 +01:00
|
|
|
return "https://secure.gravatar.com/avatar/%s?d=identicon" % (hash_key,)
|
2017-02-21 03:41:20 +01:00
|
|
|
else:
|
|
|
|
return settings.DEFAULT_AVATAR_URI+'?version=0'
|