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

Method insertCreateEvents

test/room.go:90–116  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

88}
89
90func (r *Room) insertCreateEvents(t *testing.T) {
91 t.Helper()
92 var joinRule gomatrixserverlib.JoinRuleContent
93 var hisVis gomatrixserverlib.HistoryVisibilityContent
94 plContent := eventutil.InitialPowerLevelsContent(r.creator.ID)
95 switch r.preset {
96 case PresetTrustedPrivateChat:
97 fallthrough
98 case PresetPrivateChat:
99 joinRule.JoinRule = "invite"
100 hisVis.HistoryVisibility = "shared"
101 case PresetPublicChat:
102 joinRule.JoinRule = "public"
103 hisVis.HistoryVisibility = "shared"
104 }
105
106 r.CreateAndInsert(t, r.creator, gomatrixserverlib.MRoomCreate, map[string]interface{}{
107 "creator": r.creator.ID,
108 "room_version": r.Version,
109 }, WithStateKey(""))
110 r.CreateAndInsert(t, r.creator, gomatrixserverlib.MRoomMember, map[string]interface{}{
111 "membership": "join",
112 }, WithStateKey(r.creator.ID))
113 r.CreateAndInsert(t, r.creator, gomatrixserverlib.MRoomPowerLevels, plContent, WithStateKey(""))
114 r.CreateAndInsert(t, r.creator, gomatrixserverlib.MRoomJoinRules, joinRule, WithStateKey(""))
115 r.CreateAndInsert(t, r.creator, gomatrixserverlib.MRoomHistoryVisibility, hisVis, WithStateKey(""))
116}
117
118// Create an event in this room but do not insert it. Does not modify the room in any way (depth, fwd extremities, etc) so is thread-safe.
119func (r *Room) CreateEvent(t *testing.T, creator *User, eventType string, content interface{}, mods ...eventModifier) *gomatrixserverlib.HeaderedEvent {

Callers 1

NewRoomFunction · 0.95

Calls 2

CreateAndInsertMethod · 0.95
WithStateKeyFunction · 0.85

Tested by

no test coverage detected