Return compressed key with emojis (#3410)

This commit is contained in:
Ibrahem Khalil 2023-05-10 13:45:42 +03:00 committed by GitHub
parent 40e57f1127
commit ff75280b30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 2 deletions

View File

@ -1 +1 @@
0.151.0
0.151.1

View File

@ -7,6 +7,7 @@ import (
"github.com/golang/protobuf/proto"
accountJson "github.com/status-im/status-go/account/json"
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/protocol/protobuf"
@ -74,7 +75,12 @@ func (e EmojiReaction) MarshalJSON() ([]byte, error) {
EmojiID: e.Type,
}
return json.Marshal(item)
ext, err := accountJson.ExtendStructWithPubKeyData(item.From, item)
if err != nil {
return nil, err
}
return json.Marshal(ext)
}
// WrapGroupMessage indicates whether we should wrap this in membership information

View File

@ -3,6 +3,8 @@ package protocol
import (
"context"
"crypto/ecdsa"
"encoding/json"
"strings"
"testing"
"github.com/stretchr/testify/suite"
@ -12,6 +14,7 @@ import (
"github.com/status-im/status-go/eth-node/crypto"
"github.com/status-im/status-go/eth-node/types"
"github.com/status-im/status-go/multiaccounts"
"github.com/status-im/status-go/protocol/common"
"github.com/status-im/status-go/protocol/protobuf"
"github.com/status-im/status-go/protocol/tt"
"github.com/status-im/status-go/waku"
@ -203,4 +206,20 @@ func (s *MessengerEmojiSuite) TestEmojiPrivateGroup() {
)
s.Require().NoError(err)
s.Require().NoError(alice.Shutdown())
}
func (s *MessengerEmojiSuite) TestCompressedKeyReturnedWithEmoji() {
emojiReaction := &EmojiReaction{}
id, err := crypto.GenerateKey()
s.Require().NoError(err)
emojiReaction.From = common.PubkeyToHex(&id.PublicKey)
emojiReaction.LocalChatID = testPublicChatID
encodedReaction, err := json.Marshal(emojiReaction)
s.Require().NoError(err)
// Check that compressedKey and emojiHash exists
s.Require().True(strings.Contains(string(encodedReaction), "compressedKey\":\"zQ"))
s.Require().True(strings.Contains(string(encodedReaction), "emojiHash"))
}