Commit graph

1324 commits

Author SHA1 Message Date
Michael Holloway 5eb4c6cd1d Add notifiertypes parameter to ApiEchoNotifications
Previously, ApiEchoNotifications returned only events which were
enabled for the `web` notifier type. With this change, the notifier
type or types to consider can be specified by argument to the new
`notifiertypes` parameter.

This change is required so that the apps can request notification
content from the API for push notifications.

Bug: T287909
Change-Id: I2d1155e113f2defb0f02416a7a659c3ee162d3a6
2021-08-17 10:27:14 -04:00
jenkins-bot 8032317d9c Merge "Only ignore user muting for notifications on your talk page (not subpages)" 2021-08-12 06:47:32 +00:00
jenkins-bot afe6a50d3a Merge "Link to the section (if known) from the orange banner" 2021-08-06 09:27:41 +00:00
Bartosz Dziewoński a6db7325e3 Only ignore user muting for notifications on your talk page (not subpages)
Bug: T288112
Change-Id: I41b8774fe0aea836c771c49ce6542156b686707a
2021-08-04 17:36:50 +02:00
Petr Pchelko e609db33ff Replace deprecated UserLoadOptionHook
Bug: T286576
Change-Id: I36d59813f25268097b822919d4236a41e0ea363a
2021-08-03 07:28:31 -07:00
jenkins-bot d9f43ee2f0 Merge "Replace deprecated UserSaveOptions hook" 2021-08-03 14:20:36 +00:00
jenkins-bot 822e623b7d Merge "Fix variable choice in NotificationController::notify" 2021-08-02 15:40:24 +00:00
jenkins-bot 5566f84378 Merge "Turn push notification token list into a circular buffer." 2021-07-30 14:46:10 +00:00
DannyS712 5d3c416672 Remove ParserTestTables hook handler.
This hook is no longer called in MW 1.36+ by core, and this
extension already requires MW 1.37+

See I5124789fac333a664b73b4b4a1e801ecc0a618ca

Change-Id: I420c2a231cc1c7d6a350a1f04f7c7d4fd942b377
2021-07-30 04:00:17 +00:00
Dmitry Brant 6c5a88107c Turn push notification token list into a circular buffer.
At the moment we support a maximum of 10 tokens per user for subscribing
to push notifications, stored as a basic list that runs out when the
limit is reached.  There may, however, be some edge cases where an app
registers a token and then forgets to unregister it (and repeats this 10
times), after which time it will be unable to register any new token.

This changes the token list to behave more like a circular buffer, by
simply deleting the oldest token before inserting the new one. This way
an app could register a new token even in the rare case of forgetting
the previous ten.

Change-Id: I387de63460882e4e56d1aa6db1f78d73a0495208
2021-07-29 17:22:57 -04:00
Ottomata 7336a1a67c Finalize migration of EchoMail and EchoInteraction to Event Platform
Also remove produciton of inactive Echo schema.

Bug: T287210
Change-Id: Ifc7f5aa22e62e7308f729de5a7fcf3fad9519615
2021-07-28 19:29:26 +01:00
Matěj Suchánek e30b466d9c Fix variable choice in NotificationController::notify
I believe this is a bug. Individual user's option ($userNotifyTypes)
should not influence the options for all users ($notifyTypes).

This piece of code was first introduced in
I51600bbb26594323831d22bc35d34587ff146d47.

Change-Id: I32d56891ac68e82734813280505b4a57d5427f8c
2021-07-28 13:13:00 +02:00
TChin 113230aaed Replace deprecated UserSaveOptions hook
Bug: T287472
Change-Id: I170cd7f5676459f83e7b1abadf5485486b8caaab
2021-07-27 15:24:51 -04:00
jenkins-bot 9e9303221e Merge "SpecialDisplayNotificationsConfiguration: Fix default values of core prefs" 2021-07-27 18:32:19 +00:00
jenkins-bot 0364d96af3 Merge "SpecialDisplayNotificationsConfiguration: Use OOUI checkboxes" 2021-07-27 18:32:18 +00:00
Bartosz Dziewoński 0341634e45 SpecialDisplayNotificationsConfiguration: Fix default values of core prefs
Some of Echo's subscription user preferences are mapped to existing
user preferences defined in core MediaWiki. However, this special page
was checking the Echo preference names, returning incorrect values.

This affected the edit-user-talk preference and watchlist preferences
(not available with the default configuration).

Change-Id: I2de7553f82434505c000c30a71b9f90c4490482b
2021-07-27 19:53:58 +02:00
Bartosz Dziewoński b826dd263c SpecialDisplayNotificationsConfiguration: Use OOUI checkboxes
On some systems, when they are disabled, checked and unchecked
checkboxes are not that easy to distinguish. They're really bad
for me on Windows (apparently a bit less bad on macOS).
https://phabricator.wikimedia.org/F34567120

OOUI checkboxes are clearer (since they're bigger and the
check icon has higher contrast against the background).
https://phabricator.wikimedia.org/F34567121

Change-Id: I124c7e1874d50d5f3883ffcc5264da46ae012e0a
2021-07-27 19:33:30 +02:00
DannyS712 4cc8233ee5 DiscussionParser: fetch UserNameUtils service outside of loop
Change-Id: I6c523dcc2ca1e06136f2f5ad18c0ac371c7f9494
2021-07-26 09:40:49 +00:00
DannyS712 f13dd018c7 Enable and fix ReturnTypeDeclaration sniff
Libup decided to disable the sniff, fix the issues instead

Change-Id: Ibac1c3f32af19edff3f428928efe578d97061b07
2021-07-24 04:36:30 +00:00
libraryupgrader 17a644263a build: Updating dependencies
composer:
* mediawiki/mediawiki-codesniffer: 36.0.0 → 37.0.0
  The following sniffs are failing and were disabled:
  * PSR12.Functions.ReturnTypeDeclaration.SpaceBeforeReturnType

npm:
* svgo: 2.3.0 → 2.3.1
  * https://npmjs.com/advisories/1754 (CVE-2021-33587)
* postcss: 7.0.35 → 7.0.36
  * https://npmjs.com/advisories/1693 (CVE-2021-23368)
* trim-newlines: 3.0.0 → 3.0.1
  * https://npmjs.com/advisories/1753 (CVE-2021-33623)

Change-Id: Id866782d39ac02a329bd79539f2d52392fffd296
2021-07-24 01:48:06 +00:00
jdlrobson b4ec1eda88 Fix display of user messages orange bar
The icon in Vector is copied across when Vector is loaded before
Echo in LocalSettings.php

Change-Id: Ida8c78e5c723f9628928f0293f43b2d67616888f
2021-07-22 13:21:53 -07:00
jenkins-bot e8430bd44a Merge "Update vector badge styles" 2021-07-22 17:59:38 +00:00
bwang b0aaa2e4ec Update vector badge styles
- Override echo icon styles for modern vector
- Reverts https://gerrit.wikimedia.org/r/c/mediawiki/extensions/Echo/+/704862

Bug: T285259
Change-Id: Id71d3e248dc6d0ee24278e0ecfbcf8691e1da24b
2021-07-22 11:53:36 -05:00
Petr Pchelko a10b0b07c8 Use CentralIdLookupFactory and pass UserIdentity
Change-Id: I44144df7cf244eb867c1b261c10cc29b020f8409
2021-07-21 19:23:42 -07:00
Matěj Suchánek 3f05f8a71b Drop unused property and inject a service to SpecialDisplayNotificationsConfiguration
Change-Id: I0f238b863638245eef381e540da7d610d01bd25b
2021-07-17 10:40:45 +00:00
jenkins-bot a6dbadb006 Merge "Avoid using User::setOption()" 2021-07-17 10:29:45 +00:00
ZabeMath 3befbe0a69 Avoid using User::setOption()
User::setOption() is deprecated and should be replaced with UserOptionsManager::setOption()

Bug: T277818
Change-Id: I001301fb95635c421a0bbb921fd909c5312dc896
2021-07-17 09:52:53 +00:00
bwang fbde7bd61b Add icon property to echo link data for modern Vector
Bug: T285259
Change-Id: I995f877a6e8574a519aedece31e7889b9735366a
2021-07-16 15:05:29 +00:00
DannyS712 3269afae8e Remove use of global $wgUser
This partially reverts commit 83a181ce9c
and fully reverts 82896eff62

To avoid regressing to the errors from T139665, check if the user
retrieved from RequestContext::getMain()->getUser() is safe to load
instead of $wgUser, still in addition to the other checks that
EchoForeignWikiRequest::$user is safe to load.

Bug: T243732
Change-Id: I22c4918fc7e8b3d1364a95de3958c055059971b8
2021-07-14 04:57:34 +00:00
jenkins-bot fa8331294b Merge "Hardcode talk alert id to be pt-talk-alert" 2021-07-13 19:42:47 +00:00
bwang 2bf4047410 Hardcode talk alert id to be pt-talk-alert
Bug: T285442
Change-Id: I3b46a494682b3b5055f525c0c1219a1710655ce5
2021-07-13 13:58:06 -05:00
jenkins-bot bfcbfff6f6 Merge "Drop DB patches from pre MW 1.26" 2021-07-13 13:52:27 +00:00
jenkins-bot 7cb32579c7 Merge "Simplify code for detecting rollbacks" 2021-07-12 23:04:20 +00:00
jenkins-bot 98d7428837 Merge "Avoid using ContentHandler::getContentText()" 2021-07-12 14:22:05 +00:00
jenkins-bot 31d115e9f3 Merge "Remove probably outdated error suppression" 2021-06-29 17:49:35 +00:00
Matěj Suchánek 4b4954ac40 Remove probably outdated error suppression
https://bugs.php.net/bug.php?id=50688 was closed as fixed
in 2017 when PHP 7.0 was only supported upstream.
We already require PHP 7.2.

Change-Id: Ie9801e38915da634e31c91ebdcb61226e0ae5712
2021-06-29 17:29:23 +02:00
DannyS712 0099c45e54 AttributeManager: accept UserIdentity objects
Inject a UserOptionsLookup to replace deprecated
User::getOption()

Change-Id: I177f6d3486f987073e5d745077f0abfe9ae85aca
2021-06-29 06:41:47 +00:00
DannyS712 66a290500c EventLogging: accept UserIdentity objects
Replace User::getEditCount with UserEditTracker service

Change-Id: Idcf98dc6b1e88f9301b731b1d8296f613464a364
2021-06-29 06:12:59 +00:00
DannyS712 2e1757eaaf NotificationMapper: accept UserIdentity objects
No need for a full User, only the user's id is retrieved

Change-Id: Ibf4005c83d66d846b7e1ab711cd135c9ae08964a
2021-06-29 05:53:41 +00:00
Reedy 5d4a012d48 Drop DB patches from pre MW 1.26
Change-Id: I6693239455a2696b7bb77841041204b75a3c99fb
2021-06-27 23:16:03 +00:00
Reedy 532faf27f5 Reorganise MySQL/SQLite patches
SQL files that are MySQL/SQLite specific have been moved to subfolders

Change-Id: Ib677815f2fb6a4e3aa0236a31160efaf761ad4ef
2021-06-26 16:24:14 +00:00
Jan Drewniak 6ccbea0d5a Set .mw-echo-alert class on link instead of list-item
Update to 7880cc18, restores ".mw-echo-alert" class on "class" property
instead of on "link-class" property.

Bug: T284496
Change-Id: I11a04fa5a7e9d0b34e62733ee537a43549d13477
2021-06-08 13:29:59 +02:00
Bartosz Dziewoński 7f993f570d Link to the section (if known) from the orange banner
If there's exactly one new user talk message, then link directly to it
from the orange banner.

I'm using EchoEventPresentationModel to get the link target, instead
of some more direct way, because this approach allows us to override
the link in DiscussionTools. Together with the changes proposed in
T281590, this would allow linking directly to individual messages (and
highlighting them), rather than just the section.

Bug: T58475
Change-Id: I1fd0e22f4ee0f0dfacaf420d3fd890dce0820cbd
2021-06-07 21:48:48 +02:00
Nicholas Ray 2583f803c3 Add talk notification instead of transforming the talk link
Note: This change would potentially affect all skins including modern
and legacy Vector and others.

The status quo when a talk notification is present is to transform the
talk link into an orange notification message. One option is to leave
the talk link and **add** a notification instead of transforming it.

This will result in two elements #pt-mytalk and #pt-talk-alert
This will interfere with styles targeting #pt-mytalk .mw-echo-alert
This impacts user styles but not anything in production.

Bug: T283811
Change-Id: I3e4be1381f9a2e9986b94b3b13df5ed64d09a59d
2021-06-04 09:33:50 -07:00
jenkins-bot 76f525b69f Merge "SpecialNotifications: Load mark-as-read icon in no-JS mode" 2021-06-03 17:10:37 +00:00
jdlrobson 4c58a85bb1 Echo hook needs to consider other hook modifications
Follow up to 7880cc1

Bug: T274428
Change-Id: Ia4520a3df28027d43ecdeb217b108669e7cb6795
2021-06-02 17:25:00 +00:00
Bartosz Dziewoński ab6a37f4e1 SpecialNotifications: Load mark-as-read icon in no-JS mode
Follow-up to 34e3d5feba.

Change-Id: I780baad06e16b29a8a1b033af60f14c33368119b
2021-06-01 23:02:59 +02:00
Nicholas Ray 7880cc1895 Make talk page notification use link-class, id and don't set class
Before this commit, setting:

```
$wgVectorConsolidateUserLinks = [
  'logged_in' => true
];
```

would result in an orange talk notification that had missing or
incorrect attributes (`#ca-mytalk` instead of `#pt-mytalk` and missing
the `title` and `accesskey` attributes) when visiting modern Vector
with a talk notification visible. The notification's html looked like:

```
<li id="ca-mytalk" class="mw-echo-alert">
  <a href="/wiki/User_talk:Newuser5">You have a new Talk page message</a>
</li>
```

The `pt-mytalk` id is important for echo to remove the notification [1].
The title and accesskey are important for accessibility reasons.

This commit corrects that by setting a `link-class`, setting an explicit
`id`, and NOT setting a `class` key. This results in html that is
correct in both modern and legacy Vector:

```
<li id="pt-mytalk">
  <a href="/wiki/User_talk:Newuser5" class="mw-echo-alert" title="Your talk page [ctrl-option-n]" accesskey="n">You have a new Talk page message</a>
</li>
```

[1] 67bf58a489/modules/ext.echo.init.js (L172)

Bug: T274428
Change-Id: I5afc74992ad3153ac32df65ccf5fd03b469f05fb
2021-05-27 19:22:10 -06:00
Nicholas Ray 3a351cfb4f Move talk page notification data from 'user-menu' to 'notifications'
**Note**: This change will affect the order of the yellow talk page
message notification on legacy Vector/other skins by moving it from
after the `#pt-notifications-notice` element to before the
`#pt-notifications-alert` element. This was done because the
notification is related to the list of messages that appear when the
bell icon is clicked so having it in close proximity to that icon is
hopefully more intuitive than having it next to the unrelated inbox
icon. [1]

Per T274428, we need this notification to be inside the `notifications`
array instead of inside the `user-menu` array.

Additionally:

* Per T274428, update the notifications message copy to "You have a new
Talk page message"

* Remove the `onPersonalUrls` hook method inside EchoHooks,
unregister its use as a hook in extension.json, and update its
references in Echo.

[1] T274428#7113896

Bug: T274428
Change-Id: I5ae0ec089bcf0eec1ec7ac13f60e811f54e1d8e1
2021-05-25 18:24:29 -06:00
Bartosz Dziewoński 3762c3d4d8 Simplify code for detecting rollbacks
Thanks to the changes from T254074, the EditResult object passed to
the 'PageSaveComplete' hook now knows whether the edit being saved
is a rollback. We don't need to pass this information from the
'RollbackComplete' hook via globals.

Bug: T277649
Change-Id: Ieef7941e4665204b1a9b2356a58216626ed1f54b
2021-05-25 20:32:36 +02:00