responses: add Equal method for LazyLoadSummary

This commit is contained in:
Tulir Asokan 2025-10-25 15:34:48 +03:00
commit 364ae39fef

View file

@ -6,12 +6,14 @@ import (
"fmt"
"maps"
"reflect"
"slices"
"strconv"
"strings"
"github.com/tidwall/gjson"
"github.com/tidwall/sjson"
"go.mau.fi/util/jsontime"
"go.mau.fi/util/ptr"
"maunium.net/go/mautrix/event"
"maunium.net/go/mautrix/id"
@ -342,6 +344,17 @@ type LazyLoadSummary struct {
InvitedMemberCount *int `json:"m.invited_member_count,omitempty"`
}
func (lls *LazyLoadSummary) Equal(other *LazyLoadSummary) bool {
if lls == other {
return true
} else if lls == nil || other == nil {
return false
}
return ptr.Val(lls.JoinedMemberCount) == ptr.Val(other.JoinedMemberCount) &&
ptr.Val(lls.InvitedMemberCount) == ptr.Val(other.InvitedMemberCount) &&
slices.Equal(lls.Heroes, other.Heroes)
}
type SyncEventsList struct {
Events []*event.Event `json:"events,omitempty"`
}