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 15:15:59 +00:00
|
|
|
publicRoomsDB storage.Database,
|
2020-01-24 17:11:20 +00:00
|
|
|
rsQueryAPI roomserverAPI.RoomserverQueryAPI,
|
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(
|
|
|
|
base.Cfg, base.KafkaConsumer, publicRoomsDB, rsQueryAPI,
|
|
|
|
)
|
2020-04-14 15:15:59 +00: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-04-14 13:07:03 +00:00
|
|
|
routing.Setup(base.APIMux, deviceDB, publicRoomsDB, rsQueryAPI, fedClient, extRoomsProvider)
|
2018-01-02 10:26:56 +00:00
|
|
|
}
|