Page MenuHomePhabricator

API should expose enough structured data about notifications that frontend can render them
Closed, ResolvedPublic

Description

Currently, the api.php?action=query&meta=notifications outputs some structured data, but not enough for frontend code to be able to render the notifications. You have to pass in notformat=flyout and that gets you pre-rendered HTML with an icon baked in.

To render notifications, we'd at least need: (please update this list as needed)

  • Body text
  • Icon
  • Primary link hrefs
  • Secondary actions
    • Label
    • Tooltip/caption
    • Icon
    • href
    • Whether they are "explicit" (rendered outside of the more menu when the notif is rendered non-compressed) or "implicit" (rendered inside of the more menu)

Event Timeline

Catrope raised the priority of this task from to Needs Triage.
Catrope updated the task description. (Show Details)
Catrope subscribed.
Catrope set Security to None.

Change 253341 had a related patch set uploaded (by Matthias Mullie):
Expose more data through API

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

In the patch currently up for review, available data is the same as what backend currently needs to render. For primary & secondary links, the only data currently available is "href" and "text".
Is there already a task for where we plan to introduce the other secondary link details?

Is there already a task for where we plan to introduce the other secondary link details?

Yes, T115421: Allow secondary actions to have icons and subtitles/tooltips

I'll just keep the patch as-is (expose existing info to API).
Adding in additional data that doesn't yet exist will be part of that other ticket, then.

Change 253341 merged by jenkins-bot:
Expose more data through API

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

Checked in betalabs:
With notformat=flyout

"read": "20151123181326",
                    "targetpages": [],
                    "*": "<div class=\"mw-echo-state\"><img class=\"mw-echo-icon\" src=\"/static/master/extensions/Flow/modules/notification/icon/Talk-ltr.png\" /><div class=\"mw-echo-content\"><div class=\"mw-echo-title\"><span class=\"plainlinks mw-echo-title-heading\"><a rel=\"nofollow\" class=\"external text\" href=\"http://en.wikipedia.beta.wmflabs.org/w/index.php?title=Topic:Ss1260tya85xnhug&amp;topic_showPostId=st2ofl4opl69tze3&amp;fromnotif=1#flow-post-st2ofl4opl69tze3\">Nov03</a></span><br/>ET1 responded on <b>Talk:ET1</b>.</div>\n<div class=\"mw-echo-notification-footer\">4 days ago</div>\n<a href=\"/w/index.php?title=Topic:Ss1260tya85xnhug&amp;topic_showPostId=st2ofl4opl69tze3&amp;fromnotif=1#flow-post-st2ofl4opl69tze3\" title=\"Topic:Ss1260tya85xnhug\" class=\"mw-echo-notification-primary-link\">View post</a></div>\n</div>\n"
                }