From aff401ed0681a6b018d0b3ba944da04fe38343a0 Mon Sep 17 00:00:00 2001 From: mohit kumar singh Date: Fri, 20 Apr 2018 20:20:44 +0530 Subject: [PATCH] fix probable bugs, package names and keywords used as identifiers (#428) Signed-off-by: MohitKS5 --- .../dendrite/clientapi/threepid/invites.go | 12 ++++++------ .../dendrite/clientapi/threepid/threepid.go | 4 ++-- .../mediaapi/thumbnailer/thumbnailer_nfnt.go | 4 ++-- .../dendrite/roomserver/input/membership.go | 16 ++++++++-------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/github.com/matrix-org/dendrite/clientapi/threepid/invites.go b/src/github.com/matrix-org/dendrite/clientapi/threepid/invites.go index fba8c928..a7fdea69 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/threepid/invites.go +++ b/src/github.com/matrix-org/dendrite/clientapi/threepid/invites.go @@ -177,8 +177,8 @@ func queryIDServer( // Returns an error if the request failed to send or if the response couldn't be parsed. func queryIDServerLookup(ctx context.Context, body *MembershipRequest) (*idServerLookupResponse, error) { address := url.QueryEscape(body.Address) - url := fmt.Sprintf("https://%s/_matrix/identity/api/v1/lookup?medium=%s&address=%s", body.IDServer, body.Medium, address) - req, err := http.NewRequest(http.MethodGet, url, nil) + requestURL := fmt.Sprintf("https://%s/_matrix/identity/api/v1/lookup?medium=%s&address=%s", body.IDServer, body.Medium, address) + req, err := http.NewRequest(http.MethodGet, requestURL, nil) if err != nil { return nil, err } @@ -237,8 +237,8 @@ func queryIDServerStoreInvite( // These can be easily retrieved by requesting the public rooms API // server's database. - url := fmt.Sprintf("https://%s/_matrix/identity/api/v1/store-invite", body.IDServer) - req, err := http.NewRequest(http.MethodPost, url, strings.NewReader(data.Encode())) + requestURL := fmt.Sprintf("https://%s/_matrix/identity/api/v1/store-invite", body.IDServer) + req, err := http.NewRequest(http.MethodPost, requestURL, strings.NewReader(data.Encode())) if err != nil { return nil, err } @@ -265,8 +265,8 @@ func queryIDServerStoreInvite( // Returns an error if the request couldn't be sent, if its body couldn't be parsed // or if the key couldn't be decoded from base64. func queryIDServerPubKey(ctx context.Context, idServerName string, keyID string) ([]byte, error) { - url := fmt.Sprintf("https://%s/_matrix/identity/api/v1/pubkey/%s", idServerName, keyID) - req, err := http.NewRequest(http.MethodGet, url, nil) + requestURL := fmt.Sprintf("https://%s/_matrix/identity/api/v1/pubkey/%s", idServerName, keyID) + req, err := http.NewRequest(http.MethodGet, requestURL, nil) if err != nil { return nil, err } diff --git a/src/github.com/matrix-org/dendrite/clientapi/threepid/threepid.go b/src/github.com/matrix-org/dendrite/clientapi/threepid/threepid.go index db1c45d0..e5b3305e 100644 --- a/src/github.com/matrix-org/dendrite/clientapi/threepid/threepid.go +++ b/src/github.com/matrix-org/dendrite/clientapi/threepid/threepid.go @@ -107,8 +107,8 @@ func CheckAssociation( return false, "", "", err } - url := fmt.Sprintf("https://%s/_matrix/identity/api/v1/3pid/getValidated3pid?sid=%s&client_secret=%s", creds.IDServer, creds.SID, creds.Secret) - req, err := http.NewRequest(http.MethodGet, url, nil) + requestURL := fmt.Sprintf("https://%s/_matrix/identity/api/v1/3pid/getValidated3pid?sid=%s&client_secret=%s", creds.IDServer, creds.SID, creds.Secret) + req, err := http.NewRequest(http.MethodGet, requestURL, nil) if err != nil { return false, "", "", err } diff --git a/src/github.com/matrix-org/dendrite/mediaapi/thumbnailer/thumbnailer_nfnt.go b/src/github.com/matrix-org/dendrite/mediaapi/thumbnailer/thumbnailer_nfnt.go index e9276731..43bf8efb 100644 --- a/src/github.com/matrix-org/dendrite/mediaapi/thumbnailer/thumbnailer_nfnt.go +++ b/src/github.com/matrix-org/dendrite/mediaapi/thumbnailer/thumbnailer_nfnt.go @@ -51,10 +51,10 @@ func GenerateThumbnails( logger.WithError(err).WithField("src", src).Error("Failed to read src file") return false, err } - for _, config := range configs { + for _, singleConfig := range configs { // Note: createThumbnail does locking based on activeThumbnailGeneration busy, err = createThumbnail( - ctx, src, img, types.ThumbnailSize(config), mediaMetadata, + ctx, src, img, types.ThumbnailSize(singleConfig), mediaMetadata, activeThumbnailGeneration, maxThumbnailGenerators, db, logger, ) if err != nil { diff --git a/src/github.com/matrix-org/dendrite/roomserver/input/membership.go b/src/github.com/matrix-org/dendrite/roomserver/input/membership.go index 4c42cadd..1b4fac5e 100644 --- a/src/github.com/matrix-org/dendrite/roomserver/input/membership.go +++ b/src/github.com/matrix-org/dendrite/roomserver/input/membership.go @@ -91,22 +91,22 @@ func updateMembership( ) ([]api.OutputEvent, error) { var err error // Default the membership to Leave if no event was added or removed. - old := leave - new := leave + oldMembership := leave + newMembership := leave if remove != nil { - old, err = remove.Membership() + oldMembership, err = remove.Membership() if err != nil { return nil, err } } if add != nil { - new, err = add.Membership() + newMembership, err = add.Membership() if err != nil { return nil, err } } - if old == new && new != join { + if oldMembership == newMembership && newMembership != join { // If the membership is the same then nothing changed and we can return // immediately, unless it's a Join update (e.g. profile update). return updates, nil @@ -117,16 +117,16 @@ func updateMembership( return nil, err } - switch new { + switch newMembership { case invite: return updateToInviteMembership(mu, add, updates) case join: return updateToJoinMembership(mu, add, updates) case leave, ban: - return updateToLeaveMembership(mu, add, new, updates) + return updateToLeaveMembership(mu, add, newMembership, updates) default: panic(fmt.Errorf( - "input: membership %q is not one of the allowed values", new, + "input: membership %q is not one of the allowed values", newMembership, )) } }