Skip to content

Commit

Permalink
feature_: use identityImage clock field when making contact image url
Browse files Browse the repository at this point in the history
  • Loading branch information
seanstrom committed Jan 8, 2025
1 parent 0738734 commit f89776c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion protocol/messenger_contacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ func (m *Messenger) updateContactImagesURL(contact *Contact) error {
if err != nil {
return err
}
v.LocalURL = m.httpServer.MakeContactImageURL(common.PubkeyToHex(publicKey), k)
v.LocalURL = m.httpServer.MakeContactImageURL(common.PubkeyToHex(publicKey), k, v.Clock)
contact.Images[k] = v
}
}
Expand Down
4 changes: 2 additions & 2 deletions server/server_media.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@ func (s *MediaServer) MakeQRURL(qurul string,
return u.String()
}

func (s *MediaServer) MakeContactImageURL(publicKey string, imageType string) string {
func (s *MediaServer) MakeContactImageURL(publicKey string, imageType string, imageClock uint64) string {
u := s.MakeBaseURL()
u.Path = contactImagesPath
u.RawQuery = url.Values{"publicKey": {publicKey}, "imageName": {imageType}}.Encode()
u.RawQuery = url.Values{"publicKey": {publicKey}, "imageName": {imageType}, "clock": {fmt.Sprint(imageClock)}}.Encode()

return u.String()
}
Expand Down
9 changes: 9 additions & 0 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ func (s *ServerURLSuite) TestServer_MakeStickerURL() {
s.serverNoPort.MakeStickerURL("0xdeadbeef4ac0"))
}

func (s *ServerURLSuite) TestServer_MakeContactImageURL() {
s.Require().Equal(
baseURLWithCustomPort+"/contactImages?publicKey=0x1&imageName=Test&clock=1",
s.server.MakeContactImageURL("0x1", "Test", uint64(1)))
s.testNoPort(
baseURLWithDefaultPort+"/contactImages?publictKey=0x1&imageName=Test&clock=1",
s.serverNoPort.MakeContactImageURL("0x1", "Test", uint64(1)))
}

// TestQRCodeGeneration tests if we provide all the correct parameters to the media server
// do we get a valid QR code or not as part of the response payload.
// we have stored a generated QR code in tests folder, and we compare their bytes.
Expand Down

0 comments on commit f89776c

Please sign in to comment.