Self-hosted workflows for coding-agent delivery. Orchestrate CodeBuddy, Codex and Claude Code with scripts and human approval gates. Includes Local workflows for coding assistants.
JavaScript agent-orchestrationagentic-workflowai-agentsai-codingclaude-codecode-reviewcodebuddycodexcoding-agentscursordeveloper-toolshuman-on-the-loopllmmcpmulti-agentsdlcself-hostedsopworkflow-automationworkflow-engine
refactor(httpapi): simplify hasBusinessUser with slices.Contains (#311) (#312)
fx-kurumi6d8dd9554e92
diff --git a/internal/httpapi/business_domains.go b/internal/httpapi/business_domains.goindex f70dfada..e4e31db8 100644--- a/internal/httpapi/business_domains.go+++ b/internal/httpapi/business_domains.go@@ -11,6 +11,7 @@ import ("net/http""reflect""regexp"+ "slices""sort""strings""sync"@@ -25,12 +26,7 @@ type businessDomainsHandlers struct {var businessDomainIDPattern = regexp.MustCompile(`^[a-zA-Z0-9][a-zA-Z0-9_-]{0,63}$`)func hasBusinessUser(ids []int64, id int64) bool {- for _, v := range ids {- if id > 0 && v == id {- return true- }- }- return false+ return id > 0 && slices.Contains(ids, id)}func (h *businessDomainsHandlers) canView(d domain.BusinessDomain, id int64, admin bool) bool {return admin || hasBusinessUser(d.ManagerIDs, id) || hasBusinessUser(d.ViewerIDs, id)diff --git a/internal/httpapi/business_user_test.go b/internal/httpapi/business_user_test.gonew file mode 100644index 00000000..e2a2a067--- /dev/null+++ b/internal/httpapi/business_user_test.go@@ -0,0 +1,23 @@+package httpapi++import "testing"++func TestHasBusinessUser(t *testing.T) {+ for _, tc := range []struct {+ name string+ ids []int64+ id int64+ want bool+ }{+ {"hit", []int64{3, 7, 9}, 7, true},+ {"miss", []int64{3, 9}, 7, false},+ {"nil slice", nil, 7, false},+ {"empty slice", []int64{}, 7, false},+ {"zero id never matches", []int64{0, 1}, 0, false},+ {"negative id never matches", []int64{-1, 1}, -1, false},+ } {+ if got := hasBusinessUser(tc.ids, tc.id); got != tc.want {+ t.Errorf("%s: hasBusinessUser(%v, %d) = %v want %v", tc.name, tc.ids, tc.id, got, tc.want)+ }+ }+}