mirror of
https://github.com/1f349/dendrite.git
synced 2024-11-12 14:51:40 +00:00
fix probable bugs, package names and keywords used as identifiers (#428)
Signed-off-by: MohitKS5 <mohitkumarsingh907@gmail.com>
This commit is contained in:
parent
58c10c6d54
commit
aff401ed06
@ -177,8 +177,8 @@ func queryIDServer(
|
|||||||
// Returns an error if the request failed to send or if the response couldn't be parsed.
|
// 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) {
|
func queryIDServerLookup(ctx context.Context, body *MembershipRequest) (*idServerLookupResponse, error) {
|
||||||
address := url.QueryEscape(body.Address)
|
address := url.QueryEscape(body.Address)
|
||||||
url := fmt.Sprintf("https://%s/_matrix/identity/api/v1/lookup?medium=%s&address=%s", body.IDServer, body.Medium, address)
|
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, url, nil)
|
req, err := http.NewRequest(http.MethodGet, requestURL, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -237,8 +237,8 @@ func queryIDServerStoreInvite(
|
|||||||
// These can be easily retrieved by requesting the public rooms API
|
// These can be easily retrieved by requesting the public rooms API
|
||||||
// server's database.
|
// server's database.
|
||||||
|
|
||||||
url := fmt.Sprintf("https://%s/_matrix/identity/api/v1/store-invite", body.IDServer)
|
requestURL := fmt.Sprintf("https://%s/_matrix/identity/api/v1/store-invite", body.IDServer)
|
||||||
req, err := http.NewRequest(http.MethodPost, url, strings.NewReader(data.Encode()))
|
req, err := http.NewRequest(http.MethodPost, requestURL, strings.NewReader(data.Encode()))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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
|
// 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.
|
// or if the key couldn't be decoded from base64.
|
||||||
func queryIDServerPubKey(ctx context.Context, idServerName string, keyID string) ([]byte, error) {
|
func queryIDServerPubKey(ctx context.Context, idServerName string, keyID string) ([]byte, error) {
|
||||||
url := fmt.Sprintf("https://%s/_matrix/identity/api/v1/pubkey/%s", idServerName, keyID)
|
requestURL := fmt.Sprintf("https://%s/_matrix/identity/api/v1/pubkey/%s", idServerName, keyID)
|
||||||
req, err := http.NewRequest(http.MethodGet, url, nil)
|
req, err := http.NewRequest(http.MethodGet, requestURL, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -107,8 +107,8 @@ func CheckAssociation(
|
|||||||
return false, "", "", err
|
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)
|
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, url, nil)
|
req, err := http.NewRequest(http.MethodGet, requestURL, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, "", "", err
|
return false, "", "", err
|
||||||
}
|
}
|
||||||
|
@ -51,10 +51,10 @@ func GenerateThumbnails(
|
|||||||
logger.WithError(err).WithField("src", src).Error("Failed to read src file")
|
logger.WithError(err).WithField("src", src).Error("Failed to read src file")
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
for _, config := range configs {
|
for _, singleConfig := range configs {
|
||||||
// Note: createThumbnail does locking based on activeThumbnailGeneration
|
// Note: createThumbnail does locking based on activeThumbnailGeneration
|
||||||
busy, err = createThumbnail(
|
busy, err = createThumbnail(
|
||||||
ctx, src, img, types.ThumbnailSize(config), mediaMetadata,
|
ctx, src, img, types.ThumbnailSize(singleConfig), mediaMetadata,
|
||||||
activeThumbnailGeneration, maxThumbnailGenerators, db, logger,
|
activeThumbnailGeneration, maxThumbnailGenerators, db, logger,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -91,22 +91,22 @@ func updateMembership(
|
|||||||
) ([]api.OutputEvent, error) {
|
) ([]api.OutputEvent, error) {
|
||||||
var err error
|
var err error
|
||||||
// Default the membership to Leave if no event was added or removed.
|
// Default the membership to Leave if no event was added or removed.
|
||||||
old := leave
|
oldMembership := leave
|
||||||
new := leave
|
newMembership := leave
|
||||||
|
|
||||||
if remove != nil {
|
if remove != nil {
|
||||||
old, err = remove.Membership()
|
oldMembership, err = remove.Membership()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if add != nil {
|
if add != nil {
|
||||||
new, err = add.Membership()
|
newMembership, err = add.Membership()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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
|
// If the membership is the same then nothing changed and we can return
|
||||||
// immediately, unless it's a Join update (e.g. profile update).
|
// immediately, unless it's a Join update (e.g. profile update).
|
||||||
return updates, nil
|
return updates, nil
|
||||||
@ -117,16 +117,16 @@ func updateMembership(
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
switch new {
|
switch newMembership {
|
||||||
case invite:
|
case invite:
|
||||||
return updateToInviteMembership(mu, add, updates)
|
return updateToInviteMembership(mu, add, updates)
|
||||||
case join:
|
case join:
|
||||||
return updateToJoinMembership(mu, add, updates)
|
return updateToJoinMembership(mu, add, updates)
|
||||||
case leave, ban:
|
case leave, ban:
|
||||||
return updateToLeaveMembership(mu, add, new, updates)
|
return updateToLeaveMembership(mu, add, newMembership, updates)
|
||||||
default:
|
default:
|
||||||
panic(fmt.Errorf(
|
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,
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user