mirror of https://github.com/zulip/zulip.git
invites: Send user_id of the referrer instead of email in invites dict.
We send user_id of the referrer instead of email in the invites dict. Sending user_ids is more robust, as those are an immutable reference to a user, rather than something that can change with time. Updates to the webapp UI to display the inviters for more convenient inspection will come in a future commit.
This commit is contained in:
parent
dc05b5c317
commit
6eb8442a59
|
@ -48,12 +48,14 @@ function populate_invites(invites_data) {
|
|||
item.is_admin = page_params.is_admin;
|
||||
item.disable_buttons = item.invited_as === settings_config.user_role_values.owner.code
|
||||
&& !page_params.is_owner;
|
||||
item.referrer_email = people.get_by_user_id(item.invited_by_user_id).email;
|
||||
return render_admin_invites_list({ invite: item });
|
||||
},
|
||||
filter: {
|
||||
element: invites_table.closest(".settings-section").find(".search"),
|
||||
predicate: function (item, value) {
|
||||
const referrer_email_matched = item.ref.toLowerCase().includes(value);
|
||||
const referrer_email = people.get_by_user_id(item.invited_by_user_id).email;
|
||||
const referrer_email_matched = referrer_email.toLowerCase().includes(value);
|
||||
if (item.is_multiuse) {
|
||||
return referrer_email_matched;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
</td>
|
||||
{{#if is_admin}}
|
||||
<td>
|
||||
<span class="referred_by">{{ref}}</span>
|
||||
<span class="referred_by">{{referrer_email}}</span>
|
||||
</td>
|
||||
{{/if}}
|
||||
<td>
|
||||
|
|
|
@ -12,9 +12,15 @@ below features are supported.
|
|||
|
||||
**Feature level 22**
|
||||
|
||||
* 'GET /attachments': Rename `name` to `date_sent` for clearer meaning
|
||||
and change the data types of the new `date_sent` and `create_time`
|
||||
to integer (previously the implementation could send floats).
|
||||
* `GET /attachments`: The date when a message using the attachment was
|
||||
sent is now correctly encoded as `date_sent`, replacing the
|
||||
confusingly named `name` field. The `date_sent` and `create_time`
|
||||
fields of attachment objects are now encoded as integers;
|
||||
(previously the implementation could send floats incorrectly
|
||||
suggesting that microsecond precision is relevant).
|
||||
* `GET /invites`: Now encodes the user ID of the person who created
|
||||
the invitation as `invited_by_user_id`, replacing the previous
|
||||
`ref` field (which had that user's Zulip display email address).
|
||||
|
||||
**Feature level 21**
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ DESKTOP_WARNING_VERSION = "5.2.0"
|
|||
#
|
||||
# Changes should be accompanied by documentation explaining what the
|
||||
# new level means in templates/zerver/api/changelog.md.
|
||||
API_FEATURE_LEVEL = 21
|
||||
API_FEATURE_LEVEL = 22
|
||||
|
||||
# Bump the minor PROVISION_VERSION to indicate that folks should provision
|
||||
# only when going from an old version of the code to a newer version. Bump
|
||||
|
|
|
@ -5282,7 +5282,7 @@ def do_get_user_invites(user_profile: UserProfile) -> List[Dict[str, Any]]:
|
|||
|
||||
for invitee in prereg_users:
|
||||
invites.append(dict(email=invitee.email,
|
||||
ref=invitee.referred_by.email,
|
||||
invited_by_user_id=invitee.referred_by.id,
|
||||
invited=datetime_to_timestamp(invitee.invited_at),
|
||||
id=invitee.id,
|
||||
invited_as=invitee.invited_as,
|
||||
|
@ -5298,7 +5298,7 @@ def do_get_user_invites(user_profile: UserProfile) -> List[Dict[str, Any]]:
|
|||
date_sent__gte=lowest_datetime)
|
||||
for confirmation_obj in multiuse_confirmation_objs:
|
||||
invite = confirmation_obj.content_object
|
||||
invites.append(dict(ref=invite.referred_by.email,
|
||||
invites.append(dict(invited_by_user_id=invite.referred_by.id,
|
||||
invited=datetime_to_timestamp(confirmation_obj.date_sent),
|
||||
id=invite.id,
|
||||
link_url=confirmation_url(confirmation_obj.confirmation_key,
|
||||
|
|
|
@ -1664,12 +1664,13 @@ class InvitationsTestCase(InviteUserBase):
|
|||
|
||||
result = self.client_get("/json/invites")
|
||||
self.assertEqual(result.status_code, 200)
|
||||
self.assert_in_success_response(
|
||||
["TestOne@zulip.com", hamlet.email],
|
||||
result)
|
||||
self.assert_not_in_success_response(
|
||||
["TestTwo@zulip.com", "TestThree@zulip.com", "othello@zulip.com", othello.email],
|
||||
result)
|
||||
invites = ujson.loads(result.content)["invites"]
|
||||
self.assertEqual(len(invites), 2)
|
||||
|
||||
self.assertFalse(invites[0]["is_multiuse"])
|
||||
self.assertEqual(invites[0]["email"], "TestOne@zulip.com")
|
||||
self.assertTrue(invites[1]["is_multiuse"])
|
||||
self.assertEqual(invites[1]["invited_by_user_id"], hamlet.id)
|
||||
|
||||
def test_successful_delete_invitation(self) -> None:
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue