Merge branch 'main' into batuhan/com-beeper-ephemeral
Some checks are pending
Go / Lint (latest) (push) Waiting to run
Go / Build (old, libolm) (push) Waiting to run
Go / Build (latest, libolm) (push) Waiting to run
Go / Build (old, goolm) (push) Waiting to run
Go / Build (latest, goolm) (push) Waiting to run

This commit is contained in:
batuhan içöz 2026-03-02 06:27:50 +01:00
commit fea9e99e6f
No known key found for this signature in database
5 changed files with 33 additions and 8 deletions

View file

@ -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{}),

View file

@ -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"`
}

View file

@ -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}

View file

@ -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 {

View file

@ -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
}