Rename some functions

This commit is contained in:
Till Faelligen 2022-02-25 15:32:19 +01:00
parent ed16a2f107
commit 2ad15f308f
7 changed files with 22 additions and 22 deletions

View file

@ -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")

View file

@ -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)
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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)

View file

@ -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

View file

@ -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}
}