コード例 #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)
コード例 #2
0
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
ファイル: avatar_hash.py プロジェクト: gnprice/zulip
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)
コード例 #4
0
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
ファイル: cache.py プロジェクト: shubhsingh594/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()))
コード例 #9
0
ファイル: avatar_hash.py プロジェクト: gnprice/zulip
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"]))
コード例 #13
0
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
ファイル: cache.py プロジェクト: winning1120xx/zulip
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
ファイル: cache.py プロジェクト: brockwhittaker/zulip
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
ファイル: cache.py プロジェクト: shubhsingh594/zulip
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
ファイル: cache.py プロジェクト: TomaszKolek/zulip
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
ファイル: cache.py プロジェクト: joydeep1701/zulip
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,)