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