mirror of
https://github.com/github-tijlxyz/khatru-pyramid.git
synced 2025-04-19 18:31:18 +00:00
fix isAncestorOf() and remove button.
This commit is contained in:
parent
8885d99cac
commit
262d64ef40
@ -27,7 +27,7 @@ func userRowComponent(ctx context.Context, profile sdk.ProfileMetadata, loggedUs
|
||||
"hx-post", "/remove-from-whitelist",
|
||||
"hx-trigger", "click",
|
||||
"hx-target", "#tree",
|
||||
"hx-vals", `{"profile.pubkey": "`+profile.PubKey+`"}`,
|
||||
"hx-vals", `{"pubkey": "`+profile.PubKey+`"}`,
|
||||
)
|
||||
}
|
||||
|
||||
|
30
whitelist.go
30
whitelist.go
@ -34,23 +34,21 @@ func isPublicKeyInWhitelist(pubkey string) bool {
|
||||
return ok
|
||||
}
|
||||
|
||||
func isAncestorOf(pubkey string, target string) bool {
|
||||
ancestor := target // we must find out if we are an ancestor of the target, but we can delete ourselves
|
||||
for {
|
||||
if ancestor == pubkey {
|
||||
break
|
||||
}
|
||||
|
||||
parent, ok := whitelist[ancestor]
|
||||
if !ok {
|
||||
// parent is not in whitelist, this means this is a top-level user and can
|
||||
// only be deleted by manually editing the users.json file
|
||||
return false
|
||||
}
|
||||
|
||||
ancestor = parent
|
||||
func isAncestorOf(ancestor string, target string) bool {
|
||||
parent, ok := whitelist[target]
|
||||
if !ok {
|
||||
// parent is not in whitelist, this means this is a top-level user and can
|
||||
// only be deleted by manually editing the users.json file
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
||||
if parent == ancestor {
|
||||
// if the pubkey is the parent, that means it is an ancestor
|
||||
return true
|
||||
}
|
||||
|
||||
// otherwise we climb one degree up and test with the parent of the target
|
||||
return isAncestorOf(ancestor, parent)
|
||||
}
|
||||
|
||||
func removeFromWhitelist(target string, deleter string) error {
|
||||
|
Loading…
x
Reference in New Issue
Block a user