Esempio n. 1
0
def get_members_backend(
    request: HttpRequest,
    user_profile: UserProfile,
    include_custom_profile_fields: bool = REQ(validator=check_bool,
                                              default=False),
    client_gravatar: bool = REQ(validator=check_bool, default=False)
) -> HttpResponse:
    '''
    The client_gravatar field here is set to True if clients can compute
    their own gravatars, which saves us bandwidth.  We want to eventually
    make this the default behavior, but we have old clients that expect
    the server to compute this for us.
    '''
    realm = user_profile.realm
    if realm.email_address_visibility == Realm.EMAIL_ADDRESS_VISIBILITY_ADMINS:
        # If email addresses are only available to administrators,
        # clients cannot compute gravatars, so we force-set it to false.
        client_gravatar = False
    members = get_raw_user_data(
        realm,
        user_profile=user_profile,
        client_gravatar=client_gravatar,
        for_api=True,
        include_custom_profile_fields=include_custom_profile_fields)
    return json_success({'members': members.values()})
Esempio n. 2
0
    def test_get_raw_user_data_on_system_bot_realm(self) -> None:
        result = get_raw_user_data(get_realm("zulipinternal"),
                                   self.example_user('hamlet'),
                                   client_gravatar=True,
                                   user_avatar_url_field_optional=True)

        for bot_email in settings.CROSS_REALM_BOT_EMAILS:
            bot_profile = get_system_bot(bot_email)
            self.assertTrue(bot_profile.id in result)
            self.assertTrue(result[bot_profile.id]['is_cross_realm_bot'])