Publishing a message to an empty list of devices actually broadcasts to all devices.

Hi,
I’ve noticed an issue when publishing (pushing) messages to a specific set of devices. If an empty list of deviceID’s is targeted then the message is actually published to all devices, instead of none. There’s no problem as long as one value is specified. This value doesn’t have to be associated with a device, it just has to be passed.


DeliveryOptions deliveryOptions = new DeliveryOptions();
deliveryOptions.setPushPolicy( PushPolicyEnum.ONLY );

List<String> deviceIDs= getRecipientDeviceIDs(
p_conversation,
p_sender 
);
//deliveryOptions.setPushSinglecast( deviceIDs );
/*
for( String deviceID : deviceIDs )
{
deliveryOptions.addPushSinglecast( deviceID );
}
*/
deliveryOptions.addPushSinglecast( "somerandomgarbagedeviceidthatisntreal" );
return deliveryOptions;

Is this expected behaviour or is it a bug with this type of message publishing? As you can see from the commented out code I’ve tried a few variations on inputting deviceIDs. I could simply not ‘publish’ the message by detecting zero deviceIDs, so maybe I’m being pedantic. Just thought i’d flag it anway though in case it has any other knock-on affects within your system.
Cheers,
Grant.

I agree it is not the best behaviour. We will fix this bug

I did not understand you. If you are sending message to a non-existent id, the server will not send a message. This is the correct behaviour

Sorry i’ve possibly over-explained the situation. In a nutshell (referencing the code above), if the object ‘deliveryOptions’ contains 0 deviceIDs then i’m seeing the message being published to ALL registered devices. To me this doesn’t make sense, as I assumed it wouldn’t publish to any.

Does that make any sense?

Cheers,
Grant.

if you do not specify a recipient, the message will be delivered to all. This is the correct behaviour.