Skip to content

Commit

Permalink
[smsmodem] Fix sender identifier error with special character
Browse files Browse the repository at this point in the history
Signed-off-by: Gwendal Roulleau <[email protected]>
  • Loading branch information
dalgwen committed Jun 20, 2022
1 parent 5cc5d38 commit c1455ee
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 c1455ee

Please sign in to comment.