mirror of
https://github.com/matrix-org/dendrite.git
synced 2026-01-17 02:53:11 -06:00
Closes HNT-244. The following PR implements Space,Channel soft deletion using on-chain `disabled` flag scope to space, channel respectively. On message sync, dendrite will now gate disabled rooms by performing a leave on the user attempting to sync unless the user is the owner (more on this later). To re-join, given rooms (spaces,channels) are created by default using `invite` membership state, the owner will need to undo the on-chain `disabled` flag, setting it false then re-invite users that left the room as a side effect of it becoming disabled previously. The owner does not leave the space, channel because if they did then there would be no one left to invite users let alone themselves back in if the action is ever undone. What is not implemented in this PR: 1. **Transitive leaves on channels in a space** - If a space is disabled, users will leave the space but not the channels within the space. To allow for fully disabling a space and all its' channels, the client can offer a view to the owner that iterates over the channels and space to disable all on-chain. Furthermore, we could implement a batch on-chain method that fully disables all channels within a space (plus the space) in one on-chain call to save the owner gas. 2. **Data deletion** - No data is remove from the DAGs or on-chain. Therefore deletion is soft and reversible. 3. **New hook to check if a room is disabled** - the client can leverage existing on-chain public read only methods `getSpaceInfoBySpaceId`, `getChannelInfoByChannelId` to read the state of each in order to remove spaces, channels from a member's view that are disabled.
75 lines
2.7 KiB
Go
75 lines
2.7 KiB
Go
// Copyright 2020 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 setup
|
|
|
|
import (
|
|
appserviceAPI "github.com/matrix-org/dendrite/appservice/api"
|
|
"github.com/matrix-org/dendrite/clientapi"
|
|
"github.com/matrix-org/dendrite/clientapi/api"
|
|
"github.com/matrix-org/dendrite/federationapi"
|
|
federationAPI "github.com/matrix-org/dendrite/federationapi/api"
|
|
"github.com/matrix-org/dendrite/internal/transactions"
|
|
keyAPI "github.com/matrix-org/dendrite/keyserver/api"
|
|
"github.com/matrix-org/dendrite/mediaapi"
|
|
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
|
|
"github.com/matrix-org/dendrite/setup/base"
|
|
"github.com/matrix-org/dendrite/setup/config"
|
|
"github.com/matrix-org/dendrite/syncapi"
|
|
userapi "github.com/matrix-org/dendrite/userapi/api"
|
|
"github.com/matrix-org/gomatrixserverlib"
|
|
)
|
|
|
|
// Monolith represents an instantiation of all dependencies required to build
|
|
// all components of Dendrite, for use in monolith mode.
|
|
type Monolith struct {
|
|
Config *config.Dendrite
|
|
KeyRing *gomatrixserverlib.KeyRing
|
|
Client *gomatrixserverlib.Client
|
|
FedClient *gomatrixserverlib.FederationClient
|
|
|
|
AppserviceAPI appserviceAPI.AppServiceInternalAPI
|
|
FederationAPI federationAPI.FederationInternalAPI
|
|
RoomserverAPI roomserverAPI.RoomserverInternalAPI
|
|
UserAPI userapi.UserInternalAPI
|
|
KeyAPI keyAPI.KeyInternalAPI
|
|
|
|
// Optional
|
|
ExtPublicRoomsProvider api.ExtraPublicRoomsProvider
|
|
ExtUserDirectoryProvider userapi.QuerySearchProfilesAPI
|
|
}
|
|
|
|
// AddAllPublicRoutes attaches all public paths to the given router
|
|
func (m *Monolith) AddAllPublicRoutes(base *base.BaseDendrite) {
|
|
userDirectoryProvider := m.ExtUserDirectoryProvider
|
|
if userDirectoryProvider == nil {
|
|
userDirectoryProvider = m.UserAPI
|
|
}
|
|
clientapi.AddPublicRoutes(
|
|
base, m.FedClient, m.RoomserverAPI, m.AppserviceAPI, transactions.New(),
|
|
m.FederationAPI, m.UserAPI, userDirectoryProvider, m.KeyAPI,
|
|
m.ExtPublicRoomsProvider,
|
|
)
|
|
federationapi.AddPublicRoutes(
|
|
base, m.UserAPI, m.FedClient, m.KeyRing, m.RoomserverAPI, m.FederationAPI,
|
|
m.KeyAPI, nil,
|
|
)
|
|
mediaapi.AddPublicRoutes(
|
|
base, m.UserAPI, m.Client,
|
|
)
|
|
syncapi.AddPublicRoutes(
|
|
base, m.UserAPI, m.RoomserverAPI, m.RoomserverAPI, m.KeyAPI,
|
|
)
|
|
}
|