BREAKING: update mautrix to 0.15.x
This commit is contained in:
6
vendor/maunium.net/go/mautrix/event/beeper.go
generated
vendored
6
vendor/maunium.net/go/mautrix/event/beeper.go
generated
vendored
@@ -49,3 +49,9 @@ type BeeperRetryMetadata struct {
|
||||
RetryCount int `json:"retry_count"`
|
||||
// last_retry is also present, but not used by bridges
|
||||
}
|
||||
|
||||
type BeeperRoomKeyAckEventContent struct {
|
||||
RoomID id.RoomID `json:"room_id"`
|
||||
SessionID id.SessionID `json:"session_id"`
|
||||
FirstMessageIndex int `json:"first_message_index"`
|
||||
}
|
||||
|
||||
2
vendor/maunium.net/go/mautrix/event/content.go
generated
vendored
2
vendor/maunium.net/go/mautrix/event/content.go
generated
vendored
@@ -80,6 +80,8 @@ var TypeMap = map[Type]reflect.Type{
|
||||
|
||||
ToDeviceOrgMatrixRoomKeyWithheld: reflect.TypeOf(RoomKeyWithheldEventContent{}),
|
||||
|
||||
ToDeviceBeeperRoomKeyAck: reflect.TypeOf(BeeperRoomKeyAckEventContent{}),
|
||||
|
||||
CallInvite: reflect.TypeOf(CallInviteEventContent{}),
|
||||
CallCandidates: reflect.TypeOf(CallCandidatesEventContent{}),
|
||||
CallAnswer: reflect.TypeOf(CallAnswerEventContent{}),
|
||||
|
||||
31
vendor/maunium.net/go/mautrix/event/encryption.go
generated
vendored
31
vendor/maunium.net/go/mautrix/event/encryption.go
generated
vendored
@@ -8,6 +8,7 @@ package event
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"maunium.net/go/mautrix/id"
|
||||
)
|
||||
@@ -41,6 +42,7 @@ type EncryptedEventContent struct {
|
||||
OlmCiphertext OlmCiphertexts `json:"-"`
|
||||
|
||||
RelatesTo *RelatesTo `json:"m.relates_to,omitempty"`
|
||||
Mentions *Mentions `json:"m.mentions,omitempty"`
|
||||
}
|
||||
|
||||
type OlmCiphertexts map[id.Curve25519]struct {
|
||||
@@ -92,6 +94,10 @@ type RoomKeyEventContent struct {
|
||||
RoomID id.RoomID `json:"room_id"`
|
||||
SessionID id.SessionID `json:"session_id"`
|
||||
SessionKey string `json:"session_key"`
|
||||
|
||||
MaxAge int64 `json:"com.beeper.max_age_ms"`
|
||||
MaxMessages int `json:"com.beeper.max_messages"`
|
||||
IsScheduled bool `json:"com.beeper.is_scheduled"`
|
||||
}
|
||||
|
||||
// ForwardedRoomKeyEventContent represents the content of a m.forwarded_room_key to_device event.
|
||||
@@ -101,6 +107,10 @@ type ForwardedRoomKeyEventContent struct {
|
||||
SenderKey id.SenderKey `json:"sender_key"`
|
||||
SenderClaimedKey id.Ed25519 `json:"sender_claimed_ed25519_key"`
|
||||
ForwardingKeyChain []string `json:"forwarding_curve25519_key_chain"`
|
||||
|
||||
MaxAge int64 `json:"com.beeper.max_age_ms"`
|
||||
MaxMessages int `json:"com.beeper.max_messages"`
|
||||
IsScheduled bool `json:"com.beeper.is_scheduled"`
|
||||
}
|
||||
|
||||
type KeyRequestAction string
|
||||
@@ -134,6 +144,8 @@ const (
|
||||
RoomKeyWithheldUnauthorized RoomKeyWithheldCode = "m.unauthorised"
|
||||
RoomKeyWithheldUnavailable RoomKeyWithheldCode = "m.unavailable"
|
||||
RoomKeyWithheldNoOlmSession RoomKeyWithheldCode = "m.no_olm"
|
||||
|
||||
RoomKeyWithheldBeeperRedacted RoomKeyWithheldCode = "com.beeper.redacted"
|
||||
)
|
||||
|
||||
type RoomKeyWithheldEventContent struct {
|
||||
@@ -145,4 +157,23 @@ type RoomKeyWithheldEventContent struct {
|
||||
Reason string `json:"reason,omitempty"`
|
||||
}
|
||||
|
||||
const groupSessionWithheldMsg = "group session has been withheld: %s"
|
||||
|
||||
func (withheld *RoomKeyWithheldEventContent) Error() string {
|
||||
switch withheld.Code {
|
||||
case RoomKeyWithheldBlacklisted, RoomKeyWithheldUnverified, RoomKeyWithheldUnauthorized, RoomKeyWithheldUnavailable, RoomKeyWithheldNoOlmSession:
|
||||
return fmt.Sprintf(groupSessionWithheldMsg, withheld.Code)
|
||||
default:
|
||||
return fmt.Sprintf(groupSessionWithheldMsg+" (%s)", withheld.Code, withheld.Reason)
|
||||
}
|
||||
}
|
||||
|
||||
func (withheld *RoomKeyWithheldEventContent) Is(other error) bool {
|
||||
otherWithheld, ok := other.(*RoomKeyWithheldEventContent)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
return withheld.Code == "" || otherWithheld.Code == "" || withheld.Code == otherWithheld.Code
|
||||
}
|
||||
|
||||
type DummyEventContent struct{}
|
||||
|
||||
2
vendor/maunium.net/go/mautrix/event/events.go
generated
vendored
2
vendor/maunium.net/go/mautrix/event/events.go
generated
vendored
@@ -111,6 +111,8 @@ type MautrixInfo struct {
|
||||
TrustSource *id.Device
|
||||
|
||||
ReceivedAt time.Time
|
||||
EditedAt time.Time
|
||||
LastEditID id.EventID
|
||||
DecryptionDuration time.Duration
|
||||
|
||||
CheckpointSent bool
|
||||
|
||||
16
vendor/maunium.net/go/mautrix/event/message.go
generated
vendored
16
vendor/maunium.net/go/mautrix/event/message.go
generated
vendored
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2020 Tulir Asokan
|
||||
// Copyright (c) 2023 Tulir Asokan
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
@@ -97,6 +97,9 @@ type MessageEventContent struct {
|
||||
|
||||
FileName string `json:"filename,omitempty"`
|
||||
|
||||
Mentions *Mentions `json:"m.mentions,omitempty"`
|
||||
UnstableMentions *Mentions `json:"org.matrix.msc3952.mentions,omitempty"`
|
||||
|
||||
// Edits and relations
|
||||
NewContent *MessageEventContent `json:"m.new_content,omitempty"`
|
||||
RelatesTo *RelatesTo `json:"m.relates_to,omitempty"`
|
||||
@@ -135,6 +138,12 @@ func (content *MessageEventContent) SetEdit(original id.EventID) {
|
||||
if content.Format == FormatHTML && len(content.FormattedBody) > 0 {
|
||||
content.FormattedBody = "* " + content.FormattedBody
|
||||
}
|
||||
// If the message is long, remove most of the useless edit fallback to avoid event size issues.
|
||||
if len(content.Body) > 10000 {
|
||||
content.FormattedBody = ""
|
||||
content.Format = ""
|
||||
content.Body = content.Body[:50] + "[edit fallback cut…]"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,6 +172,11 @@ func (content *MessageEventContent) GetInfo() *FileInfo {
|
||||
return content.Info
|
||||
}
|
||||
|
||||
type Mentions struct {
|
||||
UserIDs []id.UserID `json:"user_ids,omitempty"`
|
||||
Room bool `json:"room,omitempty"`
|
||||
}
|
||||
|
||||
type EncryptedFileInfo struct {
|
||||
attachment.EncryptedFile
|
||||
URL id.ContentURIString `json:"url"`
|
||||
|
||||
64
vendor/maunium.net/go/mautrix/event/powerlevels.go
generated
vendored
64
vendor/maunium.net/go/mautrix/event/powerlevels.go
generated
vendored
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
// PowerLevelsEventContent represents the content of a m.room.power_levels state event content.
|
||||
// https://spec.matrix.org/v1.2/client-server-api/#mroompower_levels
|
||||
// https://spec.matrix.org/v1.5/client-server-api/#mroompower_levels
|
||||
type PowerLevelsEventContent struct {
|
||||
usersLock sync.RWMutex
|
||||
Users map[id.UserID]int `json:"users,omitempty"`
|
||||
@@ -23,6 +23,8 @@ type PowerLevelsEventContent struct {
|
||||
Events map[string]int `json:"events,omitempty"`
|
||||
EventsDefault int `json:"events_default,omitempty"`
|
||||
|
||||
Notifications *NotificationPowerLevels `json:"notifications,omitempty"`
|
||||
|
||||
StateDefaultPtr *int `json:"state_default,omitempty"`
|
||||
|
||||
InvitePtr *int `json:"invite,omitempty"`
|
||||
@@ -32,6 +34,66 @@ type PowerLevelsEventContent struct {
|
||||
HistoricalPtr *int `json:"historical,omitempty"`
|
||||
}
|
||||
|
||||
func copyPtr(ptr *int) *int {
|
||||
if ptr == nil {
|
||||
return nil
|
||||
}
|
||||
val := *ptr
|
||||
return &val
|
||||
}
|
||||
|
||||
func copyMap[Key comparable](m map[Key]int) map[Key]int {
|
||||
if m == nil {
|
||||
return nil
|
||||
}
|
||||
copied := make(map[Key]int, len(m))
|
||||
for k, v := range m {
|
||||
copied[k] = v
|
||||
}
|
||||
return copied
|
||||
}
|
||||
|
||||
func (pl *PowerLevelsEventContent) Clone() *PowerLevelsEventContent {
|
||||
if pl == nil {
|
||||
return nil
|
||||
}
|
||||
return &PowerLevelsEventContent{
|
||||
Users: copyMap(pl.Users),
|
||||
UsersDefault: pl.UsersDefault,
|
||||
Events: copyMap(pl.Events),
|
||||
EventsDefault: pl.EventsDefault,
|
||||
StateDefaultPtr: copyPtr(pl.StateDefaultPtr),
|
||||
|
||||
Notifications: pl.Notifications.Clone(),
|
||||
|
||||
InvitePtr: copyPtr(pl.InvitePtr),
|
||||
KickPtr: copyPtr(pl.KickPtr),
|
||||
BanPtr: copyPtr(pl.BanPtr),
|
||||
RedactPtr: copyPtr(pl.RedactPtr),
|
||||
HistoricalPtr: copyPtr(pl.HistoricalPtr),
|
||||
}
|
||||
}
|
||||
|
||||
type NotificationPowerLevels struct {
|
||||
RoomPtr *int `json:"room,omitempty"`
|
||||
}
|
||||
|
||||
func (npl *NotificationPowerLevels) Clone() *NotificationPowerLevels {
|
||||
if npl == nil {
|
||||
return nil
|
||||
}
|
||||
return &NotificationPowerLevels{
|
||||
RoomPtr: copyPtr(npl.RoomPtr),
|
||||
}
|
||||
}
|
||||
|
||||
func (npl *NotificationPowerLevels) Room() int {
|
||||
if npl != nil && npl.RoomPtr != nil {
|
||||
return *npl.RoomPtr
|
||||
}
|
||||
return 50
|
||||
}
|
||||
|
||||
func (pl *PowerLevelsEventContent) Invite() int {
|
||||
if pl.InvitePtr != nil {
|
||||
return *pl.InvitePtr
|
||||
|
||||
2
vendor/maunium.net/go/mautrix/event/relations.go
generated
vendored
2
vendor/maunium.net/go/mautrix/event/relations.go
generated
vendored
@@ -32,6 +32,8 @@ type RelatesTo struct {
|
||||
|
||||
type InReplyTo struct {
|
||||
EventID id.EventID `json:"event_id,omitempty"`
|
||||
|
||||
UnstableRoomID id.RoomID `json:"room_id,omitempty"`
|
||||
}
|
||||
|
||||
func (rel *RelatesTo) Copy() *RelatesTo {
|
||||
|
||||
5
vendor/maunium.net/go/mautrix/event/type.go
generated
vendored
5
vendor/maunium.net/go/mautrix/event/type.go
generated
vendored
@@ -124,7 +124,8 @@ func (et *Type) GuessClass() TypeClass {
|
||||
CallInvite.Type, CallCandidates.Type, CallAnswer.Type, CallReject.Type, CallSelectAnswer.Type,
|
||||
CallNegotiate.Type, CallHangup.Type, BeeperMessageStatus.Type:
|
||||
return MessageEventType
|
||||
case ToDeviceRoomKey.Type, ToDeviceRoomKeyRequest.Type, ToDeviceForwardedRoomKey.Type, ToDeviceRoomKeyWithheld.Type:
|
||||
case ToDeviceRoomKey.Type, ToDeviceRoomKeyRequest.Type, ToDeviceForwardedRoomKey.Type, ToDeviceRoomKeyWithheld.Type,
|
||||
ToDeviceBeeperRoomKeyAck.Type:
|
||||
return ToDeviceEventType
|
||||
default:
|
||||
return UnknownEventType
|
||||
@@ -253,4 +254,6 @@ var (
|
||||
ToDeviceVerificationCancel = Type{"m.key.verification.cancel", ToDeviceEventType}
|
||||
|
||||
ToDeviceOrgMatrixRoomKeyWithheld = Type{"org.matrix.room_key.withheld", ToDeviceEventType}
|
||||
|
||||
ToDeviceBeeperRoomKeyAck = Type{"com.beeper.room_key.ack", ToDeviceEventType}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user