@@ -94,16 +94,20 @@ binary_to_list_validated(undefined) ->
94
94
binary_to_list_validated (Value ) ->
95
95
binary_to_list (Value ).
96
96
97
+ can_view_value_device (_Pool , _Type , _PermissionType , _OwnerId , " *" , _Token ) ->
98
+ " 1" ;
97
99
can_view_value_device (_Pool , _Type , " all" , _OwnerId , _DeviceLabel , _Token ) ->
98
- true ;
99
- can_view_value_device (Pool , Type , _ , OwnerId , DeviceLabel , Token ) ->
100
+ " 1 " ;
101
+ can_view_value_device (Pool , Type , _PermissionType , OwnerId , DeviceLabel , Token ) ->
100
102
DeviceHashSetKey = " reactor_variables/" ++ OwnerId ,
101
103
DeviceLabelKey = " /" ++ DeviceLabel ,
102
104
TokenKey = " reactor_devices_with_permissions/view_value/" ++ Token ,
103
105
DeviceId = execute_redis_command (Pool , Type , [" HGET" , DeviceHashSetKey , DeviceLabelKey ]),
104
106
CanViewValueDevice = execute_redis_command (Pool , Type , [" SISMEMBER" , TokenKey , DeviceId ]),
105
107
binary_to_list_validated (CanViewValueDevice ).
106
108
109
+ get_topics_mqtt_by_topic (none , _Topic , _VariableId ) ->
110
+ [];
107
111
get_topics_mqtt_by_topic (last_value , Topic , VariableId ) ->
108
112
[atom_to_list (last_value ), Topic ++ " /lv" , VariableId ];
109
113
get_topics_mqtt_by_topic (value , Topic , VariableId ) ->
@@ -151,11 +155,20 @@ get_device_labels(Pool, Type, Token) ->
151
155
DeviceIds = execute_redis_command (Pool , Type , [" SMEMBERS" , DeviceIdsKey ]),
152
156
get_device_labels_by_device_ids (Pool , Type , DeviceIds ).
153
157
158
+ get_mqtt_topics_device_labels_and_variable_label (_Pool , _Type , _CanViewDevice , [], _VariableLabel , _OwnerId , _Token , _TopicKind , _Version ) ->
159
+ [];
160
+ get_mqtt_topics_device_labels_and_variable_label (Pool , Type , CanViewDevice , [DeviceLabel | Rest ], VariableLabel , OwnerId , Token , TopicKind , Version ) ->
161
+ get_mqtt_topics_by_label (Pool , Type , CanViewDevice , DeviceLabel , VariableLabel , OwnerId , Token , TopicKind , Version ) ++
162
+ get_mqtt_topics_device_labels_and_variable_label (Pool , Type , CanViewDevice , Rest , VariableLabel , OwnerId , Token , TopicKind , Version ).
163
+
154
164
get_mqtt_topics_by_label (Pool , Type , " 1" , " *" , " *" , OwnerId , Token , TopicKind , Version ) ->
155
165
DeviceLabels = get_device_labels (Pool , Type , Token ),
156
166
get_mqtt_topics_by_device_labels (Pool , Type , DeviceLabels , OwnerId , TopicKind , Version );
157
167
get_mqtt_topics_by_label (Pool , Type , " 1" , DeviceLabel , " *" , OwnerId , _ , TopicKind , Version ) ->
158
168
get_mqtt_topics_by_device_labels (Pool , Type , [DeviceLabel ], OwnerId , TopicKind , Version );
169
+ get_mqtt_topics_by_label (Pool , Type , " 1" , " *" , VariableLabel , OwnerId , Token , TopicKind , Version ) ->
170
+ DeviceLabels = get_device_labels (Pool , Type , Token ),
171
+ get_mqtt_topics_device_labels_and_variable_label (Pool , Type , " 1" , DeviceLabels , VariableLabel , OwnerId , Token , TopicKind , Version );
159
172
get_mqtt_topics_by_label (
160
173
Pool , Type , " 1" , DeviceLabel , VariableLabel , OwnerId , _ , TopicKind , Version
161
174
) ->
0 commit comments