Skip to content

Commit

Permalink
[smsmodem] Fix sender identifier error with special character
Browse files Browse the repository at this point in the history
  • Loading branch information
dalgwen committed Jun 8, 2022
1 parent 5cc5d38 commit 195acac
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@ protected void startScan() {
}
}

public void buildDiscovery(String msisdn) {
public void buildDiscovery(String sender) {
String senderSanitized = sender.replaceAll("[^a-zA-Z0-9+]", "_");
ThingUID thingUID = SMSModemHandlerFactory
.getSMSConversationUID(SMSModemBindingConstants.SMSCONVERSATION_THING_TYPE, msisdn, bridgeUid);
.getSMSConversationUID(SMSModemBindingConstants.SMSCONVERSATION_THING_TYPE, senderSanitized, bridgeUid);
DiscoveryResult result = DiscoveryResultBuilder.create(thingUID)
.withProperty(SMSModemBindingConstants.SMSCONVERSATION_PARAMETER_RECIPIENT, msisdn)
.withLabel("Conversation with " + msisdn).withBridge(bridgeUid)
.withProperty(SMSModemBindingConstants.SMSCONVERSATION_PARAMETER_RECIPIENT, senderSanitized)
.withLabel("Conversation with " + sender).withBridge(bridgeUid)
.withThingType(SMSModemBindingConstants.SMSCONVERSATION_THING_TYPE)
.withRepresentationProperty(SMSModemBindingConstants.SMSCONVERSATION_PARAMETER_RECIPIENT).build();
thingDiscovered(result);
Expand Down

0 comments on commit 195acac

Please sign in to comment.