示例#1
0
文件: avatar.py 项目: 8trust/zulip
def user_avatar_hash(email):
    # Salting the user_key may be overkill, but it prevents us from
    # basically mimicking Gravatar's hashing scheme, which could lead
    # to some abuse scenarios like folks using us as a free Gravatar
    # replacement.
    user_key = email.lower() + settings.AVATAR_SALT
    return make_safe_digest(user_key, hashlib.sha1)
def user_avatar_hash(email):
    # Salting the user_key may be overkill, but it prevents us from
    # basically mimicking Gravatar's hashing scheme, which could lead
    # to some abuse scenarios like folks using us as a free Gravatar
    # replacement.
    user_key = email.lower() + settings.AVATAR_SALT
    return make_safe_digest(user_key, hashlib.sha1)
示例#3
0
def gravatar_hash(email: Text) -> Text:
    """Compute the Gravatar hash for an email address."""
    # Non-ASCII characters aren't permitted by the currently active e-mail
    # RFCs. However, the IETF has published https://tools.ietf.org/html/rfc4952,
    # outlining internationalization of email addresses, and regardless if we
    # typo an address or someone manages to give us a non-ASCII address, let's
    # not error out on it.
    return make_safe_digest(email.lower(), hashlib.md5)
def gravatar_hash(email):
    """Compute the Gravatar hash for an email address."""
    # Non-ASCII characters aren't permitted by the currently active e-mail
    # RFCs. However, the IETF has published https://tools.ietf.org/html/rfc4952,
    # outlining internationalization of email addresses, and regardless if we
    # typo an address or someone manages to give us a non-ASCII address, let's
    # not error out on it.
    return make_safe_digest(email.lower(), hashlib.md5)
示例#5
0
def get_stream_cache_key(stream_name, realm):
    from zerver.models import Realm
    if isinstance(realm, Realm):
        realm_id = realm.id
    else:
        realm_id = realm
    return "stream_by_realm_and_name:%s:%s" % (
        realm_id, make_safe_digest(stream_name.strip().lower()))
示例#6
0
文件: cache.py 项目: anteq/zulip
def get_stream_cache_key(stream_name, realm):
    from zerver.models import Realm
    if isinstance(realm, Realm):
        realm_id = realm.id
    else:
        realm_id = realm
    return "stream_by_realm_and_name:%s:%s" % (
        realm_id, make_safe_digest(stream_name.strip().lower()))
示例#7
0
文件: cache.py 项目: rlugojr/zulip
def get_stream_cache_key(stream_name, realm):
    # type: (text_type, Union[Realm, int]) -> text_type
    from zerver.models import Realm

    if isinstance(realm, Realm):
        realm_id = realm.id
    else:
        realm_id = realm
    return u"stream_by_realm_and_name:%s:%s" % (realm_id, make_safe_digest(stream_name.strip().lower()))
示例#8
0
def get_stream_cache_key(stream_name, realm):
    # type: (text_type, Union[Realm, int]) -> text_type
    from zerver.models import Realm
    if isinstance(realm, Realm):
        realm_id = realm.id
    else:
        realm_id = realm
    return u"stream_by_realm_and_name:%s:%s" % (
        realm_id, make_safe_digest(stream_name.strip().lower()))
示例#9
0
def user_avatar_hash(uid: Text) -> Text:

    # WARNING: If this method is changed, you may need to do a migration
    # similar to zerver/migrations/0060_move_avatars_to_be_uid_based.py .

    # The salt probably doesn't serve any purpose now.  In the past we
    # used a hash of the email address, not the user ID, and we salted
    # it in order to make the hashing scheme different from Gravatar's.
    user_key = uid + settings.AVATAR_SALT
    return make_safe_digest(user_key, hashlib.sha1)
示例#10
0
def user_avatar_hash(uid: str) -> str:

    # WARNING: If this method is changed, you may need to do a migration
    # similar to zerver/migrations/0060_move_avatars_to_be_uid_based.py .

    # The salt probably doesn't serve any purpose now.  In the past we
    # used a hash of the email address, not the user ID, and we salted
    # it in order to make the hashing scheme different from Gravatar's.
    user_key = uid + settings.AVATAR_SALT
    return make_safe_digest(user_key, hashlib.sha1)
示例#11
0
文件: cache.py 项目: JamesLinus/zulip
def user_profile_cache_key(email, realm):
    # type: (Text, Realm) -> Text
    return u"user_profile:%s:%s" % (make_safe_digest(email.strip()), realm.id,)
示例#12
0
文件: cache.py 项目: ldirer/zulip
def open_graph_description_cache_key(content: bytes, request: HttpRequest) -> str:
    return "open_graph_description_path:{}".format(make_safe_digest(request.META["PATH_INFO"]))
def patched_user_avatar_path(user_profile: UserProfile) -> Text:
    email = user_profile.email
    user_key = email.lower() + settings.AVATAR_SALT
    return make_safe_digest(user_key, hashlib.sha1)
示例#14
0
def open_graph_description_cache_key(content: Any,
                                     request: HttpRequest) -> str:
    return 'open_graph_description_path:{}'.format(
        make_safe_digest(request.META['PATH_INFO']))
示例#15
0
文件: cache.py 项目: BakerWang/zulip
def open_graph_description_cache_key(content: Any, request: HttpRequest) -> str:
    return 'open_graph_description_path:%s' % (make_safe_digest(request.META['PATH_INFO']))
示例#16
0
def get_stream_cache_key(stream_name: str, realm_id: int) -> str:
    return "stream_by_realm_and_name:%s:%s" % (
        realm_id, make_safe_digest(stream_name.strip().lower()))
示例#17
0
def bot_profile_cache_key(email: str) -> str:
    return "bot_profile:%s" % (make_safe_digest(email.strip()))
示例#18
0
def get_stream_cache_key(stream_name, realm_id):
    # type: (Text, int) -> Text
    return u"stream_by_realm_and_name:%s:%s" % (
        realm_id, make_safe_digest(stream_name.strip().lower()))
示例#19
0
def user_profile_cache_key_id(email, realm_id):
    # type: (Text, int) -> Text
    return u"user_profile:%s:%s" % (
        make_safe_digest(email.strip()),
        realm_id,
    )
示例#20
0
文件: cache.py 项目: JamesLinus/zulip
def bot_profile_cache_key(email):
    # type: (Text) -> Text
    return u"bot_profile:%s" % (make_safe_digest(email.strip()))
示例#21
0
def get_client_cache_key(name):
    return 'get_client:%s' % (make_safe_digest(name), )
示例#22
0
def get_stream_cache_key(stream_name, realm_id):
    # type: (Text, int) -> Text
    return u"stream_by_realm_and_name:%s:%s" % (
        realm_id, make_safe_digest(stream_name.strip().lower()))
示例#23
0
def bot_profile_cache_key(email):
    # type: (Text) -> Text
    return u"bot_profile:%s" % (make_safe_digest(email.strip()))
示例#24
0
def user_profile_cache_key(email, realm):
    # type: (Text, Realm) -> Text
    return u"user_profile:%s:%s" % (make_safe_digest(email.strip()), realm.id,)
示例#25
0
def get_huddle_hash(id_list):
    id_list = sorted(set(id_list))
    hash_key = ",".join(str(x) for x in id_list)
    return make_safe_digest(hash_key)
示例#26
0
文件: models.py 项目: handelxh/zulip
def get_huddle_hash(id_list):
    id_list = sorted(set(id_list))
    hash_key = ",".join(str(x) for x in id_list)
    return make_safe_digest(hash_key)
示例#27
0
def user_profile_by_email_cache_key(email):
    # type: (text_type) -> text_type
    # See the comment in zerver/lib/avatar_hash.py:gravatar_hash for why we
    # are proactively encoding email addresses even though they will
    # with high likelihood be ASCII-only for the foreseeable future.
    return u'user_profile_by_email:%s' % (make_safe_digest(email.strip()), )
示例#28
0
def preview_url_cache_key(url: str) -> str:
    return "preview_url:%s" % (make_safe_digest(url))
示例#29
0
def user_profile_by_email_cache_key(email):
    # type: (Text) -> Text
    # See the comment in zerver/lib/avatar_hash.py:gravatar_hash for why we
    # are proactively encoding email addresses even though they will
    # with high likelihood be ASCII-only for the foreseeable future.
    return u'user_profile_by_email:%s' % (make_safe_digest(email.strip()),)
示例#30
0
def user_profile_cache_key_id(email: str, realm_id: int) -> str:
    return u"user_profile:%s:%s" % (make_safe_digest(email.strip()), realm_id,)
示例#31
0
文件: models.py 项目: handelxh/zulip
def get_client_cache_key(name):
    return 'get_client:%s' % (make_safe_digest(name),)
示例#32
0
def user_profile_cache_key_id(email, realm_id):
    # type: (Text, int) -> Text
    return u"user_profile:%s:%s" % (make_safe_digest(email.strip()), realm_id,)