Skip to content

Commit 0d210dc

Browse files
committed
Merge branch 'make-key-subkey-case-insensitive' into 'develop'
Make signal keys & subkeys case-insensitive See merge request programaker-project/programaker-core!203
2 parents 48002b8 + ffc7d8a commit 0d210dc

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

backend/apps/automate_channel_engine/src/automate_channel_engine.erl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ listen_channel(ChannelId, {Key}) ->
4646
listen_channel(ChannelId, {Key, SubKey}) ->
4747
Pid = self(),
4848
Node = node(),
49-
case automate_channel_engine_mnesia_backend:add_listener_to_channel(ChannelId, Pid, Node, Key, SubKey) of
49+
case automate_channel_engine_mnesia_backend:add_listener_to_channel(ChannelId, Pid, Node,
50+
canonicalize_selector(Key),
51+
canonicalize_selector(SubKey)) of
5052
ok ->
5153
?MONITOR:monitor_listener(Pid);
5254
Error ->
@@ -112,14 +114,16 @@ get_appropriate_listeners_key_subkey(ChannelId, {Key, SubKey}) ->
112114
{error, Reason } ->
113115
{error, Reason};
114116
{ok, Listeners} ->
117+
CanonicalKey = canonicalize_selector(Key),
118+
CanonicalSubKey = canonicalize_selector(SubKey),
115119
Uniques = sets:from_list(lists:filtermap(fun(#listeners_table_entry{pid=Pid, key=ListenerKey, subkey=ListenerSubKey}) ->
116120
AcceptedKey = case ListenerKey of
117-
Key -> true;
121+
CanonicalKey -> true;
118122
undefined -> true;
119123
_ -> false
120124
end,
121125
AcceptedSubKey = case ListenerSubKey of
122-
SubKey -> true;
126+
CanonicalSubKey -> true;
123127
undefined -> true;
124128
_ -> false
125129
end,
@@ -132,3 +136,10 @@ get_appropriate_listeners_key_subkey(ChannelId, {Key, SubKey}) ->
132136
Listeners)),
133137
{ok, sets:to_list(Uniques)}
134138
end.
139+
140+
canonicalize_selector(undefined) ->
141+
undefined;
142+
canonicalize_selector(null) ->
143+
null;
144+
canonicalize_selector(Selector) ->
145+
string:lowercase(Selector).

0 commit comments

Comments
 (0)