Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix onEvent mask and wildcard handling error #100

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

noreplydev
Copy link
Collaborator

Fix flows onEvent mask: Parsing from JSON to Object a Object not a string, this leads to an error parsing to Object and Object.

Fix MQTT topic subscription check: If we see how is handled mqtt subscription on Protofy/apps/api/src/api.ts there is an error if we use wildcards. On topicSub we add a value to subscriptions with let's say the key "test/#" (which is wildcard for all messages that came from test, something like test/*. Then on

  
mqtt.on("message", (messageTopic, message) => {
    const topic = messageTopic.toString()
    let parsedMessage = message.toString()
    try {
        parsedMessage = JSON.parse(parsedMessage);
    } catch (err) { }

    if(subscriptions[topic]) {  <--------------- HERE
        // Handle wildcard subscriptions
        const validSubscriptions = Object.keys(subscriptions).filter(subscription => {
    
    ...

We check if we're subscribed to that topic. A topic like:

test/sample

Will always fail even if we're subscribed with wildcard to test/# since on our subscriptions map we're subscribed to test/# not test/sample.

@noreplydev noreplydev requested review from jcarlosn and ap0k4 May 8, 2024 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant