mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-16 10:33:11 -06:00
Move FledglingEvent to gmsl
This commit is contained in:
parent
cf64e3e620
commit
1a2787f767
|
|
@ -43,7 +43,7 @@ type createRoomRequest struct {
|
||||||
Topic string `json:"topic"`
|
Topic string `json:"topic"`
|
||||||
Preset string `json:"preset"`
|
Preset string `json:"preset"`
|
||||||
CreationContent json.RawMessage `json:"creation_content"`
|
CreationContent json.RawMessage `json:"creation_content"`
|
||||||
InitialState []roomserverAPI.FledglingEvent `json:"initial_state"`
|
InitialState []gomatrixserverlib.FledglingEvent `json:"initial_state"`
|
||||||
RoomAliasName string `json:"room_alias_name"`
|
RoomAliasName string `json:"room_alias_name"`
|
||||||
RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
|
RoomVersion gomatrixserverlib.RoomVersion `json:"room_version"`
|
||||||
PowerLevelContentOverride json.RawMessage `json:"power_level_content_override"`
|
PowerLevelContentOverride json.RawMessage `json:"power_level_content_override"`
|
||||||
|
|
|
||||||
2
go.mod
2
go.mod
|
|
@ -22,7 +22,7 @@ require (
|
||||||
github.com/matrix-org/dugong v0.0.0-20210921133753-66e6b1c67e2e
|
github.com/matrix-org/dugong v0.0.0-20210921133753-66e6b1c67e2e
|
||||||
github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91
|
github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91
|
||||||
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530
|
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530
|
||||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230524095531-95ba6c68efb6
|
github.com/matrix-org/gomatrixserverlib v0.0.0-20230531024850-f490eabb6a41
|
||||||
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a
|
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a
|
||||||
github.com/matrix-org/util v0.0.0-20221111132719-399730281e66
|
github.com/matrix-org/util v0.0.0-20221111132719-399730281e66
|
||||||
github.com/mattn/go-sqlite3 v1.14.16
|
github.com/mattn/go-sqlite3 v1.14.16
|
||||||
|
|
|
||||||
4
go.sum
4
go.sum
|
|
@ -323,8 +323,8 @@ github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91 h1:s7fexw
|
||||||
github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91/go.mod h1:e+cg2q7C7yE5QnAXgzo512tgFh1RbQLC0+jozuegKgo=
|
github.com/matrix-org/go-sqlite3-js v0.0.0-20220419092513-28aa791a1c91/go.mod h1:e+cg2q7C7yE5QnAXgzo512tgFh1RbQLC0+jozuegKgo=
|
||||||
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530 h1:kHKxCOLcHH8r4Fzarl4+Y3K5hjothkVW5z7T1dUM11U=
|
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530 h1:kHKxCOLcHH8r4Fzarl4+Y3K5hjothkVW5z7T1dUM11U=
|
||||||
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s=
|
github.com/matrix-org/gomatrix v0.0.0-20220926102614-ceba4d9f7530/go.mod h1:/gBX06Kw0exX1HrwmoBibFA98yBk/jxKpGVeyQbff+s=
|
||||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230524095531-95ba6c68efb6 h1:FQpdh/KGCCQJytz4GAdG6pbx3DJ1HNzdKFc/BCZ0hP0=
|
github.com/matrix-org/gomatrixserverlib v0.0.0-20230531024850-f490eabb6a41 h1:ODPxn6DjKOPNO54fQBqAI0GHMlbj98EQMPXho/PFbFY=
|
||||||
github.com/matrix-org/gomatrixserverlib v0.0.0-20230524095531-95ba6c68efb6/go.mod h1:H9V9N3Uqn1bBJqYJNGK1noqtgJTaCEhtTdcH/mp50uU=
|
github.com/matrix-org/gomatrixserverlib v0.0.0-20230531024850-f490eabb6a41/go.mod h1:H9V9N3Uqn1bBJqYJNGK1noqtgJTaCEhtTdcH/mp50uU=
|
||||||
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a h1:awrPDf9LEFySxTLKYBMCiObelNx/cBuv/wzllvCCH3A=
|
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a h1:awrPDf9LEFySxTLKYBMCiObelNx/cBuv/wzllvCCH3A=
|
||||||
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a/go.mod h1:HchJX9oKMXaT2xYFs0Ha/6Zs06mxLU8k6F1ODnrGkeQ=
|
github.com/matrix-org/pinecone v0.11.1-0.20230210171230-8c3b24f2649a/go.mod h1:HchJX9oKMXaT2xYFs0Ha/6Zs06mxLU8k6F1ODnrGkeQ=
|
||||||
github.com/matrix-org/util v0.0.0-20221111132719-399730281e66 h1:6z4KxomXSIGWqhHcfzExgkH3Z3UkIXry4ibJS4Aqz2Y=
|
github.com/matrix-org/util v0.0.0-20221111132719-399730281e66 h1:6z4KxomXSIGWqhHcfzExgkH3Z3UkIXry4ibJS4Aqz2Y=
|
||||||
|
|
|
||||||
|
|
@ -12,14 +12,6 @@ import (
|
||||||
"github.com/matrix-org/util"
|
"github.com/matrix-org/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO: Move to GMSL
|
|
||||||
// FledglingEvent is a helper representation of an event used when creating many events in succession.
|
|
||||||
type FledglingEvent struct {
|
|
||||||
Type string `json:"type"`
|
|
||||||
StateKey string `json:"state_key"`
|
|
||||||
Content interface{} `json:"content"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type PerformCreateRoomRequest struct {
|
type PerformCreateRoomRequest struct {
|
||||||
InvitedUsers []string
|
InvitedUsers []string
|
||||||
RoomName string
|
RoomName string
|
||||||
|
|
@ -27,7 +19,7 @@ type PerformCreateRoomRequest struct {
|
||||||
Topic string
|
Topic string
|
||||||
StatePreset string
|
StatePreset string
|
||||||
CreationContent json.RawMessage
|
CreationContent json.RawMessage
|
||||||
InitialState []FledglingEvent
|
InitialState []gomatrixserverlib.FledglingEvent
|
||||||
RoomAliasName string
|
RoomAliasName string
|
||||||
RoomVersion gomatrixserverlib.RoomVersion
|
RoomVersion gomatrixserverlib.RoomVersion
|
||||||
PowerLevelContentOverride json.RawMessage
|
PowerLevelContentOverride json.RawMessage
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,6 @@ import (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
historyVisibilityShared = "shared"
|
historyVisibilityShared = "shared"
|
||||||
// TODO: These should be implemented once history visibility is implemented
|
|
||||||
// historyVisibilityWorldReadable = "world_readable"
|
|
||||||
// historyVisibilityInvited = "invited"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Creator struct {
|
type Creator struct {
|
||||||
|
|
@ -96,23 +93,23 @@ func (c *Creator) PerformCreateRoom(ctx context.Context, userID spec.UserID, roo
|
||||||
historyVisibilityContent.HistoryVisibility = historyVisibilityShared
|
historyVisibilityContent.HistoryVisibility = historyVisibilityShared
|
||||||
}
|
}
|
||||||
|
|
||||||
createEvent := api.FledglingEvent{
|
createEvent := gomatrixserverlib.FledglingEvent{
|
||||||
Type: spec.MRoomCreate,
|
Type: spec.MRoomCreate,
|
||||||
Content: createContent,
|
Content: createContent,
|
||||||
}
|
}
|
||||||
powerLevelEvent := api.FledglingEvent{
|
powerLevelEvent := gomatrixserverlib.FledglingEvent{
|
||||||
Type: spec.MRoomPowerLevels,
|
Type: spec.MRoomPowerLevels,
|
||||||
Content: powerLevelContent,
|
Content: powerLevelContent,
|
||||||
}
|
}
|
||||||
joinRuleEvent := api.FledglingEvent{
|
joinRuleEvent := gomatrixserverlib.FledglingEvent{
|
||||||
Type: spec.MRoomJoinRules,
|
Type: spec.MRoomJoinRules,
|
||||||
Content: joinRuleContent,
|
Content: joinRuleContent,
|
||||||
}
|
}
|
||||||
historyVisibilityEvent := api.FledglingEvent{
|
historyVisibilityEvent := gomatrixserverlib.FledglingEvent{
|
||||||
Type: spec.MRoomHistoryVisibility,
|
Type: spec.MRoomHistoryVisibility,
|
||||||
Content: historyVisibilityContent,
|
Content: historyVisibilityContent,
|
||||||
}
|
}
|
||||||
membershipEvent := api.FledglingEvent{
|
membershipEvent := gomatrixserverlib.FledglingEvent{
|
||||||
Type: spec.MRoomMember,
|
Type: spec.MRoomMember,
|
||||||
StateKey: userID.String(),
|
StateKey: userID.String(),
|
||||||
Content: gomatrixserverlib.MemberContent{
|
Content: gomatrixserverlib.MemberContent{
|
||||||
|
|
@ -122,13 +119,13 @@ func (c *Creator) PerformCreateRoom(ctx context.Context, userID spec.UserID, roo
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
var nameEvent *api.FledglingEvent
|
var nameEvent *gomatrixserverlib.FledglingEvent
|
||||||
var topicEvent *api.FledglingEvent
|
var topicEvent *gomatrixserverlib.FledglingEvent
|
||||||
var guestAccessEvent *api.FledglingEvent
|
var guestAccessEvent *gomatrixserverlib.FledglingEvent
|
||||||
var aliasEvent *api.FledglingEvent
|
var aliasEvent *gomatrixserverlib.FledglingEvent
|
||||||
|
|
||||||
if createRequest.RoomName != "" {
|
if createRequest.RoomName != "" {
|
||||||
nameEvent = &api.FledglingEvent{
|
nameEvent = &gomatrixserverlib.FledglingEvent{
|
||||||
Type: spec.MRoomName,
|
Type: spec.MRoomName,
|
||||||
Content: eventutil.NameContent{
|
Content: eventutil.NameContent{
|
||||||
Name: createRequest.RoomName,
|
Name: createRequest.RoomName,
|
||||||
|
|
@ -137,7 +134,7 @@ func (c *Creator) PerformCreateRoom(ctx context.Context, userID spec.UserID, roo
|
||||||
}
|
}
|
||||||
|
|
||||||
if createRequest.Topic != "" {
|
if createRequest.Topic != "" {
|
||||||
topicEvent = &api.FledglingEvent{
|
topicEvent = &gomatrixserverlib.FledglingEvent{
|
||||||
Type: spec.MRoomTopic,
|
Type: spec.MRoomTopic,
|
||||||
Content: eventutil.TopicContent{
|
Content: eventutil.TopicContent{
|
||||||
Topic: createRequest.Topic,
|
Topic: createRequest.Topic,
|
||||||
|
|
@ -146,7 +143,7 @@ func (c *Creator) PerformCreateRoom(ctx context.Context, userID spec.UserID, roo
|
||||||
}
|
}
|
||||||
|
|
||||||
if guestsCanJoin {
|
if guestsCanJoin {
|
||||||
guestAccessEvent = &api.FledglingEvent{
|
guestAccessEvent = &gomatrixserverlib.FledglingEvent{
|
||||||
Type: spec.MRoomGuestAccess,
|
Type: spec.MRoomGuestAccess,
|
||||||
Content: eventutil.GuestAccessContent{
|
Content: eventutil.GuestAccessContent{
|
||||||
GuestAccess: "can_join",
|
GuestAccess: "can_join",
|
||||||
|
|
@ -179,7 +176,7 @@ func (c *Creator) PerformCreateRoom(ctx context.Context, userID spec.UserID, roo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
aliasEvent = &api.FledglingEvent{
|
aliasEvent = &gomatrixserverlib.FledglingEvent{
|
||||||
Type: spec.MRoomCanonicalAlias,
|
Type: spec.MRoomCanonicalAlias,
|
||||||
Content: eventutil.CanonicalAlias{
|
Content: eventutil.CanonicalAlias{
|
||||||
Alias: roomAlias,
|
Alias: roomAlias,
|
||||||
|
|
@ -187,7 +184,7 @@ func (c *Creator) PerformCreateRoom(ctx context.Context, userID spec.UserID, roo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var initialStateEvents []api.FledglingEvent
|
var initialStateEvents []gomatrixserverlib.FledglingEvent
|
||||||
for i := range createRequest.InitialState {
|
for i := range createRequest.InitialState {
|
||||||
if createRequest.InitialState[i].StateKey != "" {
|
if createRequest.InitialState[i].StateKey != "" {
|
||||||
initialStateEvents = append(initialStateEvents, createRequest.InitialState[i])
|
initialStateEvents = append(initialStateEvents, createRequest.InitialState[i])
|
||||||
|
|
@ -238,7 +235,7 @@ func (c *Creator) PerformCreateRoom(ctx context.Context, userID spec.UserID, roo
|
||||||
// depending on if those events were in "initial_state" or not. This made it
|
// depending on if those events were in "initial_state" or not. This made it
|
||||||
// harder to reason about, hence sticking to a strict static ordering.
|
// harder to reason about, hence sticking to a strict static ordering.
|
||||||
// TODO: Synapse has txn/token ID on each event. Do we need to do this here?
|
// TODO: Synapse has txn/token ID on each event. Do we need to do this here?
|
||||||
eventsToMake := []api.FledglingEvent{
|
eventsToMake := []gomatrixserverlib.FledglingEvent{
|
||||||
createEvent, membershipEvent, powerLevelEvent, joinRuleEvent, historyVisibilityEvent,
|
createEvent, membershipEvent, powerLevelEvent, joinRuleEvent, historyVisibilityEvent,
|
||||||
}
|
}
|
||||||
if guestAccessEvent != nil {
|
if guestAccessEvent != nil {
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,7 @@ func (r *Upgrader) restrictOldRoomPowerLevels(ctx context.Context, evTime time.T
|
||||||
restrictedPowerLevelContent.EventsDefault = restrictedDefaultPowerLevel
|
restrictedPowerLevelContent.EventsDefault = restrictedDefaultPowerLevel
|
||||||
restrictedPowerLevelContent.Invite = restrictedDefaultPowerLevel
|
restrictedPowerLevelContent.Invite = restrictedDefaultPowerLevel
|
||||||
|
|
||||||
restrictedPowerLevelsHeadered, resErr := r.makeHeaderedEvent(ctx, evTime, userID, roomID, api.FledglingEvent{
|
restrictedPowerLevelsHeadered, resErr := r.makeHeaderedEvent(ctx, evTime, userID, roomID, gomatrixserverlib.FledglingEvent{
|
||||||
Type: spec.MRoomPowerLevels,
|
Type: spec.MRoomPowerLevels,
|
||||||
StateKey: "",
|
StateKey: "",
|
||||||
Content: restrictedPowerLevelContent,
|
Content: restrictedPowerLevelContent,
|
||||||
|
|
@ -209,7 +209,7 @@ func (r *Upgrader) clearOldCanonicalAliasEvent(ctx context.Context, oldRoom *api
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
emptyCanonicalAliasEvent, resErr := r.makeHeaderedEvent(ctx, evTime, userID, roomID, api.FledglingEvent{
|
emptyCanonicalAliasEvent, resErr := r.makeHeaderedEvent(ctx, evTime, userID, roomID, gomatrixserverlib.FledglingEvent{
|
||||||
Type: spec.MRoomCanonicalAlias,
|
Type: spec.MRoomCanonicalAlias,
|
||||||
Content: map[string]interface{}{},
|
Content: map[string]interface{}{},
|
||||||
})
|
})
|
||||||
|
|
@ -291,7 +291,7 @@ func (r *Upgrader) userIsAuthorized(ctx context.Context, userID, roomID string,
|
||||||
}
|
}
|
||||||
|
|
||||||
// nolint:gocyclo
|
// nolint:gocyclo
|
||||||
func (r *Upgrader) generateInitialEvents(ctx context.Context, oldRoom *api.QueryLatestEventsAndStateResponse, userID, roomID string, newVersion gomatrixserverlib.RoomVersion, tombstoneEvent *types.HeaderedEvent) ([]api.FledglingEvent, error) {
|
func (r *Upgrader) generateInitialEvents(ctx context.Context, oldRoom *api.QueryLatestEventsAndStateResponse, userID, roomID string, newVersion gomatrixserverlib.RoomVersion, tombstoneEvent *types.HeaderedEvent) ([]gomatrixserverlib.FledglingEvent, error) {
|
||||||
state := make(map[gomatrixserverlib.StateKeyTuple]*types.HeaderedEvent, len(oldRoom.StateEvents))
|
state := make(map[gomatrixserverlib.StateKeyTuple]*types.HeaderedEvent, len(oldRoom.StateEvents))
|
||||||
for _, event := range oldRoom.StateEvents {
|
for _, event := range oldRoom.StateEvents {
|
||||||
if event.StateKey() == nil {
|
if event.StateKey() == nil {
|
||||||
|
|
@ -354,7 +354,7 @@ func (r *Upgrader) generateInitialEvents(ctx context.Context, oldRoom *api.Query
|
||||||
EventID: tombstoneEvent.EventID(),
|
EventID: tombstoneEvent.EventID(),
|
||||||
RoomID: roomID,
|
RoomID: roomID,
|
||||||
}
|
}
|
||||||
newCreateEvent := api.FledglingEvent{
|
newCreateEvent := gomatrixserverlib.FledglingEvent{
|
||||||
Type: spec.MRoomCreate,
|
Type: spec.MRoomCreate,
|
||||||
StateKey: "",
|
StateKey: "",
|
||||||
Content: newCreateContent,
|
Content: newCreateContent,
|
||||||
|
|
@ -367,7 +367,7 @@ func (r *Upgrader) generateInitialEvents(ctx context.Context, oldRoom *api.Query
|
||||||
newMembershipContent := map[string]interface{}{}
|
newMembershipContent := map[string]interface{}{}
|
||||||
_ = json.Unmarshal(oldMembershipEvent.Content(), &newMembershipContent)
|
_ = json.Unmarshal(oldMembershipEvent.Content(), &newMembershipContent)
|
||||||
newMembershipContent["membership"] = spec.Join
|
newMembershipContent["membership"] = spec.Join
|
||||||
newMembershipEvent := api.FledglingEvent{
|
newMembershipEvent := gomatrixserverlib.FledglingEvent{
|
||||||
Type: spec.MRoomMember,
|
Type: spec.MRoomMember,
|
||||||
StateKey: userID,
|
StateKey: userID,
|
||||||
Content: newMembershipContent,
|
Content: newMembershipContent,
|
||||||
|
|
@ -393,13 +393,13 @@ func (r *Upgrader) generateInitialEvents(ctx context.Context, oldRoom *api.Query
|
||||||
"join_rule": spec.Invite, // sane default
|
"join_rule": spec.Invite, // sane default
|
||||||
}
|
}
|
||||||
_ = json.Unmarshal(oldJoinRulesEvent.Content(), &newJoinRulesContent)
|
_ = json.Unmarshal(oldJoinRulesEvent.Content(), &newJoinRulesContent)
|
||||||
newJoinRulesEvent := api.FledglingEvent{
|
newJoinRulesEvent := gomatrixserverlib.FledglingEvent{
|
||||||
Type: spec.MRoomJoinRules,
|
Type: spec.MRoomJoinRules,
|
||||||
StateKey: "",
|
StateKey: "",
|
||||||
Content: newJoinRulesContent,
|
Content: newJoinRulesContent,
|
||||||
}
|
}
|
||||||
|
|
||||||
eventsToMake := make([]api.FledglingEvent, 0, len(state))
|
eventsToMake := make([]gomatrixserverlib.FledglingEvent, 0, len(state))
|
||||||
eventsToMake = append(
|
eventsToMake = append(
|
||||||
eventsToMake, newCreateEvent, newMembershipEvent,
|
eventsToMake, newCreateEvent, newMembershipEvent,
|
||||||
tempPowerLevelsEvent, newJoinRulesEvent,
|
tempPowerLevelsEvent, newJoinRulesEvent,
|
||||||
|
|
@ -408,7 +408,7 @@ func (r *Upgrader) generateInitialEvents(ctx context.Context, oldRoom *api.Query
|
||||||
// For some reason Sytest expects there to be a guest access event.
|
// For some reason Sytest expects there to be a guest access event.
|
||||||
// Create one if it doesn't exist.
|
// Create one if it doesn't exist.
|
||||||
if _, ok := state[gomatrixserverlib.StateKeyTuple{EventType: spec.MRoomGuestAccess, StateKey: ""}]; !ok {
|
if _, ok := state[gomatrixserverlib.StateKeyTuple{EventType: spec.MRoomGuestAccess, StateKey: ""}]; !ok {
|
||||||
eventsToMake = append(eventsToMake, api.FledglingEvent{
|
eventsToMake = append(eventsToMake, gomatrixserverlib.FledglingEvent{
|
||||||
Type: spec.MRoomGuestAccess,
|
Type: spec.MRoomGuestAccess,
|
||||||
Content: map[string]string{
|
Content: map[string]string{
|
||||||
"guest_access": "forbidden",
|
"guest_access": "forbidden",
|
||||||
|
|
@ -423,7 +423,7 @@ func (r *Upgrader) generateInitialEvents(ctx context.Context, oldRoom *api.Query
|
||||||
// are already in `eventsToMake`.
|
// are already in `eventsToMake`.
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
newEvent := api.FledglingEvent{
|
newEvent := gomatrixserverlib.FledglingEvent{
|
||||||
Type: tuple.EventType,
|
Type: tuple.EventType,
|
||||||
StateKey: tuple.StateKey,
|
StateKey: tuple.StateKey,
|
||||||
}
|
}
|
||||||
|
|
@ -437,7 +437,7 @@ func (r *Upgrader) generateInitialEvents(ctx context.Context, oldRoom *api.Query
|
||||||
// If we sent a temporary power level event into the room before,
|
// If we sent a temporary power level event into the room before,
|
||||||
// override that now by restoring the original power levels.
|
// override that now by restoring the original power levels.
|
||||||
if powerLevelsOverridden {
|
if powerLevelsOverridden {
|
||||||
eventsToMake = append(eventsToMake, api.FledglingEvent{
|
eventsToMake = append(eventsToMake, gomatrixserverlib.FledglingEvent{
|
||||||
Type: spec.MRoomPowerLevels,
|
Type: spec.MRoomPowerLevels,
|
||||||
Content: powerLevelContent,
|
Content: powerLevelContent,
|
||||||
})
|
})
|
||||||
|
|
@ -445,7 +445,7 @@ func (r *Upgrader) generateInitialEvents(ctx context.Context, oldRoom *api.Query
|
||||||
return eventsToMake, nil
|
return eventsToMake, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Upgrader) sendInitialEvents(ctx context.Context, evTime time.Time, userID string, userDomain spec.ServerName, newRoomID string, newVersion gomatrixserverlib.RoomVersion, eventsToMake []api.FledglingEvent) error {
|
func (r *Upgrader) sendInitialEvents(ctx context.Context, evTime time.Time, userID string, userDomain spec.ServerName, newRoomID string, newVersion gomatrixserverlib.RoomVersion, eventsToMake []gomatrixserverlib.FledglingEvent) error {
|
||||||
var err error
|
var err error
|
||||||
var builtEvents []*types.HeaderedEvent
|
var builtEvents []*types.HeaderedEvent
|
||||||
authEvents := gomatrixserverlib.NewAuthEvents(nil)
|
authEvents := gomatrixserverlib.NewAuthEvents(nil)
|
||||||
|
|
@ -520,14 +520,14 @@ func (r *Upgrader) makeTombstoneEvent(
|
||||||
"body": "This room has been replaced",
|
"body": "This room has been replaced",
|
||||||
"replacement_room": newRoomID,
|
"replacement_room": newRoomID,
|
||||||
}
|
}
|
||||||
event := api.FledglingEvent{
|
event := gomatrixserverlib.FledglingEvent{
|
||||||
Type: "m.room.tombstone",
|
Type: "m.room.tombstone",
|
||||||
Content: content,
|
Content: content,
|
||||||
}
|
}
|
||||||
return r.makeHeaderedEvent(ctx, evTime, userID, roomID, event)
|
return r.makeHeaderedEvent(ctx, evTime, userID, roomID, event)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Upgrader) makeHeaderedEvent(ctx context.Context, evTime time.Time, userID, roomID string, event api.FledglingEvent) (*types.HeaderedEvent, error) {
|
func (r *Upgrader) makeHeaderedEvent(ctx context.Context, evTime time.Time, userID, roomID string, event gomatrixserverlib.FledglingEvent) (*types.HeaderedEvent, error) {
|
||||||
proto := gomatrixserverlib.ProtoEvent{
|
proto := gomatrixserverlib.ProtoEvent{
|
||||||
Sender: userID,
|
Sender: userID,
|
||||||
RoomID: roomID,
|
RoomID: roomID,
|
||||||
|
|
@ -574,7 +574,7 @@ func (r *Upgrader) makeHeaderedEvent(ctx context.Context, evTime time.Time, user
|
||||||
return headeredEvent, nil
|
return headeredEvent, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func createTemporaryPowerLevels(powerLevelContent *gomatrixserverlib.PowerLevelContent, userID string) (api.FledglingEvent, bool) {
|
func createTemporaryPowerLevels(powerLevelContent *gomatrixserverlib.PowerLevelContent, userID string) (gomatrixserverlib.FledglingEvent, bool) {
|
||||||
// Work out what power level we need in order to be able to send events
|
// Work out what power level we need in order to be able to send events
|
||||||
// of all types into the room.
|
// of all types into the room.
|
||||||
neededPowerLevel := powerLevelContent.StateDefault
|
neededPowerLevel := powerLevelContent.StateDefault
|
||||||
|
|
@ -605,7 +605,7 @@ func createTemporaryPowerLevels(powerLevelContent *gomatrixserverlib.PowerLevelC
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then return the temporary power levels event.
|
// Then return the temporary power levels event.
|
||||||
return api.FledglingEvent{
|
return gomatrixserverlib.FledglingEvent{
|
||||||
Type: spec.MRoomPowerLevels,
|
Type: spec.MRoomPowerLevels,
|
||||||
Content: tempPowerLevelContent,
|
Content: tempPowerLevelContent,
|
||||||
}, powerLevelsOverridden
|
}, powerLevelsOverridden
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue