Page MenuHomePhabricator

Watchlist Expiry: Add watchlist expiry support to Block API [medium]
Closed, ResolvedPublic

Description

As a Watchlist Expiry user, I want watchlist expiry support added to Block API, so that I can watch a user's talk page after blocking in order to monitor for unblock requests.

Background: This was split out from T248407. The use-case is you can watch a user's talk page after blocking, say to monitor for unblock requests. The code seems to trace to the SpecialBlock class, where it calls WatchAction::doWatch() which already accepts an expiry. The parameter should be called watchlistexpiry to be consistent with the other APIs (except for the watch API, itself). The parameter type should be "expiry", to be introduced with T248508.

Resources:

Acceptance Criteria:

  • Add watchlist expiry support to Block API
  • The parameter should be called watchlistexpiry to be consistent with the other APIs (except for the watch API, itself).
  • The parameter type should be "expiry", to be introduced with T248508.

Event Timeline

ifried renamed this task from Add watchlist expiry support to Block API to Watchlist Expiry: Add watchlist expiry support to Block API.Mar 26 2020, 4:13 PM
ifried updated the task description. (Show Details)
ifried updated the task description. (Show Details)
ARamirez_WMF renamed this task from Watchlist Expiry: Add watchlist expiry support to Block API to Watchlist Expiry: Add watchlist expiry support to Block API [medium].Mar 26 2020, 5:20 PM
ARamirez_WMF moved this task from Needs Discussion to Up Next (June 3-21) on the Community-Tech board.

Change 631442 had a related patch set uploaded (by Ammarpad; owner: Ammarpad):
[mediawiki/core@master] Add WatchlistExpiry support to ApiBlock

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

Change 631442 merged by jenkins-bot:
[mediawiki/core@master] Add WatchlistExpiry support to ApiBlock

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

dom_walden subscribed.

When using API:Block I can now pass a watchlistexpiry parameter (alongside the existing watchuser parameter). This watches the target of the block's User and User_talk page for the time specified.

It returns the watch expiry in the API response. For example, performing this request (watch expiry highlighted):

{
    "block": {
        "user": "Drwpb",
        "userID": 16190,
        "expiry": "2020-11-06T15:12:20Z",
        "id": 15958,
        "reason": "sjdfklsdjl",
        "nocreate": "",
        "noemail": "",
        "watchuser": "",
        "watchlistexpiry": "2020-10-20T15:12:20Z", <---
        "pagerestrictions": [],
        "namespacerestrictions": null
    }
}

If I pass an infinite value for watchlistexpiry, it will update the User/User_talk watches to be permanent, and return a null value for watch expiry. E.g. this request:

{
    "block": {
        ...
        "watchuser": "",
        "watchlistexpiry": null,
	...
    }
}

If I pass watchuser but not watchlistexpiry (for example, this request):

  • if User/User_talk pages are not already watched, it will watch them permanently
  • if User/User_talk pages are already watched, it will not change the watch or the expiry

Note that if I don't pass watchlistexpiry the API response will not include the watch expiry (even if the User/User_talk pages are already temporarily watched).

Also note that not passing watchuser will not unwatch a page that is already watched. This behaviour pre-dates this change.

The normal validation rules for watchlist expiries apply. For example, if you enter a value greater than 6 months, you get a warning (below) and the User/User_talk pages are watched for 6 months instead.

{
    "warnings": {
        "block": {
            "*": "Given value \"20 months\" for parameter \"watchlistexpiry\" exceeds the maximum of \"6 months\". Using maximum instead."
        }
    },
    ...
}

I briefly tested API:Block with watchlist expiry disabled. As far as I am aware, it works the same as it did before this change.

@ifried I notice your staff account has Administrator rights on testwiki. This means you should be able to test this on testwiki when it goes to production. E.g. https://test.wikipedia.org/wiki/Special:ApiSandbox#action=block&format=json&user=Drwpb&watchuser=1&watchlistexpiry=2%20weeks

Test Environments:

I have tested blocking someone on testwiki and setting a watchlist expiry period via the API Sandbox, and it worked as expected. The user page of the blocked user was correctly added to my watchlist for the temporary time that was specified. Furthermore, this work has been deployed to production. For this reason, I'm marking it as Done.