Commit graph

50 commits

Author SHA1 Message Date
daniel
b38e0e8e32 REST edit: handle null edits correctly
For null-edits, the new revision is the same as the old revision.

Bug: T277601
Change-Id: I73f902f7ef890470ff6ee3e4500095adbb00938a
2021-03-19 14:10:25 +01:00
daniel
fa8ddd48fc Implement /revision/{id} endpoint
Also implements and endpoint for revision source,
for parity with /page/{title}.

Bug: T267981
Change-Id: I88c714df6e428fbc02aa4ff7f4ecea7d8b458468
2020-12-14 16:54:43 +00:00
daniel
a4b51d2774 Implement /revision/{id}/html endpoint
This doesn't have caching yet.

Bug: T267981
Change-Id: I32a35bb7bc6c6832ce7c79fb942922abc1ddb0e0
2020-12-14 16:54:35 +00:00
Nikki Nikkhoui
783258900f UserContribs tags prop as array
Make the tags property in each contribution in
the User Contributions REST endpoint an array of tag
objects (instead of a key/value pair mapping tag names
to tag properties).

Bug: T259716
Change-Id: I8265ded81f05fef5f88d5a565266f91a307dd38c
2020-08-25 22:31:17 +00:00
Nikki Nikkhoui
c26d64fc18 UserContributions endpoint add tags 'display' property
Add a property to the 'tags' object in the /user/{name}/contributions
REST endpoint named 'display' which shows the display
HTML for the tag which is either defined in i18n .json
files or overriden at MediaWiki:tag-$name

Bug: T259716
Depends-On: I57e2a7253944a3fde3f52f52bbf5fe8473c8a415
Change-Id: Id755adcab8b0115e19df2a6046643ebe97881e28
2020-08-19 06:04:50 -07:00
Nikki Nikkhoui
c0f4b8a1eb Make array of tags with property 'text'
Change the tag property on each contribution from an
array of strings to an array of objects with property
'text'.

Bug: T252202
Bug: T235073
Change-Id: I9ececd1f351600e3e0fd54be2fb34449898285e1
2020-08-06 07:35:29 -07:00
jenkins-bot
8991f53965 Merge "REST /page/{title}: Fix title encoding." 2020-07-28 19:09:48 +00:00
Nikki Nikkhoui
3ba476102d /contributions/user/{user}/count
REST Endpoint for getting the number of contributions for a given
user (not yourself).

Change-Id: Ib3bfedcec0aa1af1983cec0a7bda28fc49ddc673
2020-07-28 18:36:41 +00:00
daniel
d2d2906ce7 REST /page/{title}: Fix title encoding.
Page titles used in URL paths, such as the Location header returned
after a page was created, must use the correct encoding for spaces and
pluses.

Bug: T258606
Change-Id: I75e91ac8f8da4eb183a9c8f1a682ea08c2225227
2020-07-23 23:17:17 +02:00
Nikki Nikkhoui
43f2d5440f Rename 'revisions' to 'contributions'
Extensions have the ability to inject their own idea of what
a contribution is into the ContribsPager query resultset (via
the ContribsPager__reallyDoQueryHook). Because of this,
stable chronological ordering of ContribsPager results
becomes virtually impossible

For the purpose of the User Contribution REST endpoints, we will
restrict the resultset to ONLY mediawiki revisions for now.

This patch renames 'revisions' to 'contributions' and adds the
'type' field to future-proof work on adding different kinds of
contributions to the User Contribution REST endpoints.

Bug: T257838
Change-Id: I1e6de1c14a5f47e0310df86325fa6d791833addb
2020-07-22 18:29:29 +02:00
Ostrzyciel
435d5f4d55 Add mw-manual-revert change tag
Based on the patch that introduces manual revert detection, this is
to create a software-defined change tag that will be applied to all
edits that restore a page to an exact previous state. This is also
for consistency with mw-undo and mw-rollback that will make a
"reverted" tag appear on reverted edits in the future.

Note about the REST API tests: in the next patch in this chain
I encountered even more issues with comparing returned changed tags
with expectations, so I decided it'd better if we just checked the
change tags applied manually in these tests. Otherwise we can run into
nasty race conditions, as the reverted tag is processed after sending
the response to client in the deferred update. It also makes the test
hard to maintain.

Bug: T256001
Change-Id: Ic367886f39faedcb823222b7d63bf4d5cb236ae9
2020-07-16 13:29:12 +02:00
daniel
7717db62e1 REST /user/{name}/contribs
Bug: T235073
Change-Id: Ia262d055185c20142629d0824e4ba14a5e5fa9d3
2020-07-09 12:34:52 -07:00
daniel
afdcacbfd5 REST /me/contributions/count filter by tag
Bug: T251806
Change-Id: Ib071ebb91f20a0ca1c0e14b4a271fc17f343a648
2020-07-06 19:56:17 +02:00
daniel
c1a73e64e1 REST me/contributions/count endpoint
Introduce endpoint for getting a uer's contribution count.

Bug: T251805
Change-Id: I409b7943941437f46dd8cdb2194fca9b7404f185
2020-07-06 09:28:33 +00:00
daniel
2cf5a251b9 me/contributions: filter by tag
Bug: T251803
Change-Id: I5ba4164abe414df4b24858422f2a601e00516d7f
2020-07-02 22:27:21 +02:00
daniel
01b959fb83 UserContributions endpoint: return deltas
Bug: T252202
Change-Id: Ie38c658bddb974ded85a532b2fc556af5706275e
2020-06-26 11:44:57 +02:00
jenkins-bot
038f57ec69 Merge "REST /me/contributions: return change tags" 2020-06-25 18:03:14 +00:00
Nikki Nikkhoui
7452d8c067 REST /me/contributions: return change tags
The endpoint for user contributions should include change tags in the
result. Bump the version of npm module api-testing.

Bug: T252202
Change-Id: Iccc0c378bc65d0f34b38557f4c78f424d95a951f
2020-06-25 19:28:02 +02:00
Ed Sanders
c7926a58d6 api-testing: Fix variable scopes to avoid shadowing
Change-Id: I3ba5e9bd98c0e66c7e4050ca5c9f0320042149d7
2020-06-24 13:21:36 +01:00
Ed Sanders
08510de602 api-testing: Use wikimedia/mocha eslint config
Change-Id: Iec346d87f252c66fbff1e0fa522d7440df6f1764
2020-06-18 19:20:33 +01:00
jenkins-bot
2d34500f59 Merge "UserContributions endpoint: filter suppressed revisions" 2020-06-16 18:33:33 +00:00
jenkins-bot
94a0cdec43 Merge "REST api: bump some endpoints to v1" 2020-06-16 16:36:21 +00:00
daniel
96aacab20b UserContributions endpoint: filter suppressed revisions
ContributionsLookup needs to have the acting user (the authority) passde
in explicitly, so suppressed user contributions can be filtered according
to the user's permissions.

Bug: T252202
Change-Id: I94098f87ae45cd4e1db4a7168bf6e9478e9e32fc
2020-06-16 08:20:32 -07:00
daniel
5601152836 REST /me/contributions: implement backwards paging
This is part of a chain of patches that implement the user
contributions endpoint. This patch adds the ability to navigate
towards newer newer contributions from a response listign older
contributions.

Bug: T252202
Change-Id: I54c43f3c7bd5d2fa55431eda733291a7067bfc75
2020-06-15 11:41:36 -07:00
Nikki Nikkhoui
fbe321166e REST /me/contributions: allow paging forward
This is part of a chain of patches that implement the
user contributions endpoint.

In this patch, we add the ability to page through changes,
from latest to oldest only.

Bug: T252202
Change-Id: If1e862e419ce86b68606ddf28a78304461d3a6d8
2020-06-12 13:50:16 +02:00
daniel
2f3e07a6c9 REST api: bump some endpoints to v1
The following endpoints move from v0 to v1:

  GET page/{title}/links/language
  GET page/{title}
  PUT page/{title}
  POST page
  GET page/{title}/bare
  GET page/{title}/html
  GET page/{title}/with_html
  GET page/{title}/links/media
  GET file/{title}

NOTE: after merging this, give SRE a heads up, e.g. by
putting a note on the train ticket when this is merged
(navigate from T254174 as appropriate). 

Bug: T255043
Change-Id: I3b8890da901e6312582d9a215c6a647173f16149
2020-06-11 20:16:47 +00:00
daniel
5ac84ffd12 REST /me/contributions: return revisions
This is part of a chain of patches to complete the REST User Contributions
endpoint. This change returns a list of the 2 (hard-coded for now) most
recent revisions for a given user.

Package.json was also updated for new api-testing module (v 1.1.0)

Bug: T252202
Change-Id: I42a5dfc0e1ff7600848e89ac2c4b002e8a3612df
2020-06-09 08:19:45 -07:00
Nikki Nikkhoui
300fcfd00b REST me/contributions: Returns 401 Unauthorized
This is the first in a chain of patches that iteratively create
the me/contributions endpoint that returns a list
of contributions by the currently logged in user.

This patch contains stubs for major classes needed
as well as implementation and test just for returning
a 401 Unauthorized for anonymous users.

Bug:T252202
Change-Id: Ib75711bb015f476e9d486cb3008eb7b06b148d00
2020-06-09 15:00:25 +00:00
daniel
2051b84e5f PageHistoryHandler: fix self-reference route
THis introduces Handler::getRouteUrl() and uses it in
PageHistoryHandler() to generate self-reference links to adjacent
segments of the response.

Bug: T252566
Change-Id: Ie7b2c6cc63c8a499d4714336b917a9e3328294ca
2020-06-08 18:56:26 +02:00
Ed Sanders
8b720e9bd6 eslint: Update to eslint-config-wikimedia 0.16.0
* valid-jsdoc replaced with jsdoc plugin
* New /selenium config

Change-Id: I471eebac0312cb25c539c3f6a3ecfc7cfd4ed8d6
2020-06-02 21:32:56 +01:00
jenkins-bot
f11aee48da Merge "CreationHandler: fix redirect URL" 2020-05-26 19:07:43 +00:00
daniel
504e9c446f CreationHandler: fix redirect URL
Add missing version prefix to Location header emitted after successful
creation.

Bug: T253143
Change-Id: I6262f61668cefacce12ed6f2a976340e10cf105b
2020-05-25 11:13:18 +02:00
Nikki Nikkhoui
eeac328472 Move Search endpoints into core routes
Move both search endpoints from coreDevelopmentRoutes to coreRoutes, making them
accessible in a production environment.

Change-Id: I14c1a9eb4c76a22f72caa7ae201699d4ef9eb282
2020-05-20 11:52:47 -07:00
Peter Ovchyn
7df7b923da rest: Add 'thumbnail' and 'description' fields to the search response
By default, core adds those fields as null to each row.
provideThumbnail and provideDescription hooks are introduced.
Extension should subscribe on the hooks to provide a thumbnail and description respectively.

Bug: T250144
Change-Id: I42c6c8ff9d887a440174af2a21c7921573b06640
2020-05-05 19:35:52 +03:00
jenkins-bot
f98a9e576a Merge "SearchHandler: emit Cache-Control header." 2020-04-06 15:53:50 +00:00
daniel
7d8fe94ea2 SearchHandler: emit Cache-Control header.
Completion search used for type-ahead should make use of http caches,
like ApiOpenSearch does.

Bug: T245675
Change-Id: Ia8366684203381b6c4dc55669a6877e53e9ffe40
2020-04-06 13:37:49 +02:00
jenkins-bot
83fc4e8c11 Merge "SearchHandler: add support for completion search" 2020-03-27 15:55:48 +00:00
daniel
76b703fe5c SearchHandler: add support for completion search
This defines a new REST route, /coredev/v0/search/title

Bug: T246387
Change-Id: Ib8d64f3028d3fa2ce239f922181064a3fc91a488
2020-03-26 20:38:30 +01:00
jenkins-bot
fde16090b6 Merge "REST endpoints: Add etag and last-modified headers" 2020-03-26 03:15:58 +00:00
jenkins-bot
6d791abd80 Merge "Define POST handler for /page/: create page" 2020-03-26 01:33:50 +00:00
daniel
22561b64a7 REST endpoints: Add etag and last-modified headers
Modified endpoints:
* /v1/page/{title}/history
* /v1/revision/{id}/bare
* /coredev/v0/page/{title}/links/language
* /coredev/v0/page/{title}/links/media
* /coredev/v0/file/{title}

Bug: T238374
Change-Id: I3ddf8fafc17eba3aec724a445d38af98bbc74dc1
2020-03-26 00:18:34 +01:00
daniel
c4382301cc REST Handlers: use max-age not maxage for cache-control
Smally typo, big consequence.

Change-Id: I1d8f43dd3b11e4854b08d41fb5f0c7ede3dba90e
2020-03-25 22:38:03 +01:00
daniel
65342f8353 Define POST handler for /page/: create page
NOTE: once this is merged, also merge Ie7b47e6868cc on the OAuth repo,
to fix unit tests after a breaking change to Router's constructor
signature.

Bug: T230842
Change-Id: I8f5b92918a58e44a4f2d8c78d234d9f64c2d06bf
2020-03-25 20:49:20 +01:00
daniel
81a47eaad3 page/update: return diffs on conflict
This adds diffs for use in an interactive merge when detecting an edit
conflict.

Bug: T230843
Change-Id: I6345361fce98524027ad778749d4fbf54169ccb6
2020-03-23 15:59:47 +00:00
daniel
58e5332991 page/update endpoint
Bug: T230843
Change-Id: I95289eddfc9ab2e0cef11b9363a5e239cdb2258e
2020-03-23 16:59:21 +01:00
daniel
c647e16c92 SearchHandler: implement limit parameter
The integration tests in Search.js were copied from the api-testing repo, see
<https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/tools/api-testing/+/refs/heads/master/test/REST/Search.js>

Bug: T245676
Change-Id: Icb4e9b363586914f2c4bcf809bde003d90c017db
2020-03-04 11:13:55 +01:00
Clara Andrew-Wani
aa0ad28c4f Move Search and Watchlist tests from api-testing repo into Core
Bug: T236680
Change-Id: Id1e37791576d27e5e7007387e91270392e7d5904
2020-02-06 00:55:53 +00:00
Clara Andrew-Wani
f07d7ba699 Move tests from api-testing repo into Core
Except for Search & Watchlist, which need fixes in gated extensions first.

Change-Id: I88d24dda4bc047868de3ff9dd4a5753b9c7b0f64
2020-02-05 16:07:54 -08:00
Petr Pchelko
a136005a35 REST: /page/{title}/{bare,html,with_html} endpoints backed by RESTBase.
Bug: T234377
Bug: T234375
Change-Id: I77709c17e951e3efb542028e5c0d53eedda8c7bf
2020-01-23 11:55:20 -08:00
Nikki Nikkhoui
6fc42ade9d PageSourceHandler integration tests
Add integration tests for /page/{title} endpoint
Bug: T229663

Change-Id: If8e140f70c518a8fa5e5eaef46f87a383c813e40
2020-01-14 16:43:43 -08:00