From 3e4325e408342c527bd2563f8b6c99a4375ae211 Mon Sep 17 00:00:00 2001
From: Pascal Bleser
Date: Thu, 18 Jun 2026 16:49:11 +0200
Subject: [PATCH] groupware: downgrade to Go 1.25 since our building images are
only available for 1.25 at the moment
* retrofit from using self-referencing generics parameters that were
introduced with Go 1.26, will re-enable when we upgrade to 1.26
* re-introduce a 'ptr' func since we don't have the new 'new' func yet
that comes with 1.26
---
go.mod | 2 +-
pkg/jmap/integration_addressbook_test.go | 12 +++----
pkg/jmap/integration_calendar_test.go | 8 ++---
pkg/jmap/model.go | 41 +++++++++++++++++-------
pkg/jmap/model_examples.go | 26 +++++++--------
pkg/jmap/templates.go | 7 ++--
pkg/jmap/tools.go | 16 ++++++---
7 files changed, 68 insertions(+), 44 deletions(-)
diff --git a/go.mod b/go.mod
index c0c58d70ee..edb5956cf4 100644
--- a/go.mod
+++ b/go.mod
@@ -1,6 +1,6 @@
module github.com/opencloud-eu/opencloud
-go 1.26.0
+go 1.25.0
require (
dario.cat/mergo v1.0.2
diff --git a/pkg/jmap/integration_addressbook_test.go b/pkg/jmap/integration_addressbook_test.go
index 87d6f8c9eb..267c14c166 100644
--- a/pkg/jmap/integration_addressbook_test.go
+++ b/pkg/jmap/integration_addressbook_test.go
@@ -59,8 +59,8 @@ func TestAddressBooks(t *testing.T) {
},
func(orig AddressBook) AddressBookChange {
return AddressBookChange{
- Description: new(orig.Description + " (changed)"),
- IsSubscribed: new(!orig.IsSubscribed),
+ Description: ptr(orig.Description + " (changed)"),
+ IsSubscribed: ptr(!orig.IsSubscribed),
}
},
func(t *testing.T, orig AddressBook, _ AddressBookChange, changed AddressBook) {
@@ -213,8 +213,8 @@ func TestContacts(t *testing.T) {
now := time.Now().Truncate(time.Duration(1) * time.Second).UTC()
for _, event := range expectedContactCardsById {
change := ContactCardChange{
- Language: new("xyz"),
- Updated: new(now),
+ Language: ptr("xyz"),
+ Updated: ptr(now),
}
result, err := s.client.UpdateContactCard(accountId, event.Id, change, ctx)
require.NoError(err)
@@ -401,11 +401,11 @@ func (s *StalwartTest) fillContacts( //NOSONAR
card := ContactCardChange{
Type: jscontact.ContactCardType,
- Version: new(jscontact.JSContactVersion_1_0),
+ Version: ptr(jscontact.JSContactVersion_1_0),
AddressBookIds: toBoolPtrMap([]string{addressbookId}),
ProdId: &productName,
Language: &language,
- Kind: new(jscontact.ContactCardKindIndividual),
+ Kind: ptr(jscontact.ContactCardKindIndividual),
Name: &nameObj,
}
diff --git a/pkg/jmap/integration_calendar_test.go b/pkg/jmap/integration_calendar_test.go
index 442165ba47..ceff8766f3 100644
--- a/pkg/jmap/integration_calendar_test.go
+++ b/pkg/jmap/integration_calendar_test.go
@@ -49,8 +49,8 @@ func TestCalendars(t *testing.T) { //NOSONAR
},
func(orig Calendar) CalendarChange {
return CalendarChange{
- Description: new(orig.Description + " (changed)"),
- IsSubscribed: new(!orig.IsSubscribed),
+ Description: ptr(orig.Description + " (changed)"),
+ IsSubscribed: ptr(!orig.IsSubscribed),
}
},
func(t *testing.T, orig Calendar, _ CalendarChange, changed Calendar) {
@@ -178,7 +178,7 @@ func TestEvents(t *testing.T) {
for _, event := range expectedEventsById {
change := CalendarEventChange{
EventChange: jscalendar.EventChange{
- Status: new(jscalendar.StatusCancelled),
+ Status: ptr(jscalendar.StatusCancelled),
ObjectChange: jscalendar.ObjectChange{
Sequence: uintPtr(99),
ShowWithoutTime: truep,
@@ -467,7 +467,7 @@ func (s *StalwartTest) fillEvents( //NOSONAR
EventChange: jscalendar.EventChange{
Type: jscalendar.EventType,
Start: jscalendar.LocalDateTime(start),
- Duration: new(jscalendar.Duration(duration)),
+ Duration: ptr(jscalendar.Duration(duration)),
Status: &status,
ObjectChange: jscalendar.ObjectChange{
CommonObjectChange: jscalendar.CommonObjectChange{
diff --git a/pkg/jmap/model.go b/pkg/jmap/model.go
index 1ec63cc164..152fd3b125 100644
--- a/pkg/jmap/model.go
+++ b/pkg/jmap/model.go
@@ -1389,11 +1389,13 @@ type ChangesResponse[T Foo] interface {
GetDestroyed() []string
}
-type QueryCommand[T Foo, SELF QueryCommand[T, SELF]] interface {
+// TODO enable self-referencing generics parameter when upgrading to Go 1.26
+// type QueryCommand[T Foo, SELF QueryCommand[T, SELF]] interface {
+type QueryCommand[T Foo] interface {
JmapCommand
GetResponse() QueryResponse[T]
// Wither that creates a new object of the same type, keeping all the same values except for the limit that is specified as parameter.
- WithLimit(limit *uint) SELF
+ WithLimit(limit *uint) QueryCommand[T] // TODO change return type to SELF when upgrading to Go 1.26
}
type QueryResponse[T Foo] interface {
@@ -1912,12 +1914,15 @@ type MailboxQueryCommand struct {
CalculateTotal bool `json:"calculateTotal,omitempty"`
}
-var _ QueryCommand[Mailbox, MailboxQueryCommand] = &MailboxQueryCommand{}
+// TODO enable self-referencing generics parameter when upgrading to Go 1.26
+var _ QueryCommand[Mailbox /*, MailboxQueryCommand*/] = &MailboxQueryCommand{}
func (c MailboxQueryCommand) GetCommand() Command { return CommandMailboxQuery }
func (c MailboxQueryCommand) GetObjectType() ObjectType { return MailboxType }
func (c MailboxQueryCommand) GetResponse() QueryResponse[Mailbox] { return &MailboxQueryResponse{} }
-func (c MailboxQueryCommand) WithLimit(limit *uint) MailboxQueryCommand {
+
+// TODO enable self-referencing generics parameter when upgrading to Go 1.26
+func (c MailboxQueryCommand) WithLimit(limit *uint) QueryCommand[Mailbox] /*MailboxQueryCommand*/ {
return MailboxQueryCommand{
AccountId: c.AccountId,
Filter: c.Filter,
@@ -2232,12 +2237,15 @@ type EmailQueryCommand struct {
CalculateTotal bool `json:"calculateTotal,omitempty"`
}
-var _ QueryCommand[Email, EmailQueryCommand] = &EmailQueryCommand{}
+// TODO enable self-referencing generics parameter when upgrading to Go 1.26
+var _ QueryCommand[Email /*, EmailQueryCommand*/] = &EmailQueryCommand{}
func (c EmailQueryCommand) GetCommand() Command { return CommandEmailQuery }
func (c EmailQueryCommand) GetObjectType() ObjectType { return MailboxType }
func (c EmailQueryCommand) GetResponse() QueryResponse[Email] { return &EmailQueryResponse{} }
-func (c EmailQueryCommand) WithLimit(limit *uint) EmailQueryCommand {
+
+// TODO enable self-referencing generics parameter when upgrading to Go 1.26
+func (c EmailQueryCommand) WithLimit(limit *uint) QueryCommand[Email] /*EmailQueryCommand*/ {
return EmailQueryCommand{
AccountId: c.AccountId,
Filter: c.Filter,
@@ -7203,14 +7211,17 @@ type ContactCardQueryCommand struct {
CalculateTotal bool `json:"calculateTotal,omitzero"`
}
-var _ QueryCommand[ContactCard, ContactCardQueryCommand] = &ContactCardQueryCommand{}
+// TODO enable self-referencing generics parameter when upgrading to Go 1.26
+var _ QueryCommand[ContactCard /*, ContactCardQueryCommand*/] = &ContactCardQueryCommand{}
func (c ContactCardQueryCommand) GetCommand() Command { return CommandContactCardQuery }
func (c ContactCardQueryCommand) GetObjectType() ObjectType { return ContactCardType }
func (c ContactCardQueryCommand) GetResponse() QueryResponse[ContactCard] {
return &ContactCardQueryResponse{}
}
-func (c ContactCardQueryCommand) WithLimit(limit *uint) ContactCardQueryCommand {
+
+// TODO enable self-referencing generics parameter when upgrading to Go 1.26
+func (c ContactCardQueryCommand) WithLimit(limit *uint) QueryCommand[ContactCard] /*ContactCardQueryCommand*/ {
return ContactCardQueryCommand{
AccountId: c.AccountId,
Filter: c.Filter,
@@ -7952,14 +7963,17 @@ type CalendarEventQueryCommand struct {
CalculateTotal bool `json:"calculateTotal,omitempty" doc:"opt" default:"false"`
}
-var _ QueryCommand[CalendarEvent, CalendarEventQueryCommand] = &CalendarEventQueryCommand{}
+// TODO enable self-referencing generics parameter when upgrading to Go 1.26
+var _ QueryCommand[CalendarEvent /*, CalendarEventQueryCommand*/] = &CalendarEventQueryCommand{}
func (c CalendarEventQueryCommand) GetCommand() Command { return CommandCalendarEventQuery }
func (c CalendarEventQueryCommand) GetObjectType() ObjectType { return CalendarEventType }
func (c CalendarEventQueryCommand) GetResponse() QueryResponse[CalendarEvent] {
return &CalendarEventQueryResponse{}
}
-func (c CalendarEventQueryCommand) WithLimit(limit *uint) CalendarEventQueryCommand {
+
+// TODO enable self-referencing generics parameter when upgrading to Go 1.26
+func (c CalendarEventQueryCommand) WithLimit(limit *uint) QueryCommand[CalendarEvent] /*CalendarEventQueryCommand*/ {
return CalendarEventQueryCommand{
AccountId: c.AccountId,
Filter: c.Filter,
@@ -8451,14 +8465,17 @@ type PrincipalQueryCommand struct {
CalculateTotal bool `json:"calculateTotal,omitzero"`
}
-var _ QueryCommand[Principal, PrincipalQueryCommand] = &PrincipalQueryCommand{}
+// TODO enable self-referencing generics parameter when upgrading to Go 1.26
+var _ QueryCommand[Principal /*, PrincipalQueryCommand*/] = &PrincipalQueryCommand{}
func (c PrincipalQueryCommand) GetCommand() Command { return CommandPrincipalQuery }
func (c PrincipalQueryCommand) GetObjectType() ObjectType { return PrincipalType }
func (c PrincipalQueryCommand) GetResponse() QueryResponse[Principal] {
return &PrincipalQueryResponse{}
}
-func (c PrincipalQueryCommand) WithLimit(limit *uint) PrincipalQueryCommand {
+
+// TODO enable self-referencing generics parameter when upgrading to Go 1.26
+func (c PrincipalQueryCommand) WithLimit(limit *uint) QueryCommand[Principal] /*PrincipalQueryCommand*/ {
return PrincipalQueryCommand{
AccountId: c.AccountId,
Filter: c.Filter,
diff --git a/pkg/jmap/model_examples.go b/pkg/jmap/model_examples.go
index 43a42c296b..6fe57415c3 100644
--- a/pkg/jmap/model_examples.go
+++ b/pkg/jmap/model_examples.go
@@ -575,7 +575,7 @@ func (e Exemplar) MailboxInbox() (Mailbox, string, string) {
Id: e.MailboxInboxId,
Name: "Inbox",
Role: JmapMailboxRoleInbox,
- SortOrder: new(0),
+ SortOrder: ptr(0),
TotalEmails: 1291,
UnreadEmails: 82,
TotalThreads: 891,
@@ -600,7 +600,7 @@ func (e Exemplar) MailboxInboxProjects() (Mailbox, string, string) {
Id: e.MailboxProjectId,
ParentId: e.MailboxInboxId,
Name: "Projects",
- SortOrder: new(0),
+ SortOrder: ptr(0),
TotalEmails: 112,
UnreadEmails: 3,
TotalThreads: 85,
@@ -625,7 +625,7 @@ func (e Exemplar) MailboxDrafts() (Mailbox, string, string) {
Id: e.MailboxDraftsId,
Name: "Drafts",
Role: JmapMailboxRoleDrafts,
- SortOrder: new(0),
+ SortOrder: ptr(0),
TotalEmails: 12,
UnreadEmails: 1,
TotalThreads: 12,
@@ -650,7 +650,7 @@ func (e Exemplar) MailboxSent() (Mailbox, string, string) {
Id: e.MailboxSentId,
Name: "Sent Items",
Role: JmapMailboxRoleSent,
- SortOrder: new(0),
+ SortOrder: ptr(0),
TotalEmails: 1621,
UnreadEmails: 0,
TotalThreads: 1621,
@@ -675,7 +675,7 @@ func (e Exemplar) MailboxJunk() (Mailbox, string, string) {
Id: e.MailboxJunkId,
Name: "Junk Mail",
Role: JmapMailboxRoleJunk,
- SortOrder: new(0),
+ SortOrder: ptr(0),
TotalEmails: 251,
UnreadEmails: 0,
TotalThreads: 251,
@@ -700,7 +700,7 @@ func (e Exemplar) MailboxDeleted() (Mailbox, string, string) {
Id: e.MailboxDeletedId,
Name: "Deleted Items",
Role: JmapMailboxRoleTrash,
- SortOrder: new(0),
+ SortOrder: ptr(0),
TotalEmails: 99,
UnreadEmails: 0,
TotalThreads: 91,
@@ -918,7 +918,7 @@ func (e Exemplar) AddressBook() AddressBook {
func (e Exemplar) AddressBookChange() AddressBookChange {
return AddressBookChange{
- Description: new("A different name"),
+ Description: ptr("A different name"),
}
}
@@ -2325,9 +2325,9 @@ func (e Exemplar) CalendarEventSearchResults() CalendarEventSearchResults {
return CalendarEventSearchResults{
Results: []CalendarEvent{ev},
CanCalculateChanges: true,
- Position: new(uint(3)),
- Limit: new(uint(10)),
- Total: new(uint(4)),
+ Position: uintPtr(3),
+ Limit: uintPtr(10),
+ Total: uintPtr(4),
}
}
@@ -2337,8 +2337,8 @@ func (e Exemplar) ContactCardSearchResults() ContactCardSearchResults {
return ContactCardSearchResults{
Results: []ContactCard{c1, c2},
CanCalculateChanges: true,
- Position: new(uint(3)),
- Limit: new(uint(10)),
- Total: new(uint(4)),
+ Position: uintPtr(3),
+ Limit: uintPtr(10),
+ Total: uintPtr(4),
}
}
diff --git a/pkg/jmap/templates.go b/pkg/jmap/templates.go
index a599241e30..d28db883a6 100644
--- a/pkg/jmap/templates.go
+++ b/pkg/jmap/templates.go
@@ -485,7 +485,8 @@ func query[T Foo, FILTER any, SORT any, QUERY QueryCommand[T], GET GetCommand[T]
}
*/
-func queryN[T Foo, FILTER any, SORT any, QUERY QueryCommand[T, QUERY], GET GetCommand[T], QUERYRESP QueryResponse[T], GETRESP GetResponse[T], RESP any]( //NOSONAR
+// TODO enable self-referencing generics parameter when upgrading to Go 1.26
+func queryN[T Foo, FILTER any, SORT any, QUERY QueryCommand[T /*, QUERY*/], GET GetCommand[T], QUERYRESP QueryResponse[T], GETRESP GetResponse[T], RESP any]( //NOSONAR
client *Client, name string, objType ObjectType,
defaultSortBy []SORT,
queryCommandFactory func(accountId AccountId, queryParams QueryParams, limit *uint, filter FILTER, sortBy []SORT) QUERY,
@@ -504,11 +505,11 @@ func queryN[T Foo, FILTER any, SORT any, QUERY QueryCommand[T, QUERY], GET GetCo
invocations := make([]Invocation, len(accountIds)*2)
var g GET
- var q QUERY
+ var q QueryCommand[T] // TODO change type to QUERY when upgrading to Go 1.26
{
i := 0
for accountId, queryParams := range accountIds {
- query := queryCommandFactory(accountId, queryParams, limit, filter, sortBy)
+ var query QueryCommand[T] = queryCommandFactory(accountId, queryParams, limit, filter, sortBy) // TODO change type to QUERY when upgrading to Go 1.26
q = query
invocations[i*2+0] = invocation(query, mcid(accountId, "0"))
if limit != nil && *limit == 0 {
diff --git a/pkg/jmap/tools.go b/pkg/jmap/tools.go
index f9f58b6b78..7bb7d8c8c1 100644
--- a/pkg/jmap/tools.go
+++ b/pkg/jmap/tools.go
@@ -245,7 +245,8 @@ func retrieveSet[T Foo, C SetCommand[T], R SetResponse[T]](ctx Context, data *Re
return retrieveResponseMatchParameters(ctx, data, command.GetCommand(), tag, target)
}
-func retrieveQuery[T Foo, C QueryCommand[T, C], R QueryResponse[T]](ctx Context, data *Response, command C, tag string, target *R) Error {
+// TODO enable self-referencing generics parameter when upgrading to Go 1.26
+func retrieveQuery[T Foo, C QueryCommand[T /*, C*/], R QueryResponse[T]](ctx Context, data *Response, command C, tag string, target *R) Error {
return retrieveResponseMatchParameters(ctx, data, command.GetCommand(), tag, target)
}
@@ -394,8 +395,8 @@ func mapPairs[K comparable, L, R any](left map[K]L, right map[K]R) map[K]pair[L,
}
var (
- truep = new(true)
- falsep = new(false)
+ truep = ptr(true)
+ falsep = ptr(false)
)
func identity1[T any](t T) T {
@@ -406,10 +407,10 @@ func list[T Foo, GETRESP GetResponse[T]](r GETRESP) []T { return r.GetList() }
func getid[T Idable](r T) string { return r.GetId() }
func uintPtr[T int | uint](i T) *uint {
- return new(uint(i))
+ return ptr(uint(i))
}
-func valueIf[T any | uint | int | bool](value *T, condition bool) *T {
+func valueIf[T any | uint | int | bool | any](value *T, condition bool) *T {
if condition {
return value
} else {
@@ -433,3 +434,8 @@ func ns(namespaces ...JmapNamespace) []JmapNamespace {
}
return result
}
+
+// TODO remove and replace with calls to new() when upgrading to Go 1.26
+func ptr[T any | int | uint | bool | string](t T) *T {
+ return &t
+}