diff --git a/roomdb/sqlite/invites.go b/roomdb/sqlite/invites.go index a771142..560c836 100644 --- a/roomdb/sqlite/invites.go +++ b/roomdb/sqlite/invites.go @@ -228,6 +228,7 @@ func (i Invites) List(ctx context.Context) ([]roomdb.Invite, error) { entries, err := models.Invites( qm.Where("active = true"), qm.Load("CreatedByMember"), + qm.Load("CreatedByMember.Aliases"), ).All(ctx, tx) if err != nil { return err diff --git a/roomdb/sqlite/invites_test.go b/roomdb/sqlite/invites_test.go index e05d7c3..1f5a127 100644 --- a/roomdb/sqlite/invites_test.go +++ b/roomdb/sqlite/invites_test.go @@ -59,6 +59,11 @@ func TestInvites(t *testing.T) { mid, err := db.Members.Add(ctx, invitingMember, roomdb.RoleModerator) require.NoError(t, err, "failed to create test user") + aliasString := "alias" + + err = db.Aliases.Register(ctx, aliasString, invitingMember, []byte("signature")) + require.NoError(t, err, "failed to create an alias for the test user") + t.Run("simple create and consume", func(t *testing.T) { r := require.New(t) @@ -76,6 +81,8 @@ func TestInvites(t *testing.T) { r.Len(lst, 1, "expected 1 invite") r.True(lst[0].CreatedAt.After(before), "expected CreatedAt to be after the start marker") + r.NotEmpty(lst[0].CreatedBy.Aliases, "expected aliases of the user to be populated") + r.Equal(aliasString, lst[0].CreatedBy.Aliases[0].Name, "alias name should be populated") _, nope := db.Members.GetByFeed(ctx, newMember) r.Error(nope, "expected feed to not yet be on the allow list") diff --git a/web/handlers/admin/invites_test.go b/web/handlers/admin/invites_test.go index 90d3d21..6d7735a 100644 --- a/web/handlers/admin/invites_test.go +++ b/web/handlers/admin/invites_test.go @@ -64,10 +64,16 @@ func TestInvitesOverview(t *testing.T) { elems := html.Find(trSelector) a.EqualValues(1, elems.Length()/2, "wrong number of entries on the table (signular)") - // check for link to remove confirm link - link, yes := elems.Find("a").Attr("href") + // check for the link to member details + link, yes := elems.Find("a").Eq(0).Attr("href") a.True(yes, "a-tag has href attribute") - wantURL := ts.URLTo(router.AdminInvitesRevokeConfirm, "id", 666) + wantURL := ts.URLTo(router.AdminMemberDetails, "id", testUser.ID) + a.Equal(wantURL.String(), link) + + // check for link to remove confirm link + link, yes = elems.Find("a").Eq(1).Attr("href") + a.True(yes, "a-tag has href attribute") + wantURL = ts.URLTo(router.AdminInvitesRevokeConfirm, "id", 666) a.Equal(wantURL.String(), link) testInviteButtonDisabled := func(shouldBeDisabled bool) { diff --git a/web/templates/admin/invite-list.tmpl b/web/templates/admin/invite-list.tmpl index 990cbe0..a54baaa 100644 --- a/web/templates/admin/invite-list.tmpl +++ b/web/templates/admin/invite-list.tmpl @@ -75,11 +75,13 @@ SPDX-License-Identifier: CC-BY-4.0 - {{if eq $creatorIsAlias true}} - {{$creator}} - {{else}} - {{$creator}} - {{end}} + + {{if eq $creatorIsAlias true}} + {{$creator}} + {{else}} + {{$creator}} + {{end}} + {{ if or member_is_elevated $hasCreatedInvite }}