diff --git a/cmd/insert-user/main.go b/cmd/insert-user/main.go index 53c679a..461bb2e 100644 --- a/cmd/insert-user/main.go +++ b/cmd/insert-user/main.go @@ -31,16 +31,11 @@ func main() { var ( repoPath string - role roomdb.Role + role roomdb.Role = roomdb.RoleAdmin ) flag.StringVar(&repoPath, "repo", filepath.Join(u.HomeDir, ".ssb-go-room"), "where the repo of the room is located") flag.Func("role", "which role the new member should have (ie moderator, admin, member. defaults to admin)", func(val string) error { - if val == "" { - role = roomdb.RoleAdmin - return nil - } - switch strings.ToLower(val) { case "admin": role = roomdb.RoleAdmin @@ -58,7 +53,7 @@ func main() { flag.Parse() - if len(os.Args) != 2 { + if len(os.Args) != 3 { fmt.Fprintf(os.Stderr, "usage: %s <@theirPublicKey.ed25519>\n", os.Args[0]) flag.Usage() os.Exit(1) @@ -70,7 +65,8 @@ func main() { check(err) defer db.Close() - pubKey, err := refs.ParseFeedRef(os.Args[1]) + pubKey, err := refs.ParseFeedRef(os.Args[2]) + check(err) fmt.Fprintln(os.Stderr, "Enter Password: ") bytePassword, err := terminal.ReadPassword(int(syscall.Stdin)) diff --git a/cmd/server/main.go b/cmd/server/main.go index 7abc7ef..387c1f0 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -247,7 +247,7 @@ func runroomsrv() error { handlers.Databases{ Aliases: db.Aliases, AuthFallback: db.AuthFallback, - DeniedList: db.DeniedList, + DeniedKeys: db.DeniedKeys, Invites: db.Invites, Notices: db.Notices, Members: db.Members, diff --git a/muxrpc/test/go/alias_test.go b/muxrpc/test/go/alias_test.go index 3228e9d..821d3fa 100644 --- a/muxrpc/test/go/alias_test.go +++ b/muxrpc/test/go/alias_test.go @@ -9,8 +9,6 @@ import ( "testing" "time" - "github.com/ssb-ngi-pointer/go-ssb-room/roomdb" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.cryptoscope.co/muxrpc/v2" @@ -18,6 +16,7 @@ import ( "github.com/ssb-ngi-pointer/go-ssb-room/aliases" "github.com/ssb-ngi-pointer/go-ssb-room/internal/maybemod/keys" + "github.com/ssb-ngi-pointer/go-ssb-room/roomdb" "github.com/ssb-ngi-pointer/go-ssb-room/roomsrv" ) diff --git a/web/handlers/admin/invites_test.go b/web/handlers/admin/invites_test.go index e1e2d41..3eeb452 100644 --- a/web/handlers/admin/invites_test.go +++ b/web/handlers/admin/invites_test.go @@ -102,6 +102,7 @@ func TestInvitesCreateForm(t *testing.T) { func TestInvitesCreate(t *testing.T) { ts := newSession(t) a := assert.New(t) + r := require.New(t) urlTo := web.NewURLTo(ts.Router) urlRemove := urlTo(router.AdminInvitesCreate) @@ -114,7 +115,7 @@ func TestInvitesCreate(t *testing.T) { }) a.Equal(http.StatusOK, rec.Code) - a.Equal(1, ts.InvitesDB.CreateCallCount()) + r.Equal(1, ts.InvitesDB.CreateCallCount(), "expected one invites.Create call") _, userID, aliasSuggestion := ts.InvitesDB.CreateArgsForCall(0) a.EqualValues(ts.User.ID, userID) a.EqualValues("jerry", aliasSuggestion) diff --git a/web/handlers/admin/setup_test.go b/web/handlers/admin/setup_test.go index d04f045..0dfb85f 100644 --- a/web/handlers/admin/setup_test.go +++ b/web/handlers/admin/setup_test.go @@ -36,7 +36,7 @@ type testSession struct { MembersDB *mockdb.FakeMembersService PinnedDB *mockdb.FakePinnedNoticesService - User *roomdb.Member + User roomdb.Member Domain string @@ -63,7 +63,7 @@ func newSession(t *testing.T) *testSession { ts.Domain = randomString(10) // fake user - ts.User = &roomdb.Member{ + ts.User = roomdb.Member{ ID: 1234, Nickname: "room mate", Role: roomdb.RoleModerator, @@ -81,7 +81,7 @@ func newSession(t *testing.T) *testSession { return msgID + "Plural" } testFuncs["current_page_is"] = func(routeName string) bool { return true } - testFuncs["is_logged_in"] = func() *roomdb.Member { return ts.User } + testFuncs["is_logged_in"] = func() *roomdb.Member { return &ts.User } testFuncs["urlToNotice"] = func(name string) string { return "" } testFuncs["relative_time"] = func(when time.Time) string { return humanize.Time(when) } diff --git a/web/handlers/http.go b/web/handlers/http.go index bd86fab..729c2c2 100644 --- a/web/handlers/http.go +++ b/web/handlers/http.go @@ -46,7 +46,7 @@ var HTMLTemplates = []string{ type Databases struct { Aliases roomdb.AliasesService AuthFallback roomdb.AuthFallbackService - DeniedList roomdb.DeniedListService + DeniedKeys roomdb.DeniedKeysService Invites roomdb.InvitesService Notices roomdb.NoticesService Members roomdb.MembersService @@ -234,9 +234,10 @@ func New( roomState, admin.Databases{ Aliases: dbs.Aliases, - Members: dbs.Members, + DeniedKeys: dbs.DeniedKeys, Invites: dbs.Invites, Notices: dbs.Notices, + Members: dbs.Members, PinnedNotices: dbs.PinnedNotices, }, ) diff --git a/web/i18n/defaults/active.en.toml b/web/i18n/defaults/active.en.toml index 9ba6bbd..3e3a80d 100644 --- a/web/i18n/defaults/active.en.toml +++ b/web/i18n/defaults/active.en.toml @@ -22,12 +22,19 @@ AdminAliasesTitle = "Aliases" AdminAliasesWelcome = "Here you can see and revoke the registered aliases of this room." AdminAliasesRevoke = "Revoke" -AdminAllowListTitle = "Members" -AdminAllowListWelcome = "Here you can see all the members of the room and ways to add new ones (by their SSB ID) or remove exising ones." -AdminAllowListAdd = "Add" -AdminAllowListRemove = "Remove" -AdminAllowListRemoveConfirmWelcome = "Are you sure you want to remove this member? They will lose their alias, if they have one." -AdminAllowListRemoveConfirmTitle = "Confirm member removal" +AdminDeniedKeysTitle = "Denied Public Keys" +AdminDeniedKeysWelcome = "This page can be used to ban/block SSB IDs so that they can't access the room any more." +AdminDeniedKeysAdd = "Add" +AdminDeniedKeysRemove = "Remove" +AdminDeniedKeysRemoveConfirmWelcome = "Are you sure you want to remove this member? They will lose their alias, if they have one." +AdminDeniedKeysRemoveConfirmTitle = "Confirm member removal" + +AdminMembersTitle = "Members" +AdminMembersWelcome = "Here you can see all the members of the room and ways to add new ones (by their SSB ID) or remove exising ones." +AdminMembersAdd = "Add" +AdminMembersRemove = "Remove" +AdminMembersRemoveConfirmWelcome = "Are you sure you want to remove this member? They will lose their alias, if they have one." +AdminMembersRemoveConfirmTitle = "Confirm member removal" AdminInvitesTitle = "Invites" AdminInvitesWelcome = "Create invite tokens for people who are not yet members of this room. At the same time as you create an invite, you can also (optionally) attach an alias to it so that the person who receives the invite can automatically use that claim that alias for themselves." diff --git a/web/templates/menu.tmpl b/web/templates/menu.tmpl index d6b69f1..59e2ca6 100644 --- a/web/templates/menu.tmpl +++ b/web/templates/menu.tmpl @@ -33,7 +33,16 @@ > - {{i18n "AdminAllowListTitle"}} + {{i18n "AdminMembersTitle"}} + + + + + + {{i18n "AdminDeniedKeysTitle"}}