mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
Merge branch 'main' into batuhan/com-beeper-ephemeral
This commit is contained in:
commit
fea9e99e6f
5 changed files with 33 additions and 8 deletions
|
|
@ -40,6 +40,9 @@ var TypeMap = map[Type]reflect.Type{
|
|||
StateSpaceParent: reflect.TypeOf(SpaceParentEventContent{}),
|
||||
StateSpaceChild: reflect.TypeOf(SpaceChildEventContent{}),
|
||||
|
||||
StateRoomPolicy: reflect.TypeOf(RoomPolicyEventContent{}),
|
||||
StateUnstableRoomPolicy: reflect.TypeOf(RoomPolicyEventContent{}),
|
||||
|
||||
StateLegacyPolicyRoom: reflect.TypeOf(ModPolicyContent{}),
|
||||
StateLegacyPolicyServer: reflect.TypeOf(ModPolicyContent{}),
|
||||
StateLegacyPolicyUser: reflect.TypeOf(ModPolicyContent{}),
|
||||
|
|
|
|||
|
|
@ -343,3 +343,15 @@ func (efmc *ElementFunctionalMembersContent) Add(mxid id.UserID) bool {
|
|||
efmc.ServiceMembers = append(efmc.ServiceMembers, mxid)
|
||||
return true
|
||||
}
|
||||
|
||||
type PolicyServerPublicKeys struct {
|
||||
Ed25519 id.Ed25519 `json:"ed25519,omitempty"`
|
||||
}
|
||||
|
||||
type RoomPolicyEventContent struct {
|
||||
Via string `json:"via,omitempty"`
|
||||
PublicKeys *PolicyServerPublicKeys `json:"public_keys,omitempty"`
|
||||
|
||||
// Deprecated, only for legacy use
|
||||
PublicKey id.Ed25519 `json:"public_key,omitempty"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,7 +113,7 @@ func (et *Type) GuessClass() TypeClass {
|
|||
StatePinnedEvents.Type, StateTombstone.Type, StateEncryption.Type, StateBridge.Type, StateHalfShotBridge.Type,
|
||||
StateSpaceParent.Type, StateSpaceChild.Type, StatePolicyRoom.Type, StatePolicyServer.Type, StatePolicyUser.Type,
|
||||
StateElementFunctionalMembers.Type, StateBeeperRoomFeatures.Type, StateBeeperDisappearingTimer.Type,
|
||||
StateMSC4391BotCommand.Type:
|
||||
StateMSC4391BotCommand.Type, StateRoomPolicy.Type, StateUnstableRoomPolicy.Type:
|
||||
return StateEventType
|
||||
case EphemeralEventReceipt.Type, EphemeralEventTyping.Type, EphemeralEventPresence.Type, EphemeralEventAIStream.Type:
|
||||
return EphemeralEventType
|
||||
|
|
@ -196,6 +196,9 @@ var (
|
|||
StateSpaceChild = Type{"m.space.child", StateEventType}
|
||||
StateSpaceParent = Type{"m.space.parent", StateEventType}
|
||||
|
||||
StateRoomPolicy = Type{"m.room.policy", StateEventType}
|
||||
StateUnstableRoomPolicy = Type{"org.matrix.msc4284.policy", StateEventType}
|
||||
|
||||
StateLegacyPolicyRoom = Type{"m.room.rule.room", StateEventType}
|
||||
StateLegacyPolicyServer = Type{"m.room.rule.server", StateEventType}
|
||||
StateLegacyPolicyUser = Type{"m.room.rule.user", StateEventType}
|
||||
|
|
|
|||
|
|
@ -123,6 +123,19 @@ func (pdu *PDU) ToClientEvent(roomVersion id.RoomVersion) (*event.Event, error)
|
|||
return evt, nil
|
||||
}
|
||||
|
||||
func (pdu *PDU) AddSignature(serverName string, keyID id.KeyID, signature string) {
|
||||
if signature == "" {
|
||||
return
|
||||
}
|
||||
if pdu.Signatures == nil {
|
||||
pdu.Signatures = make(map[string]map[id.KeyID]string)
|
||||
}
|
||||
if _, ok := pdu.Signatures[serverName]; !ok {
|
||||
pdu.Signatures[serverName] = make(map[id.KeyID]string)
|
||||
}
|
||||
pdu.Signatures[serverName][keyID] = signature
|
||||
}
|
||||
|
||||
func marshalCanonical(data any) (jsontext.Value, error) {
|
||||
marshaledBytes, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -28,13 +28,7 @@ func (pdu *PDU) Sign(roomVersion id.RoomVersion, serverName string, keyID id.Key
|
|||
return fmt.Errorf("failed to marshal redacted PDU to sign: %w", err)
|
||||
}
|
||||
signature := ed25519.Sign(privateKey, rawJSON)
|
||||
if pdu.Signatures == nil {
|
||||
pdu.Signatures = make(map[string]map[id.KeyID]string)
|
||||
}
|
||||
if _, ok := pdu.Signatures[serverName]; !ok {
|
||||
pdu.Signatures[serverName] = make(map[id.KeyID]string)
|
||||
}
|
||||
pdu.Signatures[serverName][keyID] = base64.RawStdEncoding.EncodeToString(signature)
|
||||
pdu.AddSignature(serverName, keyID, base64.RawStdEncoding.EncodeToString(signature))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue