2018-01-02 10:26:56 +00:00
|
|
|
// Copyright 2017 Vector Creations Ltd
|
|
|
|
//
|
|
|
|
// 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 publicroomsapi
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/matrix-org/dendrite/clientapi/auth/storage/devices"
|
|
|
|
"github.com/matrix-org/dendrite/common/basecomponent"
|
2020-01-24 17:11:20 +00:00
|
|
|
"github.com/matrix-org/dendrite/publicroomsapi/consumers"
|
2018-01-02 10:26:56 +00:00
|
|
|
"github.com/matrix-org/dendrite/publicroomsapi/routing"
|
|
|
|
"github.com/matrix-org/dendrite/publicroomsapi/storage"
|
2020-03-19 11:04:08 +00:00
|
|
|
"github.com/matrix-org/dendrite/publicroomsapi/types"
|
2020-01-24 17:11:20 +00:00
|
|
|
roomserverAPI "github.com/matrix-org/dendrite/roomserver/api"
|
2020-03-19 11:04:08 +00:00
|
|
|
"github.com/matrix-org/gomatrixserverlib"
|
2018-01-02 10:26:56 +00:00
|
|
|
"github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
|
|
|
// SetupPublicRoomsAPIComponent sets up and registers HTTP handlers for the PublicRoomsAPI
|
|
|
|
// component.
|
|
|
|
func SetupPublicRoomsAPIComponent(
|
|
|
|
base *basecomponent.BaseDendrite,
|
2020-02-13 17:27:33 +00:00
|
|
|
deviceDB devices.Database,
|
2020-04-14 16:15:59 +01:00
|
|
|
publicRoomsDB storage.Database,
|
2020-05-01 10:48:17 +01:00
|
|
|
rsAPI roomserverAPI.RoomserverInternalAPI,
|
2020-03-19 11:04:08 +00:00
|
|
|
fedClient *gomatrixserverlib.FederationClient,
|
|
|
|
extRoomsProvider types.ExternalPublicRoomsProvider,
|
2018-01-02 10:26:56 +00:00
|
|
|
) {
|
2020-01-24 17:11:20 +00:00
|
|
|
rsConsumer := consumers.NewOutputRoomEventConsumer(
|
2020-05-01 10:48:17 +01:00
|
|
|
base.Cfg, base.KafkaConsumer, publicRoomsDB, rsAPI,
|
2020-01-24 17:11:20 +00:00
|
|
|
)
|
2020-04-14 16:15:59 +01:00
|
|
|
if err := rsConsumer.Start(); err != nil {
|
2020-01-24 17:11:20 +00:00
|
|
|
logrus.WithError(err).Panic("failed to start public rooms server consumer")
|
|
|
|
}
|
|
|
|
|
2020-05-01 10:48:17 +01:00
|
|
|
routing.Setup(base.APIMux, deviceDB, publicRoomsDB, rsAPI, fedClient, extRoomsProvider)
|
2018-01-02 10:26:56 +00:00
|
|
|
}
|