Rename Input to Perform

This commit is contained in:
Neil Alexander 2020-04-29 10:32:38 +01:00
parent 63b28c1a31
commit 17999e2149
6 changed files with 92 additions and 92 deletions

View file

@ -25,16 +25,16 @@ type FederationSenderInternalAPI interface {
response *QueryJoinedHostServerNamesInRoomResponse,
) error
// Handle an instruction to make_join & send_join with a remote server.
InputJoinRequest(
PerformJoinRequest(
ctx context.Context,
request *InputJoinRequest,
response *InputJoinResponse,
request *PerformJoinRequest,
response *PerformJoinResponse,
) error
// Handle an instruction to make_leave & send_leave with a remote server.
InputLeaveRequest(
PerformLeaveRequest(
ctx context.Context,
request *InputLeaveRequest,
response *InputLeaveResponse,
request *PerformLeaveRequest,
response *PerformLeaveResponse,
) error
}

View file

@ -1,53 +0,0 @@
package api
import (
"context"
commonHTTP "github.com/matrix-org/dendrite/common/http"
"github.com/opentracing/opentracing-go"
)
const (
FederationSenderInputJoinRequestPath = "/api/federationsender/inputJoinRequest"
FederationSenderInputLeaveRequestPath = "/api/federationsender/inputLeaveRequest"
)
type InputJoinRequest struct {
RoomID string `json:"room_id"`
}
type InputJoinResponse struct {
}
// Handle an instruction to make_join & send_join with a remote server.
func (h *httpFederationSenderInternalAPI) InputJoinRequest(
ctx context.Context,
request *InputJoinRequest,
response *InputJoinResponse,
) error {
span, ctx := opentracing.StartSpanFromContext(ctx, "InputJoinRequest")
defer span.Finish()
apiURL := h.federationSenderURL + FederationSenderInputJoinRequestPath
return commonHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
type InputLeaveRequest struct {
RoomID string `json:"room_id"`
}
type InputLeaveResponse struct {
}
// Handle an instruction to make_leave & send_leave with a remote server.
func (h *httpFederationSenderInternalAPI) InputLeaveRequest(
ctx context.Context,
request *InputLeaveRequest,
response *InputLeaveResponse,
) error {
span, ctx := opentracing.StartSpanFromContext(ctx, "InputLeaveRequest")
defer span.Finish()
apiURL := h.federationSenderURL + FederationSenderInputLeaveRequestPath
return commonHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}

View file

@ -0,0 +1,53 @@
package api
import (
"context"
commonHTTP "github.com/matrix-org/dendrite/common/http"
"github.com/opentracing/opentracing-go"
)
const (
FederationSenderPerformJoinRequestPath = "/api/federationsender/inputJoinRequest"
FederationSenderPerformLeaveRequestPath = "/api/federationsender/inputLeaveRequest"
)
type PerformJoinRequest struct {
RoomID string `json:"room_id"`
}
type PerformJoinResponse struct {
}
// Handle an instruction to make_join & send_join with a remote server.
func (h *httpFederationSenderInternalAPI) PerformJoinRequest(
ctx context.Context,
request *PerformJoinRequest,
response *PerformJoinResponse,
) error {
span, ctx := opentracing.StartSpanFromContext(ctx, "PerformJoinRequest")
defer span.Finish()
apiURL := h.federationSenderURL + FederationSenderPerformJoinRequestPath
return commonHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}
type PerformLeaveRequest struct {
RoomID string `json:"room_id"`
}
type PerformLeaveResponse struct {
}
// Handle an instruction to make_leave & send_leave with a remote server.
func (h *httpFederationSenderInternalAPI) PerformLeaveRequest(
ctx context.Context,
request *PerformLeaveRequest,
response *PerformLeaveResponse,
) error {
span, ctx := opentracing.StartSpanFromContext(ctx, "PerformLeaveRequest")
defer span.Finish()
apiURL := h.federationSenderURL + FederationSenderPerformLeaveRequestPath
return commonHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response)
}

View file

@ -56,27 +56,27 @@ func (f *FederationSenderInternalAPI) SetupHTTP(servMux *http.ServeMux) {
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
}),
)
servMux.Handle(api.FederationSenderInputJoinRequestPath,
servMux.Handle(api.FederationSenderPerformJoinRequestPath,
common.MakeInternalAPI("inputJoinRequest", func(req *http.Request) util.JSONResponse {
var request api.InputJoinRequest
var response api.InputJoinResponse
var request api.PerformJoinRequest
var response api.PerformJoinResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
return util.MessageResponse(http.StatusBadRequest, err.Error())
}
if err := f.InputJoinRequest(req.Context(), &request, &response); err != nil {
if err := f.PerformJoinRequest(req.Context(), &request, &response); err != nil {
return util.ErrorResponse(err)
}
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
}),
)
servMux.Handle(api.FederationSenderInputLeaveRequestPath,
servMux.Handle(api.FederationSenderPerformLeaveRequestPath,
common.MakeInternalAPI("inputLeaveRequest", func(req *http.Request) util.JSONResponse {
var request api.InputLeaveRequest
var response api.InputLeaveResponse
var request api.PerformLeaveRequest
var response api.PerformLeaveResponse
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
return util.MessageResponse(http.StatusBadRequest, err.Error())
}
if err := f.InputLeaveRequest(req.Context(), &request, &response); err != nil {
if err := f.PerformLeaveRequest(req.Context(), &request, &response); err != nil {
return util.ErrorResponse(err)
}
return util.JSONResponse{Code: http.StatusOK, JSON: &response}

View file

@ -1,25 +0,0 @@
package query
import (
"context"
"github.com/matrix-org/dendrite/federationsender/api"
)
// InputJoinRequest implements api.FederationSenderInternalAPI
func (r *FederationSenderInternalAPI) InputJoinRequest(
ctx context.Context,
request *api.InputJoinRequest,
response *api.InputJoinResponse,
) (err error) {
return nil
}
// InputLeaveRequest implements api.FederationSenderInternalAPI
func (r *FederationSenderInternalAPI) InputLeaveRequest(
ctx context.Context,
request *api.InputLeaveRequest,
response *api.InputLeaveResponse,
) (err error) {
return nil
}

View file

@ -0,0 +1,25 @@
package query
import (
"context"
"github.com/matrix-org/dendrite/federationsender/api"
)
// PerformJoinRequest implements api.FederationSenderInternalAPI
func (r *FederationSenderInternalAPI) PerformJoinRequest(
ctx context.Context,
request *api.PerformJoinRequest,
response *api.PerformJoinResponse,
) (err error) {
return nil
}
// PerformLeaveRequest implements api.FederationSenderInternalAPI
func (r *FederationSenderInternalAPI) PerformLeaveRequest(
ctx context.Context,
request *api.PerformLeaveRequest,
response *api.PerformLeaveResponse,
) (err error) {
return nil
}