Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Base push rule contains_user_name should check formatted body #8715

Open
michaelkaye opened this issue Nov 4, 2020 · 10 comments
Open

Base push rule contains_user_name should check formatted body #8715

michaelkaye opened this issue Nov 4, 2020 · 10 comments
Labels
A-Push Issues related to push/notifications T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements.

Comments

@michaelkaye
Copy link
Contributor

michaelkaye commented Nov 4, 2020

Description

Steps to reproduce

Have your notification settings in element web (or element android) set to:

Messages for my display name: None
Messages for my user name: Noisy

Send this message - this was generated in element web by typing "mich" then adding "and again this should notify my phone".

"content": {
    "body": "Michael: this should notify my phone",
    "format": "org.matrix.custom.html",
    "formatted_body": "<a href=\"https://matrix.to/#/@delph:matrix.org\">Michael</a>: this should notify my phone",
    "msgtype": "m.text"
  },

Send instead this message:

"content": {
    "body": "this room is unencrypted; the message contained my user name (delph) and i have msgs containing my user name set to Noisy",
    "msgtype": "m.text"
  },

It doesn't matter if the channel is encrypted or not.

And a notification is sent through and element web highlights the message - this doesn't even have my user name it with the server included, so i would still be highlighted on other servers.

I cannot use my display name notification on "Michael" as there are a number of people with that name in the wild, and i don't want to be notified that people are talking to them.

I want to be notified only when someone uses the pill that contains my user ID, and i rely on this behaviour - i'm not sure when this stopped working but at the moment I simply don't get informed when people are talking to me, and have to manually scrape channels looking for my name.

I'm sure this worked before - users would have to send a pill and i would be notified of it, but I can't say when it's broken - i've just noticed it in the last few weeks.

Version information

Running on matrix.org (test messages sent over federation from another server)
Using stock element web and element-android - no dev versions installed.

@erikjohnston
Copy link
Member

A quick look in the matrix.org database suggests that Synapse considers both messages noisy (i.e. action highlight and sound).

When you manually open android does it show both messages as highlighted?

@michaelkaye
Copy link
Contributor Author

eleweb
There's a few tests there, the first 3 messages were without display-name notifications enabled, the last with it enabled.

@michaelkaye
Copy link
Contributor Author

Could this be an element web / element android issue then?

@erikjohnston
Copy link
Member

Oh, hang on, the first message there you're not notified about at all (I accidentally was looking at the last one).

@erikjohnston
Copy link
Member

Ok, yeah. Looks like Synapse never checks the formatted body when looking for user names. This failure may have been obscured when a) you had your display name set to Michael (delph), as we only search for the localpart of your user ID, and b) it looks like quotes include the full user ID in the text body.

This is somewhat a spec thing, ish maybe, as the user name rule is defined to be: 'conditions': [{'kind': 'event_match', 'key': 'content.body', 'pattern_type': 'user_localpart'}], i.e. it is explicitly only checking the body

@michaelkaye
Copy link
Contributor Author

So putting in this (or something similar) to the push event rules seems to fix it, though presumably others will be in the same boat and hand-rolling account data edits doesn't feel the right way to get notifications working:

{
   "device" : {},
   "global" : {
...cut...
      "override" : [
...cut...
         {
            "actions" : [
               "notify",
               {
                  "set_tweak" : "highlight",
                  "value" : true
               },
               {
                  "set_tweak" : "sound",
                  "value" : "default"
               }
            ],
            "conditions" : [
               {
                  "key" : "content.formatted_body",
                  "kind" : "event_match",
                  "pattern" : "<username>"
               }
            ],
            "default" : false,
            "enabled" : true,
            "rule_id": "username_event_match"
         },
...cut...
}

Does the spec say we couldn't default to adding this rule if the username rule is in place ? I know the defaults can't enable it, but that doesn't mean we couldn't (say) get the clients to do this

@erikjohnston erikjohnston changed the title Notifications for user name (not display name) aren't triggered by pills containing the user name. Base push rule contains_user_name should check formatted body Nov 5, 2020
@erikjohnston
Copy link
Member

I think in Synapse we should either:

  1. extend .m.rule.contains_user_name to check the formatted body, though this conflicts with the definition in the spec; or
  2. add a separate rule, but then clients would need to know to enabled/disable that as well.

Either way this should also be handled by the spec: https://github.com/matrix-org/matrix-doc/issues/2850

@richvdh richvdh added the A-Push Issues related to push/notifications label Nov 9, 2020
@callahad
Copy link
Contributor

@richvdh Do you think this is something that could slot into the backlog for the user delight project? Seems like a UX papercut that will especially affect people with common names.

@richvdh
Copy link
Member

richvdh commented Nov 16, 2020

It's kinda annoying to change the push rules. The hope is that we'd get back to revamping the notifications system (matrix-org/matrix-spec-proposals#2785 etc) in the new year; given we've lasted this long with the current implementation, my inclination is to leave it for a few more weeks.

@michaelkaye
Copy link
Contributor Author

So putting in this (or something similar) to the push event rules seems to fix it, though presumably others will be in the same boat and hand-rolling account data edits doesn't feel the right way to get notifications working:

Hi there, welcome to a few more weeks later. This hand-rolled fix has stopped working and I'm missing notifications so I'd advise against trying it if they do end up on this issue.

Best workaround I have at the moment is to make your display name very unlikely to be duplicated, and re-enable notifications on display name.

@anoadragon453 anoadragon453 added the T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements. label May 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Push Issues related to push/notifications T-Enhancement New features, changes in functionality, improvements in performance, or user-facing enhancements.
Projects
None yet
Development

No branches or pull requests

5 participants