Skip to content

Commit

Permalink
Merge pull request #184 from ssb-ngi-pointer/fix-183
Browse files Browse the repository at this point in the history
rename address field in alias JSON resolver
  • Loading branch information
cryptix authored Apr 22, 2021
2 parents e355036 + 34eef5f commit 5dba245
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 12 additions & 12 deletions web/handlers/aliases.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ type aliasResponder interface {

// aliasJSONResponse dictates the field names and format of the JSON response for the alias web endpoint
type aliasJSONResponse struct {
Status string `json:"status"`
Address string `json:"address"`
RoomID string `json:"roomId"`
UserID string `json:"userId"`
Alias string `json:"alias"`
Signature string `json:"signature"`
Status string `json:"status"`
MultiserverAddress string `json:"multiserverAddress"`
RoomID string `json:"roomId"`
UserID string `json:"userId"`
Alias string `json:"alias"`
Signature string `json:"signature"`
}

// handles JSON responses
Expand All @@ -104,12 +104,12 @@ func (json *aliasJSONResponder) UpdateRoomInfo(netInfo network.ServerEndpointDet

func (json aliasJSONResponder) SendConfirmation(alias roomdb.Alias) {
var resp = aliasJSONResponse{
Status: "successful",
RoomID: json.netInfo.RoomID.Ref(),
Address: json.netInfo.MultiserverAddress(),
Alias: alias.Name,
UserID: alias.Feed.Ref(),
Signature: base64.StdEncoding.EncodeToString(alias.Signature),
Status: "successful",
RoomID: json.netInfo.RoomID.Ref(),
MultiserverAddress: json.netInfo.MultiserverAddress(),
Alias: alias.Name,
UserID: alias.Feed.Ref(),
Signature: base64.StdEncoding.EncodeToString(alias.Signature),
}
json.enc.Encode(resp)
}
Expand Down
2 changes: 2 additions & 0 deletions web/handlers/aliases_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ func TestAliasResolve(t *testing.T) {
r.NoError(err)
a.Equal(testAlias.Signature, sigData)
a.Equal(ts.NetworkInfo.RoomID.Ref(), params.Get("roomId"))
a.Equal(ts.NetworkInfo.MultiserverAddress(), params.Get("multiserverAddress"))

// now as JSON
jsonURL, err := routes.Get(router.CompleteAliasResolve).URL("alias", testAlias.Name)
Expand All @@ -86,4 +87,5 @@ func TestAliasResolve(t *testing.T) {
a.Equal(testAlias.Signature, sigData2)
a.Equal(testAlias.Feed.Ref(), ar.UserID, "wrong user feed on response")
a.Equal(ts.NetworkInfo.RoomID.Ref(), ar.RoomID, "wrong room feed on response")
a.Equal(ts.NetworkInfo.MultiserverAddress(), ar.MultiserverAddress)
}

0 comments on commit 5dba245

Please sign in to comment.