dendrite/relayapi/internal/api.go

53 lines
1.6 KiB
Go

// Copyright 2024 New Vector Ltd.
// Copyright 2022 The Matrix.org Foundation C.I.C.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
// Please see LICENSE files in the repository root for full details.
package internal
import (
"sync"
"github.com/element-hq/dendrite/federationapi/producers"
"github.com/element-hq/dendrite/relayapi/storage"
rsAPI "github.com/element-hq/dendrite/roomserver/api"
"github.com/matrix-org/gomatrixserverlib"
"github.com/matrix-org/gomatrixserverlib/fclient"
"github.com/matrix-org/gomatrixserverlib/spec"
)
type RelayInternalAPI struct {
db storage.Database
fedClient fclient.FederationClient
rsAPI rsAPI.RoomserverInternalAPI
keyRing *gomatrixserverlib.KeyRing
producer *producers.SyncAPIProducer
presenceEnabledInbound bool
serverName spec.ServerName
relayingEnabledMutex sync.Mutex
relayingEnabled bool
}
func NewRelayInternalAPI(
db storage.Database,
fedClient fclient.FederationClient,
rsAPI rsAPI.RoomserverInternalAPI,
keyRing *gomatrixserverlib.KeyRing,
producer *producers.SyncAPIProducer,
presenceEnabledInbound bool,
serverName spec.ServerName,
relayingEnabled bool,
) *RelayInternalAPI {
return &RelayInternalAPI{
db: db,
fedClient: fedClient,
rsAPI: rsAPI,
keyRing: keyRing,
producer: producer,
presenceEnabledInbound: presenceEnabledInbound,
serverName: serverName,
relayingEnabled: relayingEnabled,
}
}