mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/DiscussionTools
synced 2024-11-28 18:21:50 +00:00
Merge "Fix notifications when new comment is under subheading"
This commit is contained in:
commit
a51132998c
|
@ -15,6 +15,7 @@ use Error;
|
|||
use IDBAccessObject;
|
||||
use Iterator;
|
||||
use MediaWiki\Extension\DiscussionTools\CommentParser;
|
||||
use MediaWiki\Extension\DiscussionTools\HeadingItem;
|
||||
use MediaWiki\Extension\DiscussionTools\Hooks\HookUtils;
|
||||
use MediaWiki\Extension\DiscussionTools\SubscriptionItem;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
|
@ -143,6 +144,20 @@ class EventDispatcher {
|
|||
|
||||
foreach ( $newComments as $newComment ) {
|
||||
$heading = $newComment->getHeading();
|
||||
// Find a level 2 heading, because the interface doesn't allow subscribing to other headings.
|
||||
// (T286736)
|
||||
while ( $heading instanceof HeadingItem && $heading->getHeadingLevel() !== 2 ) {
|
||||
$heading = $heading->getParent();
|
||||
}
|
||||
if ( !( $heading instanceof HeadingItem ) ) {
|
||||
continue;
|
||||
}
|
||||
// Check if the name corresponds to a section that contain no comments (only sub-sections).
|
||||
// The interface doesn't allow subscribing to them either, because they can't be distinguished
|
||||
// from each other. (T285796)
|
||||
if ( $heading->getName() === 'h-' ) {
|
||||
continue;
|
||||
}
|
||||
$events[] = [
|
||||
'type' => 'dt-subscribed-new-comment',
|
||||
'title' => $title,
|
||||
|
|
|
@ -1,16 +1 @@
|
|||
[
|
||||
{
|
||||
"type": "dt-subscribed-new-comment",
|
||||
"title": {},
|
||||
"extra": {
|
||||
"subscribed-comment-name": "h-X-2020-01-01T00:03:00.000Z",
|
||||
"comment-id": "c-X-2020-01-01T00:03:00.000Z",
|
||||
"comment-name": "c-X-2020-01-01T00:03:00.000Z",
|
||||
"content": "E.",
|
||||
"section-title": "",
|
||||
"revid": null,
|
||||
"mentioned-users": []
|
||||
},
|
||||
"agent": {}
|
||||
}
|
||||
]
|
||||
[]
|
||||
|
|
|
@ -1,16 +1 @@
|
|||
[
|
||||
{
|
||||
"type": "dt-subscribed-new-comment",
|
||||
"title": {},
|
||||
"extra": {
|
||||
"subscribed-comment-name": "h-X-2020-01-01T00:03:00.000Z",
|
||||
"comment-id": "c-Y-2020-01-01T00:04:00.000Z-X-2020-01-01T00:03:00.000Z",
|
||||
"comment-name": "c-Y-2020-01-01T00:04:00.000Z",
|
||||
"content": "F.",
|
||||
"section-title": "",
|
||||
"revid": null,
|
||||
"mentioned-users": []
|
||||
},
|
||||
"agent": {}
|
||||
}
|
||||
]
|
||||
[]
|
||||
|
|
|
@ -1,16 +1 @@
|
|||
[
|
||||
{
|
||||
"type": "dt-subscribed-new-comment",
|
||||
"title": {},
|
||||
"extra": {
|
||||
"subscribed-comment-name": "h-Y-2020-01-01T00:01:00.000Z",
|
||||
"comment-id": "c-Z-2020-01-01T00:02:00.000Z-Y-2020-01-01T00:01:00.000Z",
|
||||
"comment-name": "c-Z-2020-01-01T00:02:00.000Z",
|
||||
"content": "E.",
|
||||
"section-title": "B",
|
||||
"revid": null,
|
||||
"mentioned-users": []
|
||||
},
|
||||
"agent": {}
|
||||
}
|
||||
]
|
||||
[]
|
||||
|
|
|
@ -1,16 +1 @@
|
|||
[
|
||||
{
|
||||
"type": "dt-subscribed-new-comment",
|
||||
"title": {},
|
||||
"extra": {
|
||||
"subscribed-comment-name": "h-Z-2020-01-01T00:03:00.000Z",
|
||||
"comment-id": "c-Z-2020-01-01T00:03:00.000Z-D",
|
||||
"comment-name": "c-Z-2020-01-01T00:03:00.000Z",
|
||||
"content": "F.",
|
||||
"section-title": "D",
|
||||
"revid": null,
|
||||
"mentioned-users": []
|
||||
},
|
||||
"agent": {}
|
||||
}
|
||||
]
|
||||
[]
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
"type": "dt-subscribed-new-comment",
|
||||
"title": {},
|
||||
"extra": {
|
||||
"subscribed-comment-name": "h-Y-2020-01-01T00:02:00.000Z",
|
||||
"subscribed-comment-name": "h-X-2020-01-01T00:01:00.000Z",
|
||||
"comment-id": "c-Z-2020-01-01T00:04:00.000Z-Y-2020-01-01T00:02:00.000Z",
|
||||
"comment-name": "c-Z-2020-01-01T00:04:00.000Z",
|
||||
"content": "G.",
|
||||
"section-title": "C",
|
||||
"section-title": "A",
|
||||
"revid": null,
|
||||
"mentioned-users": []
|
||||
},
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
"type": "dt-subscribed-new-comment",
|
||||
"title": {},
|
||||
"extra": {
|
||||
"subscribed-comment-name": "h-Z-2020-01-01T00:05:00.000Z",
|
||||
"subscribed-comment-name": "h-X-2020-01-01T00:01:00.000Z",
|
||||
"comment-id": "c-Z-2020-01-01T00:05:00.000Z-E",
|
||||
"comment-name": "c-Z-2020-01-01T00:05:00.000Z",
|
||||
"content": "H.",
|
||||
"section-title": "E",
|
||||
"section-title": "A",
|
||||
"revid": null,
|
||||
"mentioned-users": []
|
||||
},
|
||||
|
|
|
@ -101,7 +101,8 @@ class EventDispatcherTest extends IntegrationTestCase {
|
|||
'Z',
|
||||
'../cases/EventDispatcher/multiple/rev2.json',
|
||||
],
|
||||
// Adding comments in section 0 (before first heading).
|
||||
// Adding comments in section 0 (before first heading). These do not generate notifications,
|
||||
// because the interface doesn't allow subscribing to it.
|
||||
[
|
||||
'cases/EventDispatcher/section0/rev1.txt',
|
||||
'cases/EventDispatcher/section0/rev2.txt',
|
||||
|
@ -122,7 +123,8 @@ class EventDispatcherTest extends IntegrationTestCase {
|
|||
'../cases/EventDispatcher/emptysection/rev2.json',
|
||||
],
|
||||
// Adding comments in sub-sections, where the parent section has no comments (except in
|
||||
// sub-sections).
|
||||
// sub-sections). These do not generate notifications because of the fix for T286736,
|
||||
// but maybe they should?
|
||||
[
|
||||
'cases/EventDispatcher/subsection-empty/rev1.txt',
|
||||
'cases/EventDispatcher/subsection-empty/rev2.txt',
|
||||
|
|
Loading…
Reference in a new issue