Merge pull request #182 from multica-ai/agent/lambda/532f6d3d
fix(handler): set issue_prefix when auto-creating workspace on first login
This commit is contained in:
commit
3f2b345a1d
4 changed files with 18 additions and 2 deletions
|
|
@ -133,10 +133,12 @@ func (h *Handler) ensureUserWorkspace(ctx context.Context, user db.User) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
wsName := defaultWorkspaceName(user)
|
||||
workspace, err := qtx.CreateWorkspace(ctx, db.CreateWorkspaceParams{
|
||||
Name: defaultWorkspaceName(user),
|
||||
Name: wsName,
|
||||
Slug: defaultWorkspaceSlug(user),
|
||||
Description: pgtype.Text{},
|
||||
IssuePrefix: generateIssuePrefix(wsName),
|
||||
})
|
||||
if err != nil {
|
||||
if isUniqueViolation(err) {
|
||||
|
|
|
|||
|
|
@ -281,12 +281,17 @@ func splitIdentifier(id string) *identifierParts {
|
|||
}
|
||||
|
||||
// getIssuePrefix fetches the issue_prefix for a workspace.
|
||||
// Falls back to generating a prefix from the workspace name if the stored
|
||||
// prefix is empty (e.g. workspaces created before the prefix was introduced).
|
||||
func (h *Handler) getIssuePrefix(ctx context.Context, workspaceID pgtype.UUID) string {
|
||||
ws, err := h.Queries.GetWorkspace(ctx, workspaceID)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
return ws.IssuePrefix
|
||||
if ws.IssuePrefix != "" {
|
||||
return ws.IssuePrefix
|
||||
}
|
||||
return generateIssuePrefix(ws.Name)
|
||||
}
|
||||
|
||||
func (h *Handler) loadAgentForUser(w http.ResponseWriter, r *http.Request, agentID string) (db.Agent, bool) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue