Remove number from `ReportMessageManager#store`
This commit is contained in:
parent
5816f76bbe
commit
7b3703506b
|
@ -56,12 +56,8 @@ public class MessagesManager {
|
||||||
|
|
||||||
messagesCache.insert(messageGuid, destinationUuid, destinationDevice, message);
|
messagesCache.insert(messageGuid, destinationUuid, destinationDevice, message);
|
||||||
|
|
||||||
if (message.hasSource() && !destinationUuid.toString().equals(message.getSourceUuid())) {
|
if (message.hasSourceUuid() && !destinationUuid.toString().equals(message.getSourceUuid())) {
|
||||||
if (message.hasSourceUuid()) {
|
reportMessageManager.store(message.getSourceUuid(), messageGuid);
|
||||||
reportMessageManager.store(message.getSource(), message.getSourceUuid(), messageGuid);
|
|
||||||
} else {
|
|
||||||
logger.warn("Message missing source UUID");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,14 +45,11 @@ public class ReportMessageManager {
|
||||||
this.reportedMessageListeners.add(listener);
|
this.reportedMessageListeners.add(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO sourceNumber can be removed after 2022-04-01
|
public void store(String sourceAci, UUID messageGuid) {
|
||||||
public void store(String sourceNumber, String sourceAci, UUID messageGuid) {
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Objects.requireNonNull(sourceNumber);
|
|
||||||
Objects.requireNonNull(sourceAci);
|
Objects.requireNonNull(sourceAci);
|
||||||
|
|
||||||
reportMessageDynamoDb.store(hash(messageGuid, sourceNumber));
|
|
||||||
reportMessageDynamoDb.store(hash(messageGuid, sourceAci));
|
reportMessageDynamoDb.store(hash(messageGuid, sourceAci));
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
logger.warn("Failed to store hash", e);
|
logger.warn("Failed to store hash", e);
|
||||||
|
@ -93,7 +90,6 @@ public class ReportMessageManager {
|
||||||
sourceNumber.ifPresent(number ->
|
sourceNumber.ifPresent(number ->
|
||||||
reportedMessageListeners.forEach(listener -> {
|
reportedMessageListeners.forEach(listener -> {
|
||||||
try {
|
try {
|
||||||
// TODO should listener take the source Aci?
|
|
||||||
listener.handleMessageReported(number, messageGuid, reporterUuid);
|
listener.handleMessageReported(number, messageGuid, reporterUuid);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
logger.error("Failed to notify listener of reported message", e);
|
logger.error("Failed to notify listener of reported message", e);
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2021-2022 Signal Messenger, LLC
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
package org.whispersystems.textsecuregcm.storage;
|
package org.whispersystems.textsecuregcm.storage;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
@ -34,7 +39,7 @@ class MessagesManagerTest {
|
||||||
|
|
||||||
messagesManager.insert(destinationUuid, 1L, message);
|
messagesManager.insert(destinationUuid, 1L, message);
|
||||||
|
|
||||||
verify(reportMessageManager).store(eq(sourceNumber), eq(sourceAci.toString()), any(UUID.class));
|
verify(reportMessageManager).store(eq(sourceAci.toString()), any(UUID.class));
|
||||||
|
|
||||||
final Envelope syncMessage = Envelope.newBuilder(message)
|
final Envelope syncMessage = Envelope.newBuilder(message)
|
||||||
.setSourceUuid(destinationUuid.toString())
|
.setSourceUuid(destinationUuid.toString())
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2021-2022 Signal Messenger, LLC
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
|
||||||
package org.whispersystems.textsecuregcm.storage;
|
package org.whispersystems.textsecuregcm.storage;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
|
||||||
|
@ -6,7 +11,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.doThrow;
|
import static org.mockito.Mockito.doThrow;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.times;
|
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.verifyNoInteractions;
|
import static org.mockito.Mockito.verifyNoInteractions;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
@ -56,18 +60,18 @@ class ReportMessageManagerTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testStore() {
|
void testStore() {
|
||||||
assertDoesNotThrow(() -> reportMessageManager.store(null, null, messageGuid));
|
assertDoesNotThrow(() -> reportMessageManager.store(null, messageGuid));
|
||||||
|
|
||||||
verifyNoInteractions(reportMessageDynamoDb);
|
verifyNoInteractions(reportMessageDynamoDb);
|
||||||
|
|
||||||
reportMessageManager.store(sourceNumber, sourceAci.toString(), messageGuid);
|
reportMessageManager.store(sourceAci.toString(), messageGuid);
|
||||||
|
|
||||||
verify(reportMessageDynamoDb, times(2)).store(any());
|
verify(reportMessageDynamoDb).store(any());
|
||||||
|
|
||||||
doThrow(RuntimeException.class)
|
doThrow(RuntimeException.class)
|
||||||
.when(reportMessageDynamoDb).store(any());
|
.when(reportMessageDynamoDb).store(any());
|
||||||
|
|
||||||
assertDoesNotThrow(() -> reportMessageManager.store(sourceNumber, sourceAci.toString(), messageGuid));
|
assertDoesNotThrow(() -> reportMessageManager.store(sourceAci.toString(), messageGuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue