mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-17 11:53:09 -06:00
Fix wasm builds
This commit is contained in:
parent
64b03a01e4
commit
25ee936729
|
|
@ -19,9 +19,13 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/appservice/storage/sqlite3"
|
"github.com/matrix-org/dendrite/appservice/storage/sqlite3"
|
||||||
|
"github.com/matrix-org/dendrite/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewDatabase(dataSourceName string) (Database, error) {
|
func NewDatabase(
|
||||||
|
dataSourceName string,
|
||||||
|
dbProperties common.DbProperties, // nolint:unparam
|
||||||
|
) (Database, error) {
|
||||||
uri, err := url.Parse(dataSourceName)
|
uri, err := url.Parse(dataSourceName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Cannot use postgres implementation")
|
return nil, fmt.Errorf("Cannot use postgres implementation")
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,15 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/clientapi/auth/storage/accounts/sqlite3"
|
"github.com/matrix-org/dendrite/clientapi/auth/storage/accounts/sqlite3"
|
||||||
|
"github.com/matrix-org/dendrite/common"
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewDatabase(dataSourceName string, serverName gomatrixserverlib.ServerName) (Database, error) {
|
func NewDatabase(
|
||||||
|
dataSourceName string,
|
||||||
|
dbProperties common.DbProperties, // nolint:unparam
|
||||||
|
serverName gomatrixserverlib.ServerName,
|
||||||
|
) (Database, error) {
|
||||||
uri, err := url.Parse(dataSourceName)
|
uri, err := url.Parse(dataSourceName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Cannot use postgres implementation")
|
return nil, fmt.Errorf("Cannot use postgres implementation")
|
||||||
|
|
|
||||||
|
|
@ -19,10 +19,15 @@ import (
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/matrix-org/dendrite/clientapi/auth/storage/devices/sqlite3"
|
"github.com/matrix-org/dendrite/clientapi/auth/storage/devices/sqlite3"
|
||||||
|
"github.com/matrix-org/dendrite/common"
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewDatabase(dataSourceName string, serverName gomatrixserverlib.ServerName) (Database, error) {
|
func NewDatabase(
|
||||||
|
dataSourceName string,
|
||||||
|
dbProperties common.DbProperties, // nolint:unparam
|
||||||
|
serverName gomatrixserverlib.ServerName,
|
||||||
|
) (Database, error) {
|
||||||
uri, err := url.Parse(dataSourceName)
|
uri, err := url.Parse(dataSourceName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Cannot use postgres implementation")
|
return nil, fmt.Errorf("Cannot use postgres implementation")
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ func main() {
|
||||||
rsAPI := base.CreateHTTPRoomserverAPIs()
|
rsAPI := base.CreateHTTPRoomserverAPIs()
|
||||||
rsAPI.SetFederationSenderAPI(fsAPI)
|
rsAPI.SetFederationSenderAPI(fsAPI)
|
||||||
|
|
||||||
publicRoomsDB, err := storage.NewPublicRoomsServerDatabase(string(base.Cfg.Database.PublicRoomsAPI))
|
publicRoomsDB, err := storage.NewPublicRoomsServerDatabase(string(base.Cfg.Database.PublicRoomsAPI), base.Cfg.DbProperties())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Panicf("failed to connect to public rooms db")
|
logrus.WithError(err).Panicf("failed to connect to public rooms db")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import (
|
||||||
|
|
||||||
"golang.org/x/crypto/ed25519"
|
"golang.org/x/crypto/ed25519"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/common"
|
||||||
"github.com/matrix-org/dendrite/common/keydb/sqlite3"
|
"github.com/matrix-org/dendrite/common/keydb/sqlite3"
|
||||||
"github.com/matrix-org/gomatrixserverlib"
|
"github.com/matrix-org/gomatrixserverlib"
|
||||||
)
|
)
|
||||||
|
|
@ -27,6 +28,7 @@ import (
|
||||||
// NewDatabase opens a database connection.
|
// NewDatabase opens a database connection.
|
||||||
func NewDatabase(
|
func NewDatabase(
|
||||||
dataSourceName string,
|
dataSourceName string,
|
||||||
|
dbProperties common.DbProperties, // nolint:unparam
|
||||||
serverName gomatrixserverlib.ServerName,
|
serverName gomatrixserverlib.ServerName,
|
||||||
serverKey ed25519.PublicKey,
|
serverKey ed25519.PublicKey,
|
||||||
serverKeyID gomatrixserverlib.KeyID,
|
serverKeyID gomatrixserverlib.KeyID,
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ func SetupFederationSenderComponent(
|
||||||
rsAPI roomserverAPI.RoomserverInternalAPI,
|
rsAPI roomserverAPI.RoomserverInternalAPI,
|
||||||
keyRing *gomatrixserverlib.KeyRing,
|
keyRing *gomatrixserverlib.KeyRing,
|
||||||
) api.FederationSenderInternalAPI {
|
) api.FederationSenderInternalAPI {
|
||||||
federationSenderDB, err := storage.NewDatabase(string(base.Cfg.Database.FederationSender))
|
federationSenderDB, err := storage.NewDatabase(string(base.Cfg.Database.FederationSender), base.Cfg.DbProperties())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Panic("failed to connect to federation sender db")
|
logrus.WithError(err).Panic("failed to connect to federation sender db")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,15 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/common"
|
||||||
"github.com/matrix-org/dendrite/federationsender/storage/sqlite3"
|
"github.com/matrix-org/dendrite/federationsender/storage/sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewDatabase opens a new database
|
// NewDatabase opens a new database
|
||||||
func NewDatabase(dataSourceName string) (Database, error) {
|
func NewDatabase(
|
||||||
|
dataSourceName string,
|
||||||
|
dbProperties common.DbProperties, // nolint:unparam
|
||||||
|
) (Database, error) {
|
||||||
uri, err := url.Parse(dataSourceName)
|
uri, err := url.Parse(dataSourceName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Cannot use postgres implementation")
|
return nil, fmt.Errorf("Cannot use postgres implementation")
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,15 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/common"
|
||||||
"github.com/matrix-org/dendrite/mediaapi/storage/sqlite3"
|
"github.com/matrix-org/dendrite/mediaapi/storage/sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Open opens a postgres database.
|
// Open opens a postgres database.
|
||||||
func Open(dataSourceName string) (Database, error) {
|
func Open(
|
||||||
|
dataSourceName string,
|
||||||
|
dbProperties common.DbProperties, // nolint:unparam
|
||||||
|
) (Database, error) {
|
||||||
uri, err := url.Parse(dataSourceName)
|
uri, err := url.Parse(dataSourceName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Cannot use postgres implementation")
|
return nil, fmt.Errorf("Cannot use postgres implementation")
|
||||||
|
|
|
||||||
59
roomserver/api/perform.go
Normal file
59
roomserver/api/perform.go
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
commonHTTP "github.com/matrix-org/dendrite/common/http"
|
||||||
|
"github.com/opentracing/opentracing-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// RoomserverPerformJoinRequestPath is the HTTP path for the PerformJoinRequest API.
|
||||||
|
RoomserverPerformJoinRequestPath = "/api/roomserver/performJoin"
|
||||||
|
|
||||||
|
// RoomserverPerformLeaveRequestPath is the HTTP path for the PerformLeaveRequest API.
|
||||||
|
RoomserverPerformLeaveRequestPath = "/api/roomserver/performLeave"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PerformJoinRequest struct {
|
||||||
|
RoomID string `json:"room_id"`
|
||||||
|
UserID string `json:"user_id"`
|
||||||
|
Content map[string]interface{} `json:"content"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PerformJoinResponse struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle an instruction to make_join & send_join with a remote server.
|
||||||
|
func (h *httpRoomserverInternalAPI) PerformJoin(
|
||||||
|
ctx context.Context,
|
||||||
|
request *PerformJoinRequest,
|
||||||
|
response *PerformJoinResponse,
|
||||||
|
) error {
|
||||||
|
span, ctx := opentracing.StartSpanFromContext(ctx, "PerformJoinRequest")
|
||||||
|
defer span.Finish()
|
||||||
|
|
||||||
|
apiURL := h.roomserverURL + RoomserverPerformJoinRequestPath
|
||||||
|
return commonHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
||||||
|
}
|
||||||
|
|
||||||
|
type PerformLeaveRequest struct {
|
||||||
|
RoomID string `json:"room_id"`
|
||||||
|
UserID string `json:"user_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type PerformLeaveResponse struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle an instruction to make_leave & send_leave with a remote server.
|
||||||
|
func (h *httpRoomserverInternalAPI) PerformLeave(
|
||||||
|
ctx context.Context,
|
||||||
|
request *PerformLeaveRequest,
|
||||||
|
response *PerformLeaveResponse,
|
||||||
|
) error {
|
||||||
|
span, ctx := opentracing.StartSpanFromContext(ctx, "PerformLeaveRequest")
|
||||||
|
defer span.Finish()
|
||||||
|
|
||||||
|
apiURL := h.roomserverURL + RoomserverPerformLeaveRequestPath
|
||||||
|
return commonHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
||||||
|
}
|
||||||
|
|
@ -35,7 +35,7 @@ func SetupRoomServerComponent(
|
||||||
keyRing gomatrixserverlib.JSONVerifier,
|
keyRing gomatrixserverlib.JSONVerifier,
|
||||||
fedClient *gomatrixserverlib.FederationClient,
|
fedClient *gomatrixserverlib.FederationClient,
|
||||||
) api.RoomserverInternalAPI {
|
) api.RoomserverInternalAPI {
|
||||||
roomserverDB, err := storage.Open(string(base.Cfg.Database.RoomServer))
|
roomserverDB, err := storage.Open(string(base.Cfg.Database.RoomServer), base.Cfg.DbProperties())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.WithError(err).Panicf("failed to connect to room server db")
|
logrus.WithError(err).Panicf("failed to connect to room server db")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,15 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/common"
|
||||||
"github.com/matrix-org/dendrite/roomserver/storage/sqlite3"
|
"github.com/matrix-org/dendrite/roomserver/storage/sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewPublicRoomsServerDatabase opens a database connection.
|
// NewPublicRoomsServerDatabase opens a database connection.
|
||||||
func Open(dataSourceName string) (Database, error) {
|
func Open(
|
||||||
|
dataSourceName string,
|
||||||
|
dbProperties common.DbProperties, // nolint:unparam
|
||||||
|
) (Database, error) {
|
||||||
uri, err := url.Parse(dataSourceName)
|
uri, err := url.Parse(dataSourceName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Cannot use postgres implementation")
|
return nil, fmt.Errorf("Cannot use postgres implementation")
|
||||||
|
|
|
||||||
|
|
@ -18,11 +18,15 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
"github.com/matrix-org/dendrite/common"
|
||||||
"github.com/matrix-org/dendrite/syncapi/storage/sqlite3"
|
"github.com/matrix-org/dendrite/syncapi/storage/sqlite3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewPublicRoomsServerDatabase opens a database connection.
|
// NewPublicRoomsServerDatabase opens a database connection.
|
||||||
func NewSyncServerDatasource(dataSourceName string) (Database, error) {
|
func NewSyncServerDatasource(
|
||||||
|
dataSourceName string,
|
||||||
|
dbProperties common.DbProperties, // nolint:unparam
|
||||||
|
) (Database, error) {
|
||||||
uri, err := url.Parse(dataSourceName)
|
uri, err := url.Parse(dataSourceName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Cannot use postgres implementation")
|
return nil, fmt.Errorf("Cannot use postgres implementation")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue