MCPcopy Create free account
hub / github.com/daodst/chat / stateKeyTuplesNeeded

Method stateKeyTuplesNeeded

roomserver/state/state.go:1000–1039  ·  view source on GitHub ↗

stateKeyTuplesNeeded works out which numeric state key tuples we need to authenticate some events.

(stateKeyNIDMap map[string]types.EventStateKeyNID, stateNeeded gomatrixserverlib.StateNeeded)

Source from the content-addressed store, hash-verified

998
999// stateKeyTuplesNeeded works out which numeric state key tuples we need to authenticate some events.
1000func (v *StateResolution) stateKeyTuplesNeeded(stateKeyNIDMap map[string]types.EventStateKeyNID, stateNeeded gomatrixserverlib.StateNeeded) []types.StateKeyTuple {
1001 var keyTuples []types.StateKeyTuple
1002 if stateNeeded.Create {
1003 keyTuples = append(keyTuples, types.StateKeyTuple{
1004 EventTypeNID: types.MRoomCreateNID,
1005 EventStateKeyNID: types.EmptyStateKeyNID,
1006 })
1007 }
1008 if stateNeeded.PowerLevels {
1009 keyTuples = append(keyTuples, types.StateKeyTuple{
1010 EventTypeNID: types.MRoomPowerLevelsNID,
1011 EventStateKeyNID: types.EmptyStateKeyNID,
1012 })
1013 }
1014 if stateNeeded.JoinRules {
1015 keyTuples = append(keyTuples, types.StateKeyTuple{
1016 EventTypeNID: types.MRoomJoinRulesNID,
1017 EventStateKeyNID: types.EmptyStateKeyNID,
1018 })
1019 }
1020 for _, member := range stateNeeded.Member {
1021 stateKeyNID, ok := stateKeyNIDMap[member]
1022 if ok {
1023 keyTuples = append(keyTuples, types.StateKeyTuple{
1024 EventTypeNID: types.MRoomMemberNID,
1025 EventStateKeyNID: stateKeyNID,
1026 })
1027 }
1028 }
1029 for _, token := range stateNeeded.ThirdPartyInvite {
1030 stateKeyNID, ok := stateKeyNIDMap[token]
1031 if ok {
1032 keyTuples = append(keyTuples, types.StateKeyTuple{
1033 EventTypeNID: types.MRoomThirdPartyInviteNID,
1034 EventStateKeyNID: stateKeyNID,
1035 })
1036 }
1037 }
1038 return keyTuples
1039}
1040
1041// loadStateEvents loads the matrix events for a list of state entries.
1042// Returns a list of state events in no particular order and a map from string event ID back to state entry.

Callers 1

resolveConflictsV1Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected