diff --git a/clientapi/routing/consent_tracking.go b/clientapi/routing/consent_tracking.go index a52f62b39..ec5b10a7e 100644 --- a/clientapi/routing/consent_tracking.go +++ b/clientapi/routing/consent_tracking.go @@ -131,8 +131,8 @@ func sendServerNoticeForConsent(userAPI userapi.UserInternalAPI, rsAPI api.Rooms accountsDB userdb.Database, asAPI appserviceAPI.AppServiceQueryAPI, ) { - res := &userapi.QueryOutdatedPolicyUsersResponse{} - if err := userAPI.GetOutdatedPolicy(context.Background(), &userapi.QueryOutdatedPolicyUsersRequest{ + res := &userapi.QueryOutdatedPolicyResponse{} + if err := userAPI.QueryOutdatedPolicy(context.Background(), &userapi.QueryOutdatedPolicyRequest{ PolicyVersion: cfgClient.Matrix.UserConsentOptions.Version, }, res); err != nil { logrus.WithError(err).Error("unable to fetch users with outdated consent policy") diff --git a/clientapi/routing/register_test.go b/clientapi/routing/register_test.go index c6b7e61cf..5df58fc35 100644 --- a/clientapi/routing/register_test.go +++ b/clientapi/routing/register_test.go @@ -219,7 +219,7 @@ func TestSessionCleanUp(t *testing.T) { // manually added, as s.addParams() would start the timer with the default timeout s.params[dummySession] = registerRequest{Username: "Testing"} s.startTimer(time.Millisecond, dummySession) - time.Sleep(time.Millisecond * 2) + time.Sleep(time.Millisecond * 5) if data, ok := s.getParams(dummySession); ok { t.Errorf("expected session to be deleted: %+v", data) } @@ -245,7 +245,7 @@ func TestSessionCleanUp(t *testing.T) { s.getCompletedStages(dummySession) // reset the timer with a lower timeout s.startTimer(time.Millisecond, dummySession) - time.Sleep(time.Millisecond * 2) + time.Sleep(time.Millisecond * 5) if data, ok := s.getParams(dummySession); ok { t.Errorf("expected session to be deleted: %+v", data) } diff --git a/userapi/api/api.go b/userapi/api/api.go index a40275307..6d8927043 100644 --- a/userapi/api/api.go +++ b/userapi/api/api.go @@ -46,7 +46,7 @@ type UserInternalAPI interface { QuerySearchProfiles(ctx context.Context, req *QuerySearchProfilesRequest, res *QuerySearchProfilesResponse) error QueryOpenIDToken(ctx context.Context, req *QueryOpenIDTokenRequest, res *QueryOpenIDTokenResponse) error QueryPolicyVersion(ctx context.Context, req *QueryPolicyVersionRequest, res *QueryPolicyVersionResponse) error - GetOutdatedPolicy(ctx context.Context, req *QueryOutdatedPolicyUsersRequest, res *QueryOutdatedPolicyUsersResponse) error + QueryOutdatedPolicy(ctx context.Context, req *QueryOutdatedPolicyRequest, res *QueryOutdatedPolicyResponse) error PerformUpdatePolicyVersion(ctx context.Context, req *UpdatePolicyVersionRequest, res *UpdatePolicyVersionResponse) error } @@ -349,13 +349,13 @@ type QueryPolicyVersionResponse struct { PolicyVersion string } -// QueryOutdatedPolicyUsersRequest is the request for QueryOutdatedPolicyUsersRequest -type QueryOutdatedPolicyUsersRequest struct { +// QueryOutdatedPolicyRequest is the request for QueryOutdatedPolicyRequest +type QueryOutdatedPolicyRequest struct { PolicyVersion string } -// QueryOutdatedPolicyUsersResponse is the response for QueryOutdatedPolicyUsersRequest -type QueryOutdatedPolicyUsersResponse struct { +// QueryOutdatedPolicyResponse is the response for QueryOutdatedPolicyRequest +type QueryOutdatedPolicyResponse struct { OutdatedUsers []string } diff --git a/userapi/api/api_trace.go b/userapi/api/api_trace.go index 3428e0fd3..9d142d34b 100644 --- a/userapi/api/api_trace.go +++ b/userapi/api/api_trace.go @@ -125,9 +125,9 @@ func (t *UserInternalAPITrace) QueryPolicyVersion(ctx context.Context, req *Quer return err } -func (t *UserInternalAPITrace) GetOutdatedPolicy(ctx context.Context, req *QueryOutdatedPolicyUsersRequest, res *QueryOutdatedPolicyUsersResponse) error { - err := t.Impl.GetOutdatedPolicy(ctx, req, res) - util.GetLogger(ctx).Infof("GetOutdatedPolicy req=%+v res=%+v", js(req), js(res)) +func (t *UserInternalAPITrace) QueryOutdatedPolicy(ctx context.Context, req *QueryOutdatedPolicyRequest, res *QueryOutdatedPolicyResponse) error { + err := t.Impl.QueryOutdatedPolicy(ctx, req, res) + util.GetLogger(ctx).Infof("QueryOutdatedPolicy req=%+v res=%+v", js(req), js(res)) return err } diff --git a/userapi/internal/api.go b/userapi/internal/api.go index 862dd0c2c..8ef6a0900 100644 --- a/userapi/internal/api.go +++ b/userapi/internal/api.go @@ -610,10 +610,10 @@ func (a *UserInternalAPI) QueryPolicyVersion( return nil } -func (a *UserInternalAPI) GetOutdatedPolicy( +func (a *UserInternalAPI) QueryOutdatedPolicy( ctx context.Context, - req *api.QueryOutdatedPolicyUsersRequest, - res *api.QueryOutdatedPolicyUsersResponse, + req *api.QueryOutdatedPolicyRequest, + res *api.QueryOutdatedPolicyResponse, ) error { var err error res.OutdatedUsers, err = a.DB.GetOutdatedPolicy(ctx, req.PolicyVersion) diff --git a/userapi/inthttp/client.go b/userapi/inthttp/client.go index 9067d993e..b5176aa3e 100644 --- a/userapi/inthttp/client.go +++ b/userapi/inthttp/client.go @@ -254,15 +254,15 @@ func (h *httpUserInternalAPI) QueryKeyBackup(ctx context.Context, req *api.Query } func (h *httpUserInternalAPI) QueryPolicyVersion(ctx context.Context, req *api.QueryPolicyVersionRequest, res *api.QueryPolicyVersionResponse) error { - span, ctx := opentracing.StartSpanFromContext(ctx, "QueryKeyBackup") + span, ctx := opentracing.StartSpanFromContext(ctx, "QueryPolicyVersion") defer span.Finish() apiURL := h.apiURL + QueryPolicyVersionPath return httputil.PostJSON(ctx, span, h.httpClient, apiURL, req, res) } -func (h *httpUserInternalAPI) GetOutdatedPolicy(ctx context.Context, req *api.QueryOutdatedPolicyUsersRequest, res *api.QueryOutdatedPolicyUsersResponse) error { - span, ctx := opentracing.StartSpanFromContext(ctx, "QueryKeyBackup") +func (h *httpUserInternalAPI) QueryOutdatedPolicy(ctx context.Context, req *api.QueryOutdatedPolicyRequest, res *api.QueryOutdatedPolicyResponse) error { + span, ctx := opentracing.StartSpanFromContext(ctx, "QueryOutdatedPolicy") defer span.Finish() apiURL := h.apiURL + QueryOutdatedPolicyUsersPath @@ -270,7 +270,7 @@ func (h *httpUserInternalAPI) GetOutdatedPolicy(ctx context.Context, req *api.Qu } func (h *httpUserInternalAPI) PerformUpdatePolicyVersion(ctx context.Context, req *api.UpdatePolicyVersionRequest, res *api.UpdatePolicyVersionResponse) error { - span, ctx := opentracing.StartSpanFromContext(ctx, "QueryKeyBackup") + span, ctx := opentracing.StartSpanFromContext(ctx, "PerformUpdatePolicyVersion") defer span.Finish() apiURL := h.apiURL + PerformUpdatePolicyVersionPath diff --git a/userapi/inthttp/server.go b/userapi/inthttp/server.go index 70e8d17ce..8dc0dee55 100644 --- a/userapi/inthttp/server.go +++ b/userapi/inthttp/server.go @@ -281,12 +281,12 @@ func AddRoutes(internalAPIMux *mux.Router, s api.UserInternalAPI) { ) internalAPIMux.Handle(QueryOutdatedPolicyUsersPath, httputil.MakeInternalAPI("queryOutdatedPolicyUsers", func(req *http.Request) util.JSONResponse { - request := api.QueryOutdatedPolicyUsersRequest{} - response := api.QueryOutdatedPolicyUsersResponse{} + request := api.QueryOutdatedPolicyRequest{} + response := api.QueryOutdatedPolicyResponse{} if err := json.NewDecoder(req.Body).Decode(&request); err != nil { return util.MessageResponse(http.StatusBadRequest, err.Error()) } - err := s.GetOutdatedPolicy(req.Context(), &request, &response) + err := s.QueryOutdatedPolicy(req.Context(), &request, &response) if err != nil { return util.JSONResponse{Code: http.StatusBadRequest, JSON: &response} }