mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-26 06:28:35 -06:00
groupware: accept both '_' and '*' as the 'default account' placeholder
This commit is contained in:
@@ -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 == "" {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user