2022-04-28 15:02:30 +00:00
|
|
|
// Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
|
|
|
package perform
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-06-29 14:29:39 +00:00
|
|
|
"database/sql"
|
2022-04-28 15:02:30 +00:00
|
|
|
"encoding/json"
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/matrix-org/dendrite/internal/eventutil"
|
|
|
|
"github.com/matrix-org/dendrite/roomserver/api"
|
|
|
|
"github.com/matrix-org/dendrite/roomserver/internal/input"
|
|
|
|
"github.com/matrix-org/dendrite/roomserver/internal/query"
|
|
|
|
"github.com/matrix-org/dendrite/roomserver/storage"
|
2023-04-27 11:54:20 +00:00
|
|
|
"github.com/matrix-org/dendrite/roomserver/types"
|
2022-04-28 15:02:30 +00:00
|
|
|
"github.com/matrix-org/dendrite/setup/config"
|
|
|
|
"github.com/matrix-org/gomatrixserverlib"
|
2023-04-28 15:46:01 +00:00
|
|
|
"github.com/matrix-org/gomatrixserverlib/fclient"
|
2023-04-19 14:50:33 +00:00
|
|
|
"github.com/matrix-org/gomatrixserverlib/spec"
|
2023-01-19 20:02:32 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
2022-04-28 15:02:30 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Admin struct {
|
|
|
|
DB storage.Database
|
|
|
|
Cfg *config.RoomServer
|
|
|
|
Queryer *query.Queryer
|
|
|
|
Inputer *input.Inputer
|
2022-06-29 14:29:39 +00:00
|
|
|
Leaver *Leaver
|
2022-04-28 15:02:30 +00:00
|
|
|
}
|
|
|
|
|
2023-04-28 15:46:01 +00:00
|
|
|
// PerformAdminEvacuateRoom will remove all local users from the given room.
|
2022-04-28 15:02:30 +00:00
|
|
|
func (r *Admin) PerformAdminEvacuateRoom(
|
|
|
|
ctx context.Context,
|
2023-04-28 15:46:01 +00:00
|
|
|
roomID string,
|
|
|
|
) (affected []string, err error) {
|
|
|
|
roomInfo, err := r.DB.RoomInfo(ctx, roomID)
|
2022-04-28 15:02:30 +00:00
|
|
|
if err != nil {
|
2023-04-28 15:46:01 +00:00
|
|
|
return nil, err
|
2022-04-28 15:02:30 +00:00
|
|
|
}
|
2022-08-01 14:29:19 +00:00
|
|
|
if roomInfo == nil || roomInfo.IsStub() {
|
2023-05-17 00:33:27 +00:00
|
|
|
return nil, eventutil.ErrRoomNoExists{}
|
2022-04-28 15:02:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
memberNIDs, err := r.DB.GetMembershipEventNIDsForRoom(ctx, roomInfo.RoomNID, true, true)
|
|
|
|
if err != nil {
|
2023-04-28 15:46:01 +00:00
|
|
|
return nil, err
|
2022-04-28 15:02:30 +00:00
|
|
|
}
|
|
|
|
|
2023-05-08 19:25:44 +00:00
|
|
|
memberEvents, err := r.DB.Events(ctx, roomInfo.RoomVersion, memberNIDs)
|
2022-04-28 15:02:30 +00:00
|
|
|
if err != nil {
|
2023-04-28 15:46:01 +00:00
|
|
|
return nil, err
|
2022-04-28 15:02:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inputEvents := make([]api.InputRoomEvent, 0, len(memberEvents))
|
2023-04-28 15:46:01 +00:00
|
|
|
affected = make([]string, 0, len(memberEvents))
|
2022-04-28 15:02:30 +00:00
|
|
|
latestReq := &api.QueryLatestEventsAndStateRequest{
|
2023-04-28 15:46:01 +00:00
|
|
|
RoomID: roomID,
|
2022-04-28 15:02:30 +00:00
|
|
|
}
|
|
|
|
latestRes := &api.QueryLatestEventsAndStateResponse{}
|
|
|
|
if err = r.Queryer.QueryLatestEventsAndState(ctx, latestReq, latestRes); err != nil {
|
2023-04-28 15:46:01 +00:00
|
|
|
return nil, err
|
2022-04-28 15:02:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
prevEvents := latestRes.LatestEvents
|
2023-04-28 15:46:01 +00:00
|
|
|
var senderDomain spec.ServerName
|
|
|
|
var eventsNeeded gomatrixserverlib.StateNeeded
|
|
|
|
var identity *fclient.SigningIdentity
|
|
|
|
var event *types.HeaderedEvent
|
2022-04-28 15:02:30 +00:00
|
|
|
for _, memberEvent := range memberEvents {
|
|
|
|
if memberEvent.StateKey() == nil {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
var memberContent gomatrixserverlib.MemberContent
|
|
|
|
if err = json.Unmarshal(memberEvent.Content(), &memberContent); err != nil {
|
2023-04-28 15:46:01 +00:00
|
|
|
return nil, err
|
2022-04-28 15:02:30 +00:00
|
|
|
}
|
2023-04-19 14:50:33 +00:00
|
|
|
memberContent.Membership = spec.Leave
|
2022-04-28 15:02:30 +00:00
|
|
|
|
|
|
|
stateKey := *memberEvent.StateKey()
|
2023-05-04 10:17:42 +00:00
|
|
|
fledglingEvent := &gomatrixserverlib.ProtoEvent{
|
2023-04-28 15:46:01 +00:00
|
|
|
RoomID: roomID,
|
2023-04-19 14:50:33 +00:00
|
|
|
Type: spec.MRoomMember,
|
2022-04-28 15:02:30 +00:00
|
|
|
StateKey: &stateKey,
|
2023-06-07 17:14:35 +00:00
|
|
|
SenderID: stateKey,
|
2022-04-28 15:02:30 +00:00
|
|
|
PrevEvents: prevEvents,
|
|
|
|
}
|
|
|
|
|
2023-06-07 17:14:35 +00:00
|
|
|
userID, err := r.Queryer.QueryUserIDForSender(ctx, roomID, spec.SenderID(fledglingEvent.SenderID))
|
|
|
|
if err != nil || userID == nil {
|
2022-10-26 11:59:19 +00:00
|
|
|
continue
|
|
|
|
}
|
2023-06-07 17:14:35 +00:00
|
|
|
senderDomain = userID.Domain()
|
2022-10-26 11:59:19 +00:00
|
|
|
|
2022-04-28 15:02:30 +00:00
|
|
|
if fledglingEvent.Content, err = json.Marshal(memberContent); err != nil {
|
2023-04-28 15:46:01 +00:00
|
|
|
return nil, err
|
2022-04-28 15:02:30 +00:00
|
|
|
}
|
|
|
|
|
2023-05-04 10:17:42 +00:00
|
|
|
eventsNeeded, err = gomatrixserverlib.StateNeededForProtoEvent(fledglingEvent)
|
2022-04-28 15:02:30 +00:00
|
|
|
if err != nil {
|
2023-04-28 15:46:01 +00:00
|
|
|
return nil, err
|
2022-04-28 15:02:30 +00:00
|
|
|
}
|
|
|
|
|
2023-04-28 15:46:01 +00:00
|
|
|
identity, err = r.Cfg.Matrix.SigningIdentityFor(senderDomain)
|
2022-11-15 15:05:23 +00:00
|
|
|
if err != nil {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
2023-05-31 15:27:08 +00:00
|
|
|
event, err = eventutil.BuildEvent(ctx, fledglingEvent, identity, time.Now(), &eventsNeeded, latestRes)
|
2022-04-28 15:02:30 +00:00
|
|
|
if err != nil {
|
2023-04-28 15:46:01 +00:00
|
|
|
return nil, err
|
2022-04-28 15:02:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inputEvents = append(inputEvents, api.InputRoomEvent{
|
|
|
|
Kind: api.KindNew,
|
|
|
|
Event: event,
|
2022-10-26 11:59:19 +00:00
|
|
|
Origin: senderDomain,
|
|
|
|
SendAsServer: string(senderDomain),
|
2022-04-28 15:02:30 +00:00
|
|
|
})
|
2023-04-28 15:46:01 +00:00
|
|
|
affected = append(affected, stateKey)
|
2023-05-24 10:14:42 +00:00
|
|
|
prevEvents = []string{event.EventID()}
|
2022-04-28 15:02:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inputReq := &api.InputRoomEventsRequest{
|
|
|
|
InputRoomEvents: inputEvents,
|
2023-05-30 08:02:53 +00:00
|
|
|
Asynchronous: false,
|
2022-04-28 15:02:30 +00:00
|
|
|
}
|
|
|
|
inputRes := &api.InputRoomEventsResponse{}
|
2023-05-09 22:46:49 +00:00
|
|
|
r.Inputer.InputRoomEvents(ctx, inputReq, inputRes)
|
|
|
|
return affected, nil
|
2022-04-28 15:02:30 +00:00
|
|
|
}
|
2022-06-29 14:29:39 +00:00
|
|
|
|
2023-04-28 15:46:01 +00:00
|
|
|
// PerformAdminEvacuateUser will remove the given user from all rooms.
|
2022-06-29 14:29:39 +00:00
|
|
|
func (r *Admin) PerformAdminEvacuateUser(
|
|
|
|
ctx context.Context,
|
2023-04-28 15:46:01 +00:00
|
|
|
userID string,
|
|
|
|
) (affected []string, err error) {
|
|
|
|
_, domain, err := gomatrixserverlib.SplitID('@', userID)
|
2022-06-29 14:29:39 +00:00
|
|
|
if err != nil {
|
2023-04-28 15:46:01 +00:00
|
|
|
return nil, err
|
2022-06-29 14:29:39 +00:00
|
|
|
}
|
2022-10-26 11:59:19 +00:00
|
|
|
if !r.Cfg.Matrix.IsLocalServerName(domain) {
|
2023-04-28 15:46:01 +00:00
|
|
|
return nil, fmt.Errorf("can only evacuate local users using this endpoint")
|
2022-06-29 14:29:39 +00:00
|
|
|
}
|
|
|
|
|
2023-04-28 15:46:01 +00:00
|
|
|
roomIDs, err := r.DB.GetRoomsByMembership(ctx, userID, spec.Join)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2022-06-29 14:29:39 +00:00
|
|
|
}
|
|
|
|
|
2023-04-28 15:46:01 +00:00
|
|
|
inviteRoomIDs, err := r.DB.GetRoomsByMembership(ctx, userID, spec.Invite)
|
2022-06-29 14:29:39 +00:00
|
|
|
if err != nil && err != sql.ErrNoRows {
|
2023-04-28 15:46:01 +00:00
|
|
|
return nil, err
|
2022-06-29 14:29:39 +00:00
|
|
|
}
|
|
|
|
|
2023-04-28 15:46:01 +00:00
|
|
|
allRooms := append(roomIDs, inviteRoomIDs...)
|
|
|
|
affected = make([]string, 0, len(allRooms))
|
|
|
|
for _, roomID := range allRooms {
|
2022-06-29 14:29:39 +00:00
|
|
|
leaveReq := &api.PerformLeaveRequest{
|
|
|
|
RoomID: roomID,
|
2023-04-28 15:46:01 +00:00
|
|
|
UserID: userID,
|
2022-06-29 14:29:39 +00:00
|
|
|
}
|
|
|
|
leaveRes := &api.PerformLeaveResponse{}
|
|
|
|
outputEvents, err := r.Leaver.PerformLeave(ctx, leaveReq, leaveRes)
|
|
|
|
if err != nil {
|
2023-04-28 15:46:01 +00:00
|
|
|
return nil, err
|
2022-06-29 14:29:39 +00:00
|
|
|
}
|
2023-04-28 15:46:01 +00:00
|
|
|
affected = append(affected, roomID)
|
2022-06-29 14:29:39 +00:00
|
|
|
if len(outputEvents) == 0 {
|
|
|
|
continue
|
|
|
|
}
|
2022-07-01 09:54:07 +00:00
|
|
|
if err := r.Inputer.OutputProducer.ProduceRoomEvents(roomID, outputEvents); err != nil {
|
2023-04-28 15:46:01 +00:00
|
|
|
return nil, err
|
2022-06-29 14:29:39 +00:00
|
|
|
}
|
|
|
|
}
|
2023-04-28 15:46:01 +00:00
|
|
|
return affected, nil
|
2022-06-29 14:29:39 +00:00
|
|
|
}
|
2022-10-31 09:13:28 +00:00
|
|
|
|
2023-04-28 15:46:01 +00:00
|
|
|
// PerformAdminPurgeRoom removes all traces for the given room from the database.
|
2023-01-19 20:02:32 +00:00
|
|
|
func (r *Admin) PerformAdminPurgeRoom(
|
|
|
|
ctx context.Context,
|
2023-04-28 15:46:01 +00:00
|
|
|
roomID string,
|
2023-01-19 20:02:32 +00:00
|
|
|
) error {
|
|
|
|
// Validate we actually got a room ID and nothing else
|
2023-04-28 15:46:01 +00:00
|
|
|
if _, _, err := gomatrixserverlib.SplitID('!', roomID); err != nil {
|
|
|
|
return err
|
2023-01-19 20:02:32 +00:00
|
|
|
}
|
|
|
|
|
2023-04-28 15:46:01 +00:00
|
|
|
// Evacuate the room before purging it from the database
|
2023-05-30 08:02:53 +00:00
|
|
|
evacAffected, err := r.PerformAdminEvacuateRoom(ctx, roomID)
|
|
|
|
if err != nil {
|
2023-04-28 15:46:01 +00:00
|
|
|
logrus.WithField("room_id", roomID).WithError(err).Warn("Failed to evacuate room before purging")
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-05-30 08:02:53 +00:00
|
|
|
logrus.WithFields(logrus.Fields{
|
|
|
|
"room_id": roomID,
|
|
|
|
"evacuated_users": len(evacAffected),
|
|
|
|
}).Warn("Evacuated room, purging room from roomserver now")
|
|
|
|
|
2023-04-28 15:46:01 +00:00
|
|
|
logrus.WithField("room_id", roomID).Warn("Purging room from roomserver")
|
|
|
|
if err := r.DB.PurgeRoom(ctx, roomID); err != nil {
|
|
|
|
logrus.WithField("room_id", roomID).WithError(err).Warn("Failed to purge room from roomserver")
|
|
|
|
return err
|
2023-01-19 20:02:32 +00:00
|
|
|
}
|
|
|
|
|
2023-05-30 08:02:53 +00:00
|
|
|
logrus.WithField("room_id", roomID).Warn("Room purged from roomserver, informing other components")
|
2023-01-19 20:02:32 +00:00
|
|
|
|
2023-04-28 15:46:01 +00:00
|
|
|
return r.Inputer.OutputProducer.ProduceRoomEvents(roomID, []api.OutputEvent{
|
2023-01-19 20:02:32 +00:00
|
|
|
{
|
|
|
|
Type: api.OutputTypePurgeRoom,
|
|
|
|
PurgeRoom: &api.OutputPurgeRoom{
|
2023-04-28 15:46:01 +00:00
|
|
|
RoomID: roomID,
|
2023-01-19 20:02:32 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-10-31 09:13:28 +00:00
|
|
|
func (r *Admin) PerformAdminDownloadState(
|
|
|
|
ctx context.Context,
|
2023-04-28 15:46:01 +00:00
|
|
|
roomID, userID string, serverName spec.ServerName,
|
2022-10-31 09:13:28 +00:00
|
|
|
) error {
|
2023-06-07 17:14:35 +00:00
|
|
|
fullUserID, err := spec.NewUserID(userID, true)
|
2022-11-15 15:05:23 +00:00
|
|
|
if err != nil {
|
2023-04-28 15:46:01 +00:00
|
|
|
return err
|
2022-11-15 15:05:23 +00:00
|
|
|
}
|
2023-06-07 17:14:35 +00:00
|
|
|
senderDomain := fullUserID.Domain()
|
2022-11-15 15:05:23 +00:00
|
|
|
|
2023-04-28 15:46:01 +00:00
|
|
|
roomInfo, err := r.DB.RoomInfo(ctx, roomID)
|
2022-10-31 09:13:28 +00:00
|
|
|
if err != nil {
|
2023-04-28 15:46:01 +00:00
|
|
|
return err
|
2022-10-31 09:13:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if roomInfo == nil || roomInfo.IsStub() {
|
2023-05-17 00:33:27 +00:00
|
|
|
return eventutil.ErrRoomNoExists{}
|
2022-10-31 09:13:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fwdExtremities, _, depth, err := r.DB.LatestEventIDs(ctx, roomInfo.RoomNID)
|
|
|
|
if err != nil {
|
2023-04-28 15:46:01 +00:00
|
|
|
return err
|
2022-10-31 09:13:28 +00:00
|
|
|
}
|
|
|
|
|
2023-05-02 14:03:16 +00:00
|
|
|
authEventMap := map[string]gomatrixserverlib.PDU{}
|
|
|
|
stateEventMap := map[string]gomatrixserverlib.PDU{}
|
2022-10-31 09:13:28 +00:00
|
|
|
|
|
|
|
for _, fwdExtremity := range fwdExtremities {
|
2023-04-06 08:55:01 +00:00
|
|
|
var state gomatrixserverlib.StateResponse
|
2023-05-24 10:14:42 +00:00
|
|
|
state, err = r.Inputer.FSAPI.LookupState(ctx, r.Inputer.ServerName, serverName, roomID, fwdExtremity, roomInfo.RoomVersion)
|
2022-10-31 09:13:28 +00:00
|
|
|
if err != nil {
|
2023-05-24 10:14:42 +00:00
|
|
|
return fmt.Errorf("r.Inputer.FSAPI.LookupState (%q): %s", fwdExtremity, err)
|
2022-10-31 09:13:28 +00:00
|
|
|
}
|
2023-04-06 08:55:01 +00:00
|
|
|
for _, authEvent := range state.GetAuthEvents().UntrustedEvents(roomInfo.RoomVersion) {
|
2023-06-07 17:14:35 +00:00
|
|
|
if err = gomatrixserverlib.VerifyEventSignatures(ctx, authEvent, r.Inputer.KeyRing, func(roomID string, senderID spec.SenderID) (*spec.UserID, error) {
|
2023-06-06 20:55:18 +00:00
|
|
|
return r.DB.GetUserIDForSender(ctx, roomID, senderID)
|
|
|
|
}); err != nil {
|
2022-10-31 09:13:28 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
authEventMap[authEvent.EventID()] = authEvent
|
|
|
|
}
|
2023-04-06 08:55:01 +00:00
|
|
|
for _, stateEvent := range state.GetStateEvents().UntrustedEvents(roomInfo.RoomVersion) {
|
2023-06-07 17:14:35 +00:00
|
|
|
if err = gomatrixserverlib.VerifyEventSignatures(ctx, stateEvent, r.Inputer.KeyRing, func(roomID string, senderID spec.SenderID) (*spec.UserID, error) {
|
2023-06-06 20:55:18 +00:00
|
|
|
return r.DB.GetUserIDForSender(ctx, roomID, senderID)
|
|
|
|
}); err != nil {
|
2022-10-31 09:13:28 +00:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
stateEventMap[stateEvent.EventID()] = stateEvent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-27 11:54:20 +00:00
|
|
|
authEvents := make([]*types.HeaderedEvent, 0, len(authEventMap))
|
|
|
|
stateEvents := make([]*types.HeaderedEvent, 0, len(stateEventMap))
|
2022-10-31 09:13:28 +00:00
|
|
|
stateIDs := make([]string, 0, len(stateEventMap))
|
|
|
|
|
|
|
|
for _, authEvent := range authEventMap {
|
2023-05-02 14:03:16 +00:00
|
|
|
authEvents = append(authEvents, &types.HeaderedEvent{PDU: authEvent})
|
2022-10-31 09:13:28 +00:00
|
|
|
}
|
|
|
|
for _, stateEvent := range stateEventMap {
|
2023-05-02 14:03:16 +00:00
|
|
|
stateEvents = append(stateEvents, &types.HeaderedEvent{PDU: stateEvent})
|
2022-10-31 09:13:28 +00:00
|
|
|
stateIDs = append(stateIDs, stateEvent.EventID())
|
|
|
|
}
|
|
|
|
|
2023-06-07 17:14:35 +00:00
|
|
|
senderID, err := r.Queryer.QuerySenderIDForUser(ctx, roomID, *fullUserID)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2023-05-04 10:17:42 +00:00
|
|
|
proto := &gomatrixserverlib.ProtoEvent{
|
2023-06-07 17:14:35 +00:00
|
|
|
Type: "org.matrix.dendrite.state_download",
|
|
|
|
SenderID: string(senderID),
|
|
|
|
RoomID: roomID,
|
|
|
|
Content: spec.RawJSON("{}"),
|
2022-10-31 09:13:28 +00:00
|
|
|
}
|
|
|
|
|
2023-05-04 10:17:42 +00:00
|
|
|
eventsNeeded, err := gomatrixserverlib.StateNeededForProtoEvent(proto)
|
2022-10-31 09:13:28 +00:00
|
|
|
if err != nil {
|
2023-05-04 10:17:42 +00:00
|
|
|
return fmt.Errorf("gomatrixserverlib.StateNeededForProtoEvent: %w", err)
|
2022-10-31 09:13:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
queryRes := &api.QueryLatestEventsAndStateResponse{
|
|
|
|
RoomExists: true,
|
|
|
|
RoomVersion: roomInfo.RoomVersion,
|
|
|
|
LatestEvents: fwdExtremities,
|
|
|
|
StateEvents: stateEvents,
|
|
|
|
Depth: depth,
|
|
|
|
}
|
|
|
|
|
2022-11-15 15:05:23 +00:00
|
|
|
identity, err := r.Cfg.Matrix.SigningIdentityFor(senderDomain)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2023-05-31 15:27:08 +00:00
|
|
|
ev, err := eventutil.BuildEvent(ctx, proto, identity, time.Now(), &eventsNeeded, queryRes)
|
2022-10-31 09:13:28 +00:00
|
|
|
if err != nil {
|
2023-04-28 15:46:01 +00:00
|
|
|
return fmt.Errorf("eventutil.BuildEvent: %w", err)
|
2022-10-31 09:13:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inputReq := &api.InputRoomEventsRequest{
|
|
|
|
Asynchronous: false,
|
|
|
|
}
|
|
|
|
inputRes := &api.InputRoomEventsResponse{}
|
|
|
|
|
|
|
|
for _, authEvent := range append(authEvents, stateEvents...) {
|
|
|
|
inputReq.InputRoomEvents = append(inputReq.InputRoomEvents, api.InputRoomEvent{
|
|
|
|
Kind: api.KindOutlier,
|
|
|
|
Event: authEvent,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
inputReq.InputRoomEvents = append(inputReq.InputRoomEvents, api.InputRoomEvent{
|
|
|
|
Kind: api.KindNew,
|
|
|
|
Event: ev,
|
|
|
|
Origin: r.Cfg.Matrix.ServerName,
|
|
|
|
HasState: true,
|
|
|
|
StateEventIDs: stateIDs,
|
|
|
|
SendAsServer: string(r.Cfg.Matrix.ServerName),
|
|
|
|
})
|
|
|
|
|
2023-05-09 22:46:49 +00:00
|
|
|
r.Inputer.InputRoomEvents(ctx, inputReq, inputRes)
|
2022-10-31 09:13:28 +00:00
|
|
|
|
|
|
|
if inputRes.ErrMsg != "" {
|
2023-04-28 15:46:01 +00:00
|
|
|
return inputRes.Err()
|
2022-10-31 09:13:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|