Page MenuHomePhabricator

Android team cannot associate a talk page notification with a specific section anymore
Closed, ResolvedPublic

Description

Impact: When I get a notification on an android device for a talk page and I tap on the notification, I do not go directly to the section that the notification is all about

This will have been caused by T281590 / T253082

Patch: https://gerrit.wikimedia.org/r/c/mediawiki/extensions/DiscussionTools/+/683930

Event Timeline

We can’t associate talk page notifications with a specific section anymore. See: https://en.wikipedia.org/api/rest_v1/page/talk/User_talk:MCleinman%20(WMF) - in this request we get section names, but not those same hashes. Is it possible to either get hashes w/ the page/talk endpoint, or additionally include the section title (maybe it’s another param that could be added) in the notifications API?

The team is trying to find a work around currently, and this is NOT super-super pressing (yet).

Esanders subscribed.

This would be solved by T285971 which would add comment IDs to Android, but that is a longer term goal.

In the meantime it should be possible to modify the notifications templates to include the old section hashes somewhere else in the DOM, then Android could add some code to use these instead of the current comment ID links, e.g.

<a href="Talk:Page#commentID" data-mw-comment-section="Talk:Page#section_name">...</a>
LGoto triaged this task as High priority.Dec 8 2021, 4:55 PM

Android team to detail the API request they are using to fetch Notifications.

We use the Echo API (action=query&meta=notifications) to get a list of notifications for the current user:

https://en.wikipedia.org/w/api.php?format=json&formatversion=2&errorformat=html&errorsuselocal=1&action=query&meta=notifications&notformat=model&notlimit=max&notwikis=enwiki&notfilter=read%7C%21read

The response we receive has roughly the following structure for each notification (for a new talk message):

...
{
    header: "Dmitry Brant left a message on <strong>your talk page</strong> in "<strong>‪new topic‬</strong>".",
    compactHeader: "Dmitry Brant left you a message in "<strong>‪new topic‬</strong>".",
    body: "this is a reply to a message.",
    icon: "edit-user-talk",
    links: {
    primary: {
        url: "https://en.wikipedia.org/wiki/User_talk:Dmitry_Brant?markasread=232720605&markasreadwiki=enwiki#c-Dmitry_Brant-2021-11-16T17:30:00.000Z-Dbrant_testing-2021-07-27T16:24:00.000Z",
        label: "View message"
    },
    secondary: [
        {
            url: "https://en.wikipedia.org/wiki/Special:Contributions/Dmitry_Brant",
            label: "Dmitry Brant",
            tooltip: "",
            description: "",
            icon: "userAvatar",
            prioritized: true
        },
        {
            url: "https://en.wikipedia.org/w/index.php?title=User_talk:Dmitry_Brant&oldid=prev&diff=1055577273",
            label: "View changes",
            description: "",
            icon: "changes",
            prioritized: true
        }
    ]
}

From this structure, we need to determine the section name in the Talk page that this notification refers to. (The API is clearly aware of the section name because it puts the section in a <strong> tag in the header field, but we'd rather not have to parse the name out of the <strong> tag, since I'm guessing that's not consistent across all wikis.)
The section name also used to appear in the primary url link, in the form of a URL fragment at the end, and this is what we were using to get the section name.

So, if the section name could be added back to this API in some other way (e.g. as another field in the API response), that would be ideal for us. For example:

  {
      header: "Dmitry Brant left a message on <strong>your talk page</strong> in "<strong>‪new topic‬</strong>".",
      compactHeader: "Dmitry Brant left you a message in "<strong>‪new topic‬</strong>".",
      body: "this is a reply to a message.",
-->   section: "new topic",
      ...

Change 745341 had a related patch set uploaded (by Esanders; author: Esanders):

[mediawiki/extensions/DiscussionTools@master] Add 'legacyPrimary' links to API data for users without DT-enhanced HTML

https://gerrit.wikimedia.org/r/745341

The above patch adds a 'legacyPrimary' section to the 'links' property for notifications generated or modified by DT.

Android team should use legacyPrimary if it exists, and fallback to primary if it is not preset (for other types of notifications).

Action now is for Android team to see if this works for them - if it does we will review and merge this patch.

I've tested it locally and can confirm that this will work just fine for us. Thanks!

Change 745341 merged by jenkins-bot:

[mediawiki/extensions/DiscussionTools@master] Add 'legacyPrimary' links to API data for users without DT-enhanced HTML

https://gerrit.wikimedia.org/r/745341

ppelberg added subscribers: JTannerWMF, Dbrant, ppelberg.

Next step

  • @JTannerWMF: are you able to verify this fix produces the behavior y'all were expecting? The outcome of this will then determine whether the Editing Team needs to do additional work of close this is Resolved.
JTannerWMF added a subscriber: ABorbaWMF.

Just tested it, and it works for new notifications. @Dbrant feel free to move this to QA from Code Review if there is no further actions needed for our team.

@ABorbaWMF, trigger talk page notifications and ensure the notification brings you to the actual message instead of the general talk page.