From ecc9e6b34f7ae9429a5c5e0e3097e46d044b8e15 Mon Sep 17 00:00:00 2001
From: Pascal Bleser
Date: Tue, 14 Oct 2025 11:37:18 +0200
Subject: [PATCH] groupware: accept both '_' and '*' as the 'default account'
placeholder
---
services/groupware/pkg/groupware/groupware_request.go | 9 +++++++--
services/groupware/pkg/groupware/groupware_route.go | 7 +++++--
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/services/groupware/pkg/groupware/groupware_request.go b/services/groupware/pkg/groupware/groupware_request.go
index 89034c2bbb..ea21dca348 100644
--- a/services/groupware/pkg/groupware/groupware_request.go
+++ b/services/groupware/pkg/groupware/groupware_request.go
@@ -7,6 +7,7 @@ import (
"fmt"
"io"
"net/http"
+ "slices"
"strconv"
"strings"
"time"
@@ -40,6 +41,10 @@ type Request struct {
session *jmap.Session
}
+func isDefaultAccountid(accountId string) bool {
+ return slices.Contains(defaultAccountIds, accountId)
+}
+
func (r Request) push(typ string, event any) {
r.g.push(r.user, typ, event)
}
@@ -72,7 +77,7 @@ var (
func (r Request) GetAccountIdWithoutFallback() (string, *Error) {
accountId := chi.URLParam(r.r, UriParamAccountId)
- if accountId == "" || accountId == defaultAccountId {
+ if accountId == "" || isDefaultAccountid(accountId) {
r.logger.Error().Err(errNoPrimaryAccountFallback).Msg("failed to determine the accountId")
return "", apiError(r.errorId(), ErrorNonExistingAccount,
withDetail("Failed to determine the account to use"),
@@ -84,7 +89,7 @@ func (r Request) GetAccountIdWithoutFallback() (string, *Error) {
func (r Request) getAccountId(fallback string, err error) (string, *Error) {
accountId := chi.URLParam(r.r, UriParamAccountId)
- if accountId == "" || accountId == defaultAccountId {
+ if accountId == "" || isDefaultAccountid(accountId) {
accountId = fallback
}
if accountId == "" {
diff --git a/services/groupware/pkg/groupware/groupware_route.go b/services/groupware/pkg/groupware/groupware_route.go
index 70033cffa5..17f49ffe69 100644
--- a/services/groupware/pkg/groupware/groupware_route.go
+++ b/services/groupware/pkg/groupware/groupware_route.go
@@ -6,9 +6,11 @@ import (
"github.com/go-chi/chi/v5"
)
-const (
- defaultAccountId = "_"
+var (
+ defaultAccountIds = []string{"_", "*"}
+)
+const (
UriParamAccountId = "accountid"
UriParamMailboxId = "mailbox"
UriParamEmailId = "emailid"
@@ -56,6 +58,7 @@ func (g *Groupware) Route(r chi.Router) {
r.Get("/", g.Index)
r.Get("/accounts", g.GetAccounts)
r.Route("/accounts/all", func(r chi.Router) {
+ r.Get("/", g.GetAccounts)
r.Route("/mailboxes", func(r chi.Router) {
r.Get("/", g.GetMailboxesForAllAccounts) // ?role=
r.Get("/changes", g.GetMailboxChangesForAllAccounts)