Skip to content

Pushrules with Dotted Value keys break #1454

@schmop

Description

@schmop

I wanted to configure a pushrule ignoring "m.replace" events.
Therefore i used this configuration:

{
    scope: 'global',
    kind: 'override',
    ruleId: 'rule.no_edits',
    body: {
        actions: [
            'dont_notify'
        ],
        conditions: [
            {
                'kind': 'event_match',
                'key': 'type',
                'pattern': 'm.room.message'
            },
            {
                'kind': 'event_match',
                'key': 'content.m.relates_to.rel_type',
                'pattern': 'm.replace'
            },
        ]
    },
}

But the behaviour of Synapse and the matrix-js-sdk didn't match.
The condition key content.m.relates_to.rel_type is interpreted in the valueDottedForKey method wrong:

Actual part splitting:
['content', 'm', 'relates_to', 'rel_type']
Needed splitting:
['content', 'm.relates_to', 'rel_type']

https://github.com/matrix-org/matrix-js-sdk/blob/develop/src/pushprocessor.js#L292

        const parts = key.split('.');

Maybe the approach of just splitting by the dot is undesirable.
Synapse takes the apporach the other way around, converting the nested object to a flat object and afterwards just accessing by the key.

Pseudo:

function accessDottedKey(evt, key) {
   flatEvt = makeFlat(evt);
   return flatEvt[key];
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions