diff --git a/VERSION b/VERSION index 3a35ae4db..e6595e765 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.80.4 +0.80.5 diff --git a/protocol/messenger_handler.go b/protocol/messenger_handler.go index 1f7c9e74b..daadda689 100644 --- a/protocol/messenger_handler.go +++ b/protocol/messenger_handler.go @@ -581,8 +581,13 @@ func (m *Messenger) HandleChatMessage(state *ReceivedMessageState) error { // It looks like status-react created profile chats as public chats // so for now we need to check for the presence of "@" in their chatID - if chat.Public() && receivedMessage.ContentType == protobuf.ChatMessage_IMAGE && !chat.ProfileUpdates() { - return errors.New("images are not allowed in public chats") + if chat.Public() && !chat.ProfileUpdates() { + switch receivedMessage.ContentType { + case protobuf.ChatMessage_IMAGE: + return errors.New("images are not allowed in public chats") + case protobuf.ChatMessage_AUDIO: + return errors.New("audio messages are not allowed in public chats") + } } // If profile updates check if author is the same as chat profile public key diff --git a/protocol/messenger_test.go b/protocol/messenger_test.go index 7d01f3185..f20f58228 100644 --- a/protocol/messenger_test.go +++ b/protocol/messenger_test.go @@ -308,6 +308,27 @@ func (s *MessengerSuite) TestInit() { } } +func buildAudioMessage(s *MessengerSuite, chat Chat) *common.Message { + clock, timestamp := chat.NextClockAndTimestamp(&testTimeSource{}) + message := &common.Message{} + message.Text = "text-input-message" + message.ChatId = chat.ID + message.Clock = clock + message.Timestamp = timestamp + message.WhisperTimestamp = clock + message.LocalChatID = chat.ID + message.MessageType = protobuf.MessageType_PUBLIC_GROUP + message.ContentType = protobuf.ChatMessage_AUDIO + message.Payload = &protobuf.ChatMessage_Audio{ + Audio: &protobuf.AudioMessage{ + Type: 1, + Payload: []byte("some-payload"), + }, + } + + return message +} + func buildTestMessage(chat Chat) *common.Message { clock, timestamp := chat.NextClockAndTimestamp(&testTimeSource{}) message := &common.Message{} @@ -614,6 +635,34 @@ func (s *MessengerSuite) TestRetrieveTheirPublic() { s.Require().NoError(theirMessenger.Shutdown()) } +// Drop audio message in public group +func (s *MessengerSuite) TestDropAudioMessageInPublicGroup() { + theirMessenger := s.newMessenger(s.shh) + _, err := theirMessenger.Start() + s.Require().NoError(err) + theirChat := CreatePublicChat("status", s.m.transport) + err = theirMessenger.SaveChat(theirChat) + s.Require().NoError(err) + + chat := CreatePublicChat("status", s.m.transport) + err = s.m.SaveChat(chat) + s.Require().NoError(err) + + _, err = s.m.Join(chat) + s.Require().NoError(err) + + inputMessage := buildAudioMessage(s, *chat) + + _, err = theirMessenger.SendChatMessage(context.Background(), inputMessage) + s.NoError(err) + + time.Sleep(100 * time.Millisecond) + response, err := s.m.RetrieveAll() + s.Require().NoError(err) + s.Require().Len(response.Messages(), 0) + s.Require().NoError(theirMessenger.Shutdown()) +} + func (s *MessengerSuite) TestDeletedAtClockValue() { theirMessenger := s.newMessenger(s.shh) _, err := theirMessenger.Start()