From f1ef32f0a529fab00f08aed183e358b3c691d6fe Mon Sep 17 00:00:00 2001 From: Sean Hagstrom Date: Wed, 8 Jan 2025 11:29:40 -0800 Subject: [PATCH] fix_: use identityImage clock field when making contact image url --- protocol/messenger_contacts.go | 2 +- server/server_media.go | 4 ++-- server/server_test.go | 9 +++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/protocol/messenger_contacts.go b/protocol/messenger_contacts.go index 835670f4573..1fc7bb79412 100644 --- a/protocol/messenger_contacts.go +++ b/protocol/messenger_contacts.go @@ -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 } } diff --git a/server/server_media.go b/server/server_media.go index bbd3d0229e9..b80e5bdb09c 100644 --- a/server/server_media.go +++ b/server/server_media.go @@ -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() } diff --git a/server/server_test.go b/server/server_test.go index 7a0074a5dd1..e8d2433613c 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -145,6 +145,15 @@ func (s *ServerURLSuite) TestServer_MakeStickerURL() { s.serverNoPort.MakeStickerURL("0xdeadbeef4ac0")) } +func (s *ServerURLSuite) TestServer_MakeContactImageURL() { + s.Require().Equal( + baseURLWithCustomPort+"/contactImages?clock=1&imageName=Test&publicKey=0x1", + s.server.MakeContactImageURL("0x1", "Test", uint64(1))) + s.testNoPort( + baseURLWithDefaultPort+"/contactImages?clock=1&imageName=Test&publicKey=0x1", + 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.