Rename struct to fit namescheme

This commit is contained in:
Till Faelligen 2020-10-13 07:31:13 +02:00
parent afef2a19ae
commit d8dd4d7bc4
8 changed files with 22 additions and 9 deletions

View file

@ -30,7 +30,7 @@ func SetReceipt(req *http.Request, rsAPI roomserverAPI.RoomserverInternalAPI, de
"eventId": eventId,
"userId": device.UserID,
}).Debug("Setting receipt")
userReq := &roomserverAPI.PerformUserReceiptUpdate{
userReq := &roomserverAPI.PerformUserReceiptUpdateRequest{
RoomID: roomId,
ReceiptType: receiptType,
EventID: eventId,

View file

@ -196,5 +196,5 @@ type RoomserverInternalAPI interface {
response *RemoveRoomAliasResponse,
) error
PerformUserReceiptUpdate(ctx context.Context, req *PerformUserReceiptUpdate, res *PerformUserReceiptUpdateResponse) error
PerformUserReceiptUpdate(ctx context.Context, req *PerformUserReceiptUpdateRequest, res *PerformUserReceiptUpdateResponse) error
}

View file

@ -315,10 +315,10 @@ func js(thing interface{}) string {
func (t *RoomserverInternalAPITrace) PerformUserReceiptUpdate(
ctx context.Context,
req *PerformUserReceiptUpdate,
req *PerformUserReceiptUpdateRequest,
res *PerformUserReceiptUpdateResponse,
) error {
err := t.Impl.PerformUserReceiptUpdate(ctx, req, res)
util.GetLogger(ctx).WithError(err).Infof("PerformUserReceiptUpdate req=%+v res=%+v", js(req), js(res))
util.GetLogger(ctx).WithError(err).Infof("PerformUserReceiptUpdateRequest req=%+v res=%+v", js(req), js(res))
return err
}

View file

@ -1,6 +1,6 @@
package api
type PerformUserReceiptUpdate struct {
type PerformUserReceiptUpdateRequest struct {
RoomID string
ReceiptType string
EventID string

View file

@ -150,7 +150,7 @@ func (r *RoomserverInternalAPI) PerformLeave(
func (r *RoomserverInternalAPI) PerformUserReceiptUpdate(
ctx context.Context,
req *api.PerformUserReceiptUpdate,
req *api.PerformUserReceiptUpdateRequest,
res *api.PerformUserReceiptUpdateResponse,
) error {
return r.Receipter.PerformUserReceiptUpdate(ctx, req, res)

View file

@ -11,6 +11,6 @@ type Receipter struct {
DB storage.Database
}
func (r *Receipter) PerformUserReceiptUpdate(ctx context.Context, req *api.PerformUserReceiptUpdate, res *api.PerformUserReceiptUpdateResponse) error {
func (r *Receipter) PerformUserReceiptUpdate(ctx context.Context, req *api.PerformUserReceiptUpdateRequest, res *api.PerformUserReceiptUpdateResponse) error {
return r.DB.StoreReceipt(ctx, req.RoomID, req.ReceiptType, req.UserID, req.EventID)
}

View file

@ -496,10 +496,10 @@ func (h *httpRoomserverInternalAPI) QueryServerBannedFromRoom(
func (h *httpRoomserverInternalAPI) PerformUserReceiptUpdate(
ctx context.Context,
req *api.PerformUserReceiptUpdate,
req *api.PerformUserReceiptUpdateRequest,
res *api.PerformUserReceiptUpdateResponse,
) error {
span, ctx := opentracing.StartSpanFromContext(ctx, "PerformUserReceiptUpdate")
span, ctx := opentracing.StartSpanFromContext(ctx, "PerformUserReceiptUpdateRequest")
defer span.Finish()
apiURL := h.roomserverURL + RoomserverPerformReceiptUpdatePath

View file

@ -427,4 +427,17 @@ func AddRoutes(r api.RoomserverInternalAPI, internalAPIMux *mux.Router) {
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
}),
)
internalAPIMux.Handle(RoomserverPerformReceiptUpdatePath,
httputil.MakeInternalAPI("performReceiptUpdate", func(req *http.Request) util.JSONResponse {
request := api.PerformUserReceiptUpdateRequest{}
response := api.PerformUserReceiptUpdateResponse{}
if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
return util.MessageResponse(http.StatusBadRequest, err.Error())
}
if err := r.PerformUserReceiptUpdate(req.Context(), &request, &response); err != nil {
return util.ErrorResponse(err)
}
return util.JSONResponse{Code: http.StatusOK, JSON: &response}
}),
)
}