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, accountsDB userdb.Database,
asAPI appserviceAPI.AppServiceQueryAPI, asAPI appserviceAPI.AppServiceQueryAPI,
) { ) {
res := &userapi.QueryOutdatedPolicyUsersResponse{} res := &userapi.QueryOutdatedPolicyResponse{}
if err := userAPI.GetOutdatedPolicy(context.Background(), &userapi.QueryOutdatedPolicyUsersRequest{ if err := userAPI.QueryOutdatedPolicy(context.Background(), &userapi.QueryOutdatedPolicyRequest{
PolicyVersion: cfgClient.Matrix.UserConsentOptions.Version, PolicyVersion: cfgClient.Matrix.UserConsentOptions.Version,
}, res); err != nil { }, res); err != nil {
logrus.WithError(err).Error("unable to fetch users with outdated consent policy") 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 // manually added, as s.addParams() would start the timer with the default timeout
s.params[dummySession] = registerRequest{Username: "Testing"} s.params[dummySession] = registerRequest{Username: "Testing"}
s.startTimer(time.Millisecond, dummySession) s.startTimer(time.Millisecond, dummySession)
time.Sleep(time.Millisecond * 2) time.Sleep(time.Millisecond * 5)
if data, ok := s.getParams(dummySession); ok { if data, ok := s.getParams(dummySession); ok {
t.Errorf("expected session to be deleted: %+v", data) t.Errorf("expected session to be deleted: %+v", data)
} }
@ -245,7 +245,7 @@ func TestSessionCleanUp(t *testing.T) {
s.getCompletedStages(dummySession) s.getCompletedStages(dummySession)
// reset the timer with a lower timeout // reset the timer with a lower timeout
s.startTimer(time.Millisecond, dummySession) s.startTimer(time.Millisecond, dummySession)
time.Sleep(time.Millisecond * 2) time.Sleep(time.Millisecond * 5)
if data, ok := s.getParams(dummySession); ok { if data, ok := s.getParams(dummySession); ok {
t.Errorf("expected session to be deleted: %+v", data) 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 QuerySearchProfiles(ctx context.Context, req *QuerySearchProfilesRequest, res *QuerySearchProfilesResponse) error
QueryOpenIDToken(ctx context.Context, req *QueryOpenIDTokenRequest, res *QueryOpenIDTokenResponse) error QueryOpenIDToken(ctx context.Context, req *QueryOpenIDTokenRequest, res *QueryOpenIDTokenResponse) error
QueryPolicyVersion(ctx context.Context, req *QueryPolicyVersionRequest, res *QueryPolicyVersionResponse) 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 PerformUpdatePolicyVersion(ctx context.Context, req *UpdatePolicyVersionRequest, res *UpdatePolicyVersionResponse) error
} }
@ -349,13 +349,13 @@ type QueryPolicyVersionResponse struct {
PolicyVersion string PolicyVersion string
} }
// QueryOutdatedPolicyUsersRequest is the request for QueryOutdatedPolicyUsersRequest // QueryOutdatedPolicyRequest is the request for QueryOutdatedPolicyRequest
type QueryOutdatedPolicyUsersRequest struct { type QueryOutdatedPolicyRequest struct {
PolicyVersion string PolicyVersion string
} }
// QueryOutdatedPolicyUsersResponse is the response for QueryOutdatedPolicyUsersRequest // QueryOutdatedPolicyResponse is the response for QueryOutdatedPolicyRequest
type QueryOutdatedPolicyUsersResponse struct { type QueryOutdatedPolicyResponse struct {
OutdatedUsers []string OutdatedUsers []string
} }

View file

@ -125,9 +125,9 @@ func (t *UserInternalAPITrace) QueryPolicyVersion(ctx context.Context, req *Quer
return err return err
} }
func (t *UserInternalAPITrace) GetOutdatedPolicy(ctx context.Context, req *QueryOutdatedPolicyUsersRequest, res *QueryOutdatedPolicyUsersResponse) error { func (t *UserInternalAPITrace) QueryOutdatedPolicy(ctx context.Context, req *QueryOutdatedPolicyRequest, res *QueryOutdatedPolicyResponse) error {
err := t.Impl.GetOutdatedPolicy(ctx, req, res) err := t.Impl.QueryOutdatedPolicy(ctx, req, res)
util.GetLogger(ctx).Infof("GetOutdatedPolicy req=%+v res=%+v", js(req), js(res)) util.GetLogger(ctx).Infof("QueryOutdatedPolicy req=%+v res=%+v", js(req), js(res))
return err return err
} }

View file

@ -610,10 +610,10 @@ func (a *UserInternalAPI) QueryPolicyVersion(
return nil return nil
} }
func (a *UserInternalAPI) GetOutdatedPolicy( func (a *UserInternalAPI) QueryOutdatedPolicy(
ctx context.Context, ctx context.Context,
req *api.QueryOutdatedPolicyUsersRequest, req *api.QueryOutdatedPolicyRequest,
res *api.QueryOutdatedPolicyUsersResponse, res *api.QueryOutdatedPolicyResponse,
) error { ) error {
var err error var err error
res.OutdatedUsers, err = a.DB.GetOutdatedPolicy(ctx, req.PolicyVersion) 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 { 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() defer span.Finish()
apiURL := h.apiURL + QueryPolicyVersionPath apiURL := h.apiURL + QueryPolicyVersionPath
return httputil.PostJSON(ctx, span, h.httpClient, apiURL, req, res) return httputil.PostJSON(ctx, span, h.httpClient, apiURL, req, res)
} }
func (h *httpUserInternalAPI) GetOutdatedPolicy(ctx context.Context, req *api.QueryOutdatedPolicyUsersRequest, res *api.QueryOutdatedPolicyUsersResponse) error { func (h *httpUserInternalAPI) QueryOutdatedPolicy(ctx context.Context, req *api.QueryOutdatedPolicyRequest, res *api.QueryOutdatedPolicyResponse) error {
span, ctx := opentracing.StartSpanFromContext(ctx, "QueryKeyBackup") span, ctx := opentracing.StartSpanFromContext(ctx, "QueryOutdatedPolicy")
defer span.Finish() defer span.Finish()
apiURL := h.apiURL + QueryOutdatedPolicyUsersPath 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 { 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() defer span.Finish()
apiURL := h.apiURL + PerformUpdatePolicyVersionPath apiURL := h.apiURL + PerformUpdatePolicyVersionPath

View file

@ -281,12 +281,12 @@ func AddRoutes(internalAPIMux *mux.Router, s api.UserInternalAPI) {
) )
internalAPIMux.Handle(QueryOutdatedPolicyUsersPath, internalAPIMux.Handle(QueryOutdatedPolicyUsersPath,
httputil.MakeInternalAPI("queryOutdatedPolicyUsers", func(req *http.Request) util.JSONResponse { httputil.MakeInternalAPI("queryOutdatedPolicyUsers", func(req *http.Request) util.JSONResponse {
request := api.QueryOutdatedPolicyUsersRequest{} request := api.QueryOutdatedPolicyRequest{}
response := api.QueryOutdatedPolicyUsersResponse{} response := api.QueryOutdatedPolicyResponse{}
if err := json.NewDecoder(req.Body).Decode(&request); err != nil { if err := json.NewDecoder(req.Body).Decode(&request); err != nil {
return util.MessageResponse(http.StatusBadRequest, err.Error()) return util.MessageResponse(http.StatusBadRequest, err.Error())
} }
err := s.GetOutdatedPolicy(req.Context(), &request, &response) err := s.QueryOutdatedPolicy(req.Context(), &request, &response)
if err != nil { if err != nil {
return util.JSONResponse{Code: http.StatusBadRequest, JSON: &response} return util.JSONResponse{Code: http.StatusBadRequest, JSON: &response}
} }