diff --git a/src/github.com/matrix-org/dendrite/clientapi/producers/typingserver.go b/src/github.com/matrix-org/dendrite/clientapi/producers/typingserver.go index 90c5c209f..f4d0bcba7 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/producers/typingserver.go +++ b/src/github.com/matrix-org/dendrite/clientapi/producers/typingserver.go @@ -37,18 +37,17 @@ func (p *TypingServerProducer) Send( ctx context.Context, userID, roomID string, typing bool, timeout int64, ) error { - data := api.InputTypingEvent{ + requestData := api.InputTypingEvent{ UserID: userID, RoomID: roomID, Typing: typing, Timeout: timeout, OriginServerTS: gomatrixserverlib.AsTimestamp(time.Now()), } - request := []api.InputTypingEvent{data} - var response api.InputTypingEventsResponse - err := p.InputAPI.InputTypingEvents( - ctx, &api.InputTypingEventsRequest{InputTypingEvents: request}, &response, + var response api.InputTypingEventResponse + err := p.InputAPI.InputTypingEvent( + ctx, &api.InputTypingEventRequest{InputTypingEvent: requestData}, &response, ) return err diff --git a/src/github.com/matrix-org/dendrite/typingserver/api/input.go b/src/github.com/matrix-org/dendrite/typingserver/api/input.go index 332c4d2fe..25e2ea228 100644 --- a/src/github.com/matrix-org/dendrite/typingserver/api/input.go +++ b/src/github.com/matrix-org/dendrite/typingserver/api/input.go @@ -36,25 +36,25 @@ type InputTypingEvent struct { OriginServerTS gomatrixserverlib.Timestamp `json:"origin_server_ts"` } -// InputTypingEventsRequest is a request to TypingServerInputAPI -type InputTypingEventsRequest struct { - InputTypingEvents []InputTypingEvent `json:"input_typing_events"` +// InputTypingEventRequest is a request to TypingServerInputAPI +type InputTypingEventRequest struct { + InputTypingEvent InputTypingEvent `json:"input_typing_event"` } -// InputTypingEventsResponse is a response to InputTypingEvents -type InputTypingEventsResponse struct{} +// InputTypingEventResponse is a response to InputTypingEvents +type InputTypingEventResponse struct{} // TypingServerInputAPI is used to write events to the typing server. type TypingServerInputAPI interface { - InputTypingEvents( + InputTypingEvent( ctx context.Context, - request *InputTypingEventsRequest, - response *InputTypingEventsResponse, + request *InputTypingEventRequest, + response *InputTypingEventResponse, ) error } -// TypingServerInputTypingEventsPath is the HTTP path for the InputTypingEvents API. -const TypingServerInputTypingEventsPath = "/api/typingserver/input" +// TypingServerInputTypingEventPath is the HTTP path for the InputTypingEvent API. +const TypingServerInputTypingEventPath = "/api/typingserver/input" // NewTypingServerInputAPIHTTP creates a TypingServerInputAPI implemented by talking to a HTTP POST API. func NewTypingServerInputAPIHTTP(typingServerURL string, httpClient *http.Client) TypingServerInputAPI { @@ -70,14 +70,14 @@ type httpTypingServerInputAPI struct { } // InputRoomEvents implements TypingServerInputAPI -func (h *httpTypingServerInputAPI) InputTypingEvents( +func (h *httpTypingServerInputAPI) InputTypingEvent( ctx context.Context, - request *InputTypingEventsRequest, - response *InputTypingEventsResponse, + request *InputTypingEventRequest, + response *InputTypingEventResponse, ) error { - span, ctx := opentracing.StartSpanFromContext(ctx, "InputTypingEvents") + span, ctx := opentracing.StartSpanFromContext(ctx, "InputTypingEvent") defer span.Finish() - apiURL := h.typingServerURL + TypingServerInputTypingEventsPath + apiURL := h.typingServerURL + TypingServerInputTypingEventPath return commonHTTP.PostJSON(ctx, span, h.httpClient, apiURL, request, response) }