2020-05-04 12:53:47 +00:00
|
|
|
package api
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2020-05-21 13:40:13 +00:00
|
|
|
internalHTTP "github.com/matrix-org/dendrite/internal/http"
|
2020-05-04 12:53:47 +00:00
|
|
|
"github.com/matrix-org/gomatrixserverlib"
|
|
|
|
"github.com/opentracing/opentracing-go"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
// RoomserverPerformJoinPath is the HTTP path for the PerformJoin API.
|
2020-05-22 10:43:17 +00:00
|
|
|
RoomserverPerformJoinPath = "/roomserver/performJoin"
|
2020-05-04 12:53:47 +00:00
|
|
|
|
|
|
|
// RoomserverPerformLeavePath is the HTTP path for the PerformLeave API.
|
2020-05-22 10:43:17 +00:00
|
|
|
RoomserverPerformLeavePath = "/roomserver/performLeave"
|
2020-05-04 12:53:47 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type PerformJoinRequest struct {
|
|
|
|
RoomIDOrAlias string `json:"room_id_or_alias"`
|
|
|
|
UserID string `json:"user_id"`
|
|
|
|
Content map[string]interface{} `json:"content"`
|
|
|
|
ServerNames []gomatrixserverlib.ServerName `json:"server_names"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type PerformJoinResponse struct {
|
2020-05-26 13:41:16 +00:00
|
|
|
RoomID string `json:"room_id"`
|
2020-05-04 12:53:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (h *httpRoomserverInternalAPI) PerformJoin(
|
|
|
|
ctx context.Context,
|
|
|
|
request *PerformJoinRequest,
|
|
|
|
response *PerformJoinResponse,
|
|
|
|
) error {
|
|
|
|
span, ctx := opentracing.StartSpanFromContext(ctx, "PerformJoin")
|
|
|
|
defer span.Finish()
|
|
|
|
|
|
|
|
apiURL := h.roomserverURL + RoomserverPerformJoinPath
|
2020-05-21 13:40:13 +00:00
|
|
|
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
2020-05-04 12:53:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type PerformLeaveRequest struct {
|
|
|
|
RoomID string `json:"room_id"`
|
|
|
|
UserID string `json:"user_id"`
|
|
|
|
}
|
|
|
|
|
|
|
|
type PerformLeaveResponse struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *httpRoomserverInternalAPI) PerformLeave(
|
|
|
|
ctx context.Context,
|
|
|
|
request *PerformLeaveRequest,
|
|
|
|
response *PerformLeaveResponse,
|
|
|
|
) error {
|
|
|
|
span, ctx := opentracing.StartSpanFromContext(ctx, "PerformLeave")
|
|
|
|
defer span.Finish()
|
|
|
|
|
|
|
|
apiURL := h.roomserverURL + RoomserverPerformLeavePath
|
2020-05-21 13:40:13 +00:00
|
|
|
return internalHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
|
2020-05-04 12:53:47 +00:00
|
|
|
}
|