Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go
1.3 KB
Raw Blame
package channel

import (
	"net/url"
	"strings"
)

// IssueWebLink builds the Multica web deep link for a channel issue result.
// Web routes are workspace-scoped — /{workspaceSlug}/issues/{identifier} — so a
// link missing the slug cannot resolve to the issue and is not worth sending;
// any empty part yields an empty string and the caller replies without a link.
// That is deliberate for the adapters that will reuse this helper: an adapter
// that forgets to plumb the slug through loses its link loudly, instead of
// silently shipping the unroutable legacy /issues/{identifier} form again.
func IssueWebLink(appURL, workspaceSlug, identifier string) string {
	return ReferenceWebLink(appURL, workspaceSlug, "issue", identifier)
}

// ReferenceWebLink builds detail links for the navigable mention types.
// Member references address users, not workspace membership rows.
func ReferenceWebLink(appURL, workspaceSlug, kind, id string) string {
	route := map[string]string{
		"issue": "issues", "project": "projects", "agent": "agents",
		"squad": "squads", "member": "members",
	}[kind]
	if appURL == "" || workspaceSlug == "" || id == "" || route == "" {
		return ""
	}
	return strings.TrimRight(appURL, "/") + "/" + url.PathEscape(workspaceSlug) +
		"/" + route + "/" + url.PathEscape(id)
}