Page MenuHomePhabricator

Implement new Echo notifications API
Closed, DuplicatePublic

Description

The current meta=notifications API spits out HTML, which sucks.

Here's an example of what the output should look like (from here):

{
	"query": {
		"notifications": {
			"message": {
				"list": [
					{
						"id": "2958",
						"type": "flow-post-reply",
						"category": "flow-discussion",
						"icon": "/w/extensions/Flow/modules/notification/icon/Talk-ltr.png",
						"iconType": "flow-talk",
						"read": false,
						"message": {
							"header": "This is a header",
							"body": "This is the notification body"
						},
						"timestamp": {
							"mw": "20151122212510",
							"raw": "2015-11-22T21:25:10",
							"formatted": "Today"
						},
						"title": {
							"full": "Talk:Flow QA",
							"namespace": "Talk",
							"namespace-key": 1,
							"text": "Flow QA"
						},
						"agent": {
							"id": 0,
							"name": "127.0.0.1"
						},
						"links": {
							"primary": "http://localhost:8080/w/index.php?title=Topic:Sra2cr2rab4qqao9&topic_showPostId=sra2d6blrk772pvt&fromnotif=1#flow-post-sra2d6blrk772pvt",
							"secondary": [
								{
									"iconType": "userAvatar",
									"label": "127.0.0.1",
									"explicit": true,
									"url": "http://localhost:8080/w/index.php?title=User:127.0.0.1"
								}
							]
						}
					},
					{
						"id": "2926",
						"type": "flow-topic-renamed",
						"category": "flow-discussion",
						"icon": "/w/extensions/Flow/modules/notification/icon/Talk-ltr.png",
						"iconType": "flow-talk",
						"read": true,
						"message": {
							"header": "This notification has only header",
							"body": ""
						},
						"timestamp": {
							"mw": "20151022210626",
							"raw": "2015-10-22T21:06:26",
							"formatted": "Today"
						},
						"title": "Talk:Flow QA",
						"agent": {
							"id": 0,
							"name": "127.0.0.1"
						},
						"links": {
							"primary": "http://localhost:8080/w/index.php?title=Topic:Sra19tlcuba4huvd&fromnotif=1",
							"secondary": [
								{
									"iconType": "userAvatar",
									"label": "127.0.0.1",
									"explicit": true,
									"url": "http://localhost:8080/w/index.php?title=User:127.0.0.1"
								}
							]
						}
					},
					{
						"id": "4321",
						"type": "external",
						"icon": "/w/extensions/Flow/modules/notification/icon/Talk-ltr.png",
						"category": "external",
						"sources": [ "commonswiki" ],
						"iconType": "flow-talk",
						"message": {
							"header": "You have 2 notifications on Wikimedia Commons",
							"body": ""
						},
						"timestamp": {
							"mw": "20151022T210626",
							"raw": "2015-10-22T21:06:26",
							"formatted": "Today"
						},
						"links": {
							"primary": false,
							"secondary": []
						}
					}
				],
				"unread": {
					"raw": 3,
					"formatted": "3"
				}
			},
			"sources": {
				"commonswiki": {
					"title": "Commons",
					"url": "https://commons.wikimedia.org/w/api.php"
				}
			}
		}
	}
}